diff --git a/BSG Moderator Template.ods b/BSG Moderator Template.ods index 51051bd..436c360 100644 Binary files a/BSG Moderator Template.ods and b/BSG Moderator Template.ods differ diff --git a/BSG Moderator Template/Basic/Standard/BoardStatus.xml b/BSG Moderator Template/Basic/Standard/BoardStatus.xml index fef2610..7633756 100644 --- a/BSG Moderator Template/Basic/Standard/BoardStatus.xml +++ b/BSG Moderator Template/Basic/Standard/BoardStatus.xml @@ -443,6 +443,15 @@ sub Board_SetSpecial (effect as string) case "The Guardians" offseth = 7 offsetv = -4 + case "Lockdown" + offseth = 7 + offsetv = -6 + case "Hornet's Nest" + offseth = 7 + offsetv = -7 + case "Event Horizon" + offseth = 7 + offsetv = -2 case else foundeffect = FALSE end select @@ -516,7 +525,31 @@ sub Board_ClearSpecial (which as string) LogThis "Special: The Guardians are no longer in effect." end if end if - + if BoardSheet.GetCellByPosition(_SpecialsCol+7,_SpecialsRow-6).String <> "" then + BoardSheet.GetCellByPosition(_SpecialsCol+7,_SpecialsRow-6).String = "" + BoardSheet.GetCellByPosition(_SpecialsCol+7,_SpecialsRow-6).CellBackColor = _white + if which <> "All" then + MsgBox "Special: Lockdown is no longer in effect." + LogThis "Special: Lockdown is no longer in effect." + end if + end if + if BoardSheet.GetCellByPosition(_SpecialsCol+7,_SpecialsRow-7).String <> "" then + BoardSheet.GetCellByPosition(_SpecialsCol+7,_SpecialsRow-7).String = "" + BoardSheet.GetCellByPosition(_SpecialsCol+7,_SpecialsRow-7).CellBackColor = _white + if which <> "All" then + MsgBox "Special: Hornet's Nest is no longer in effect." + LogThis "Special: Hornet's Nest is no longer in effect." + end if + end if + if BoardSheet.GetCellByPosition(_SpecialsCol+7,_SpecialsRow-2).String <> "" then + BoardSheet.GetCellByPosition(_SpecialsCol+7,_SpecialsRow-2).String = "" + BoardSheet.GetCellByPosition(_SpecialsCol+7,_SpecialsRow-2).CellBackColor = _white + if which <> "All" then + MsgBox "Special: Event Horizon is no longer in effect." + LogThis "Special: Event Horizon is no longer in effect." + end if + end if + if which = "All" then BoardSheet.GetCellByPosition(_DetectorCol,_DetectorRow).String = "" BoardSheet.GetCellByPosition(_DetectorCol,_DetectorRow).CellBackColor = _white @@ -563,6 +596,20 @@ sub Board_ClearSpecial (which as string) MsgBox "Special: Dogfight is no longer in effect." LogThis "Special: Dogfight is no longer in effect." end if + elseif which = "Lockdown" then + if BoardSheet.GetCellByPosition(_SpecialsCol+7,_SpecialsRow-6).String <> "" then + BoardSheet.GetCellByPosition(_SpecialsCol+7,_SpecialsRow-6).String = "" + BoardSheet.GetCellByPosition(_SpecialsCol+7,_SpecialsRow-6).CellBackColor = _white + MsgBox "Special: Lockdown is no longer in effect." + LogThis "Special: Lockdown is no longer in effect." + end if + elseif which = "Hornet's Nest" then + if BoardSheet.GetCellByPosition(_SpecialsCol+7,_SpecialsRow-7).String <> "" then + BoardSheet.GetCellByPosition(_SpecialsCol+7,_SpecialsRow-7).String = "" + BoardSheet.GetCellByPosition(_SpecialsCol+7,_SpecialsRow-7).CellBackColor = _white + MsgBox "Special: Hornet's Nest is no longer in effect." + LogThis "Special: Hornet's Nest is no longer in effect." + end if end if end sub diff --git a/BSG Moderator Template/Basic/Standard/Ships.xml b/BSG Moderator Template/Basic/Standard/Ships.xml index 83ec442..8bab035 100644 --- a/BSG Moderator Template/Basic/Standard/Ships.xml +++ b/BSG Moderator Template/Basic/Standard/Ships.xml @@ -841,9 +841,13 @@ sub SetShipStatus (shiptype, shipid, ByVal targetstatus, optional seldamage as s exit sub elseif targetstatus = _ShipStatusDestroyed then Board_ClearSpecial("Thirty-Three") + Board_ClearSpecial("Lockdown") + Board_ClearSpecial("Hornet's Nest") targetstatus = _ShipStatusOffBoard elseif targetstatus = _ShipStatusRemoved then Board_ClearSpecial("Thirty-Three") + Board_ClearSpecial("Lockdown") + Board_ClearSpecial("Hornet's Nest") targetstatus = _ShipStatusDestroyed end if end if @@ -932,6 +936,10 @@ sub SetShipStatus (shiptype, shipid, ByVal targetstatus, optional seldamage as s end if if shiptype =_ShipCivilian or shiptype =_ShipBasestar then Board_ClearSpecial("Thirty-Three") + if shiptype =_ShipBasestar then + Board_ClearSpecial("Lockdown") + Board_ClearSpecial("Hornet's Nest") + end if end if else ShipSheet.GetCellByPosition(ShipCol(ShipType, _ShipColDestroyed), ShipRow(ShipType) + ShipID).string = "" @@ -2111,4 +2119,4 @@ function RepairVipers (shiptype as integer, shipcnt as integer) next i end function - \ No newline at end of file + diff --git a/BSG-Pegasus.scm b/BSG-Pegasus.scm index fc95b2b..45f9a46 100644 --- a/BSG-Pegasus.scm +++ b/BSG-Pegasus.scm @@ -263,7 +263,7 @@ 1 3 1 7 7 7 1 7 7 7 7 4 2 8 2 8 5 4 9 - 10 38 12 12 12 1 8 9 + 10 38 12 12 12 1 11 9 2 5 30 6 1 7 6 7 4 4 12 14 6 6 32 6 @@ -803,13 +803,13 @@ ) (set! voffset (quotient specialcnt 2)) (set! specoff 0) - (while (< specoff 8) + (while (< specoff 11) (when (string=5? (car (gimp-layer-get-name (vector-ref mylayers (+ c_specpos specoff)))) (car myvalues)) (begin (gimp-drawable-set-visible (vector-ref mylayers (+ c_specpos specoff)) TRUE) (gimp-layer-translate (vector-ref mylayers (+ c_specpos specoff)) (* hoffset 700) (* voffset 36)) (set! specialcnt (++ specialcnt)) - (set! specoff 8) + (set! specoff 11) ) ) ;when (set! specoff (++ specoff)) diff --git a/BSG-Util.scm b/BSG-Util.scm index b2f0067..c506ca6 100644 --- a/BSG-Util.scm +++ b/BSG-Util.scm @@ -35,6 +35,43 @@ (define (++ srcval) (let* ()(+ srcval 1))) (define (-- srcval) (let* ()(- srcval 1))) +; This reads either the next string, or the rest of the line as a scheme symbol +; This is to work around the changes to how the "read" builtin handles the " deliminator +; between tinyscheme 1.40 and 1.41, which breaks the assumptions in getcvsline and +; causes it to fail with gimp 2.10 +(define (readstringorsymbol in) +(let* + ( + (valuelst '()) + (templst '()) + (tempstr nil) + (symbolstr nil) + (nextitem nil) + ) + (set! nextitem (read in)) + (if (and (symbol? (list-ref nextitem 1)) (not (char-ci=? (peek-char in) #\newline))) + (begin + ; We have a symbol, but we didn't read to the newline, so we have to create + ; a symbol with the rest of the line + (while (not (char-ci=? (peek-char in) #\newline)) + (set! templst (append templst (list (read-char in)))) + ) ; while + (set! tempstr (list->string templst)) + (set! symbolstr (symbol->string (list-ref nextitem 1))) + (set! symbolstr (string-append symbolstr tempstr)) + (set! valuelst (append valuelst (list (list-ref nextitem 0)))) + (set! valuelst (append valuelst (list (string->symbol symbolstr)))) + ) + (begin + ; else we just return the read results + (set! valuelst nextitem) + ) + ) ; if + (set! valuelst valuelst) +) ; let +) ; define + + ; Reading from the csv is a strange process. Each line will start with a string. The first string of the first line should have ; already been read when this is called. each call of this reads everyhing after the first string and builds it in a list (A), then ; reads the first string of the next line (B) and returns a list comprising ((A) (B)). @@ -56,7 +93,7 @@ (logflag FALSE) (havenexttok nil) ) - (set! nextitem (read in)) + (set! nextitem (readstringorsymbol in)) (set! valuelst '()) (while (not (or (string? nextitem) (eof-object? nextitem))) (set! havenexttok FALSE) diff --git a/BSGP - MASTER.xcf b/BSGP - MASTER.xcf index a12fd91..69dc4b4 100644 Binary files a/BSGP - MASTER.xcf and b/BSGP - MASTER.xcf differ diff --git a/Image_Tests/.gitignore b/Image_Tests/.gitignore new file mode 100644 index 0000000..1a06816 --- /dev/null +++ b/Image_Tests/.gitignore @@ -0,0 +1 @@ +results diff --git a/Image_Tests/Reference_Images/BSGP TEST - 1.1.jpg b/Image_Tests/Reference_Images/BSGP TEST - 1.1.jpg new file mode 100644 index 0000000..c29ac87 Binary files /dev/null and b/Image_Tests/Reference_Images/BSGP TEST - 1.1.jpg differ diff --git a/Image_Tests/Reference_Images/BSGP TEST - 1.2.jpg b/Image_Tests/Reference_Images/BSGP TEST - 1.2.jpg new file mode 100644 index 0000000..fb16b60 Binary files /dev/null and b/Image_Tests/Reference_Images/BSGP TEST - 1.2.jpg differ diff --git a/Image_Tests/Reference_Images/README b/Image_Tests/Reference_Images/README new file mode 100644 index 0000000..6803e71 --- /dev/null +++ b/Image_Tests/Reference_Images/README @@ -0,0 +1,4 @@ +These are images of the test csv files generated by using Gimp 2.8.22 on a Linux x86_64 +machine. + +Images generated by other gimp version should be identical, barring jpeg compression artifacts. diff --git a/Image_Tests/data/BSGP TEST - 1.1.csv b/Image_Tests/data/BSGP TEST - 1.1.csv new file mode 100644 index 0000000..436f3b2 --- /dev/null +++ b/Image_Tests/data/BSGP TEST - 1.1.csv @@ -0,0 +1,67 @@ +"Game","TEST","1.1","Pegasus","Exodus","Daybreak","NoRevelations","Ionian Earth","Standard","log",,,,,, +"Characters","Baltar","Cain","Starbuck","Chief","Helo","Anders","",,,,,,,, +";Option",,,,,,,,,,,,,,, +"Resources",8,8,10,12,,,,,,,,,,, +"PlayerCards",0,0,0,0,0,0,0,,,,,,,, +"PlayerLocations","Research Lab","Pegasus CIC","Hangar Deck","Hangar Deck","Stranded on Caprica","Armory","",,,,,,,, +"SkillDecks",33,33,33,33,33,24,0,,,,,,,, +"Reserves",0,3,4,0,0,1,,,,,,,,, +"Decks",12,143,30,28,0,12,21,"",,,,,,, +"CivShips",7,0,0,,,,,,,,,,,, +"Roles",1,5,1,2,2,0,1,,,,,,,, +"JumpTrack",0,"",,,,,,,,,,,,, +";GamePhase",1,,,,,,,,,,,,,, +"Assignments","STRA",5,"","","","","","",,,,,,, +";BoardingParty",0,0,0,0,,,,,,,,,,, +";OccForce",0,0,0,,,,,,,,,,,, +";Distance","","","","","","","","","",,,,,, +"BoardSpecial","","","","","","","","","The Guardians","","","","Lockdown","","" +"OPG",1,1,1,1,1,1,"",,,,,,,, +";Damage","","","","","","","","","","","","",,, +";Graveyard","","","","","","","","","",,,,,, +";Cylons","","","","",,,,,,,,,,, +";Cylons","","","","",,,,,,,,,,, +";Cylons","","","","",,,,,,,,,,, +";Cylons","","","","",,,,,,,,,,, +";Cylons","","","","",,,,,,,,,,, +";Cylons","","","","",,,,,,,,,,, +";Cylons","","","","",,,,,,,,,,, +"Basestar",1,"","",,,,,,,,,,,, +"Basestar",1,"","",,,,,,,,,,,, +";Scar","",,,,,,,,,,,,,, +";Option",0,,,,,,,,,,,,,, +"Sector",1,0,3,0,0,0,,,,,,,,, +"Sector",2,0,2,0,0,0,,,,,,,,, +"Sector",3,1,0,0,0,0,,,,,,,,, +"Sector",4,0,0,1,0,0,,,,,,,,, +"Sector",5,0,0,2,0,0,,,,,,,,, +"Sector",6,0,2,2,0,0,,,,,,,,, +"Civilians",4,"A",,,,,,,,,,,,, +"Civilians",4,"B",,,,,,,,,,,,, +"Civilians",4,"C",,,,,,,,,,,,, +"Civilians",4,"D",,,,,,,,,,,,, +"Civilians",5,"E",,,,,,,,,,,,, +";Civilians","","",,,,,,,,,,,,, +";Civilians","","",,,,,,,,,,,,, +";Civilians","","",,,,,,,,,,,,, +";Civilians","","",,,,,,,,,,,,, +";Civilians","","",,,,,,,,,,,,, +";Civilians","","",,,,,,,,,,,,, +";Civilians","","",,,,,,,,,,,,, +";Option",,,,,,,,,,,,,,, +"Option","JPG",,,,,,,,,,,,,, +";CylonFleet",1,0,0,,,,,,,,,,,, +";CylonFleet",2,0,0,,,,,,,,,,,, +";CylonFleet",3,0,0,,,,,,,,,,,, +";CylonFleet",4,0,0,,,,,,,,,,,, +";CylonFleet",5,0,0,,,,,,,,,,,, +";CylonFleet",6,0,0,,,,,,,,,,,, +"Allies","Alex “Crashdown” Quartararo","Armory","Laura Roslin","President's Office","Tory Foster","Press Room",,,,,,,,, +"Trauma",3,3,3,3,3,3,0,,,,,,,, +"LoyaltyCards",2,1,1,1,1,1,0,,,,,,,, +"BGColor","Match",43,58,102,,,,,,,,,,, +"ResourceDamage",0,0,,,,,,,,,,,,, +"DamagedCivilians",0,0,0,0,0,,,,,,,,,, +"Mutiny",1,0,0,0,0,0,0,,,,,,,, +"SearchForHome","Unallied","None","None",,,,,,,,,,,, +"DestroyedBasestar",0,0,,,,,,,,,,,,, diff --git a/Image_Tests/data/BSGP TEST - 1.2.csv b/Image_Tests/data/BSGP TEST - 1.2.csv new file mode 100644 index 0000000..2cb71fc --- /dev/null +++ b/Image_Tests/data/BSGP TEST - 1.2.csv @@ -0,0 +1,67 @@ +"Game","TEST","1.2","Pegasus","Exodus","Daybreak","NoRevelations","Ionian Earth","Standard","log",,,,,, +"Characters","Baltar","Cain","Starbuck","Chief","Helo","Anders","",,,,,,,, +"Option","OutlineCounters",,,,,,,,,,,,,, +"Resources",8,8,10,12,,,,,,,,,,, +"PlayerCards",0,0,0,0,0,0,0,,,,,,,, +"PlayerLocations","Research Lab","Pegasus CIC","Resurrection Ship","Hangar Deck","Stranded on Caprica","Armory","",,,,,,,, +"SkillDecks",33,33,33,33,33,24,0,,,,,,,, +"Reserves",0,1,4,0,0,1,,,,,,,,, +"Decks",12,124,30,28,0,11,21,"",,,,,,, +"CivShips",0,0,0,,,,,,,,,,,, +"Roles",2,5,1,2,2,0,1,,,,,,,, +"JumpTrack",0,"",,,,,,,,,,,,, +";GamePhase",1,,,,,,,,,,,,,, +"Assignments","STRA",5,"","","","","","",,,,,,, +";BoardingParty",0,0,0,0,,,,,,,,,,, +";OccForce",0,0,0,,,,,,,,,,,, +";Distance","","","","","","","","","",,,,,, +"BoardSpecial","","","Jammed Assault","Thirty-Three","","","","","","","","Hornet's Nest","Lockdown","","" +"OPG",1,1,0,1,1,1,"",,,,,,,, +";Damage","","","","","","","","","","","","",,, +";Graveyard","","","","","","","","","",,,,,, +";Cylons","","","","",,,,,,,,,,, +";Cylons","","","","",,,,,,,,,,, +"Cylons",3,"C",1,0,,,,,,,,,,, +";Cylons","","","","",,,,,,,,,,, +";Cylons","","","","",,,,,,,,,,, +";Cylons","","","","",,,,,,,,,,, +";Cylons","","","","",,,,,,,,,,, +"Basestar",1,"","",,,,,,,,,,,, +"Basestar",2,"","",,,,,,,,,,,, +";Scar","",,,,,,,,,,,,,, +";Option",0,,,,,,,,,,,,,, +"Sector",1,2,6,0,0,0,,,,,,,,, +"Sector",2,2,4,0,0,0,,,,,,,,, +";Sector",3,0,0,0,0,0,,,,,,,,, +"Sector",4,0,3,1,0,0,,,,,,,,, +"Sector",5,0,0,3,0,0,,,,,,,,, +"Sector",6,0,0,3,0,0,,,,,,,,, +"Civilians",4,"A",,,,,,,,,,,,, +"Civilians",4,"B",,,,,,,,,,,,, +"Civilians",4,"C",,,,,,,,,,,,, +"Civilians",5,"D",,,,,,,,,,,,, +"Civilians",1,"E",,,,,,,,,,,,, +"Civilians",4,"F",,,,,,,,,,,,, +"Civilians",5,"G",,,,,,,,,,,,, +"Civilians",6,"H",,,,,,,,,,,,, +"Civilians",3,"I",,,,,,,,,,,,, +"Civilians",4,"J",,,,,,,,,,,,, +"Civilians",5,"K",,,,,,,,,,,,, +"Civilians",6,"L",,,,,,,,,,,,, +";Option",,,,,,,,,,,,,,, +"Option","JPG",,,,,,,,,,,,,, +";CylonFleet",1,0,0,,,,,,,,,,,, +";CylonFleet",2,0,0,,,,,,,,,,,, +";CylonFleet",3,0,0,,,,,,,,,,,, +";CylonFleet",4,0,0,,,,,,,,,,,, +";CylonFleet",5,0,0,,,,,,,,,,,, +";CylonFleet",6,0,0,,,,,,,,,,,, +"Allies","Alex “Crashdown” Quartararo","Armory","Laura Roslin","President's Office","Tory Foster","Press Room",,,,,,,,, +"Trauma",3,3,3,3,3,3,0,,,,,,,, +"LoyaltyCards",2,1,0,1,1,1,0,,,,,,,, +"BGColor","Match",43,58,102,,,,,,,,,,, +"ResourceDamage",0,0,,,,,,,,,,,,, +"DamagedCivilians",0,0,0,0,0,,,,,,,,,, +"Mutiny",1,0,0,0,0,0,0,,,,,,,, +"SearchForHome","Unallied","None","None",,,,,,,,,,,, +"DestroyedBasestar",0,0,,,,,,,,,,,,, diff --git a/Image_Tests/data/BSGP TEST - MASTER.xcf b/Image_Tests/data/BSGP TEST - MASTER.xcf new file mode 100644 index 0000000..69dc4b4 Binary files /dev/null and b/Image_Tests/data/BSGP TEST - MASTER.xcf differ diff --git a/Image_Tests/make_diff_image.py b/Image_Tests/make_diff_image.py new file mode 100755 index 0000000..1192a40 --- /dev/null +++ b/Image_Tests/make_diff_image.py @@ -0,0 +1,46 @@ +#!/usr/bin/python3 +# +# Use the python imaging library to construct a difference image between the results +# and reference images + +import sys +import os + +from PIL import Image + + +def do_cmp(): + basedir = os.path.dirname(sys.argv[0]) + reference = os.path.join(basedir, 'Reference_Images') + results = os.path.join(basedir, 'results') + + files = os.listdir(reference) + + for cand in files: + if not cand.endswith('.jpg'): + continue + cand_result = os.path.join(results, cand) + if not os.path.exists(cand_result): + print(f"Missing results image: {cand}") + continue + ref1 = Image.open(os.path.join(reference, cand)) + result1 = Image.open(cand_result) + if ref1.width != result1.width: + print(f"{cand_result} and {cand} have different widths - Cannot compare") + if ref1.height != result1.height: + print(f"{cand_result} and {cand} have different heights - Cannot compare") + diff = Image.new('RGB', (ref1.width, ref1.height)) + diff_name = cand_result.replace('.jpg','-diff.jpg') + for x in range(ref1.width): + for y in range(ref1.height): + p1 = ref1.getpixel((x,y)) + p2 = result1.getpixel((x,y)) + val = [abs(p1[i] - p2[i]) for i in range(3)] + val = tuple([x if x < 255 else 255 for x in val]) + diff.putpixel((x, y), val) + diff.save(diff_name) + + +if __name__ == "__main__": + do_cmp() + diff --git a/Image_Tests/run_tests.sh b/Image_Tests/run_tests.sh new file mode 100755 index 0000000..7345f4f --- /dev/null +++ b/Image_Tests/run_tests.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e +# Runs the image generation tests using the default version of the gimp +IFS=' +' + +mkdir -p results +rm -f results/*jpg +cd data +for x in *csv; do + fullname=$(readlink -f "$x") + gimp -i -b "(script-fu-BSGP-Run-Batch \"$fullname\")" -b '( gimp-quit 1 )' + mv ${x/csv/jpg} ../results + rm ${x/csv/xcf} + rm *log +done