-
Notifications
You must be signed in to change notification settings - Fork 5
/
BSG-Pegasus.scm
2379 lines (2136 loc) · 98 KB
/
BSG-Pegasus.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;; THIS FILE IS FOR THE PEGASUS VERSION ONLY...BASE GAME SCRIPT IS DIFFERENT
; THIS FILE IS FOR THE PEGASUS VERSION ONLY...BASE GAME SCRIPT IS DIFFERENT
;gimp invokation:
;gimp-2.g -b "(script-fu-BSGP-Run-Batch \"C:\\Documents and Settings\\Aaron Walker\\Desktop\\BSG PBEM Games\\sandbox\\TestData.csv\")" -b "(gimp-quit 0)"
; globals..they're ugly, but they save us from other constraints and from passing mylayers to every function
(define mylayers nil)
(define asgncnt nil)
(define civcnt nil)
(define specialcnt nil)
(define basestarfirst nil)
(define cardoffsetY nil)
(define playercount nil)
(define imgscale 0.75) ;use this to scale images on the cylon fleet board
(define image nil)
(define outlineoption FALSE)
(define (script-fu-BSGP-Run-Batch FileName)
(while (= 32 (char->integer (string-ref FileName 0)))
(set! FileName (substring FileName 1))
)
(script-fu-BSGP-Run 0 FileName)
)
(script-fu-register "script-fu-BSGP-Run-Batch"
""
"BSG Pegasus Run in Batch Mode"
"APW"
"APW"
"Now"
"RGB*"
SF-VALUE "Data File Name" ""
)
(script-fu-register "script-fu-BSGP-Run"
"<Image>/BSGP-Run"
"BSG Import"
"APW"
"APW"
"Now"
"RGB*"
SF-TOGGLE "Show Image Upon Completion?" TRUE
SF-FILENAME "Data File" ""
)
(define (script-fu-BSGP-Run showimage FileName)
(let*
(
(datafile nil)
(data nil)
(myvalues nil)
(setname nil)
(gamename nil)
(gameturn nil)
(nexttok "")
(filepath nil)
(fname nil)
(fname2 nil)
; (image nil)
(drawable nil)
(jpgimage 0)
(showships 0)
(objflag nil)
(usePeg FALSE)
(useExo FALSE)
(useDB FALSE)
(useRev FALSE)
(useCF FALSE)
(useCCW FALSE)
)
(set! asgncnt (make-vector 8 0))
(set! civcnt (make-vector 6 0))
(set! specialcnt 0)
(set! basestarfirst 0)
(set! logfname "bsgp-Run.log")
(set! objflag "New Caprica")
(set! filepath (car (splitfullfname FileName)))
(if (string=? (caddr (splitfullfname FileName)) "csv")
(begin
(set! datafile (open-input-file FileName))
(set! nexttok (read datafile)) ; this should be "Game"
)
(begin
(initlog filepath) ;do this to make sure there is a valid log file open
(logit "Invalid file type, must be .csv")
)
)
(if (string=? nexttok "Game")
(begin
(set! data (getcsvline datafile))
(set! setname nexttok)
(set! myvalues (car data))
(set! nexttok (cadr data))
; Game-specific data
(set! gamename (car myvalues))
(set! gameturn (cadr myvalues))
; Expansions
(set! myvalues (cddr myvalues))
(set! usePeg (string=? (car myvalues) "Pegasus")) ; Need to know whether to show Pegasus/Overlay/Treachery
(set! useExo (string=? (cadr myvalues) "Exodus")) ; Need a graveyard for executions, and the Loyalty cards.
(set! useDB (string=? (caddr myvalues) "Daybreak")) ; Colonial One overlay, Mutiny Deck
(set! useRev (string=? (cadddr myvalues) "Revelations")) ; Faith deck
; Modules
(set! myvalues (cddddr myvalues))
(set! objflag (car myvalues))
(set! useCF (string=? (cadr myvalues) "Cylon Fleet"))
;(set! useCCW (
; We can't put the 'log' token at the top of the list.
(when (and (not (null? (cddr myvalues))) (string-ci=? (caddr myvalues) "Log")) (initlog filepath))
(p_getlayerpos "ALL") ;debugging only
(logit (string-append gamename " ---- Turn " gameturn))
(set! fname (string-append filepath (bsgp-make-fname gamename "MASTER.xcf")))
(set! image (car (gimp-file-load 1 fname fname)))
(set! drawable (car (gimp-image-get-active-drawable image)))
(set! mylayers (cadr (gimp-image-get-layers image)))
(set! cardoffsetY (bsgp-ConfigureBoard image objflag usePeg useExo useCF useDB useRev) )
(gimp-text-layer-set-text (vector-ref mylayers (p_getlayerpos "Turn")) (string-append "Turn " gameturn))
; Giant while loop to read in lines, then process them.
(while (not (eof-object? nexttok))
(set! data (getcsvline datafile))
(set! setname nexttok)
(set! myvalues (car data))
(logit setname)
(logit myvalues)
(set! nexttok (cadr data))
(case (string->symbol setname)
((Characters) (bsgp-Characters image myvalues) (set! mylayers (cadr (gimp-image-get-layers image))))
((EliminatedCharacters) (bsgp-EliminatedCharacters myvalues))
((Reserves)
(when (= (length myvalues) 4)
(bsgp-DeadVipers (car (reverse myvalues)))
(set! myvalues (reverse (cdr (reverse myvalues))))
) ;when
(bsgp-Counters myvalues (p_getlayerpos "Reserves"))
)
((Resources) (bsgp-Counters myvalues (p_getlayerpos "FuelCntr")))
((ResourceDamage) (bsgp-ResourceDamage myvalues))
((Decks) (bsgp-Counters myvalues (p_getlayerpos "Destiny")))
((SkillDecks) (bsgp-Counters myvalues (p_getlayerpos "PoliticsCntr")))
((PlayerCards) (bsgp-Counters myvalues (p_getlayerpos "PlayerCardCntr")))
((CivShips) (bsgp-Counters myvalues (p_getlayerpos "CivCntr")))
((DamagedCivilians) (bsgp-DamagedCivilians myvalues (p_getlayerpos "DamagedCivs")))
((DestroyedBasestar) (bsgp-DestroyedBasestar myvalues (p_getlayerpos "DestroyedBasestar")))
((Roles) (bsgp-Roles myvalues))
((PlayerLocations) (bsgp-Players myvalues useDB))
((JumpTrack) (bsgp-JumpTrack myvalues))
((BoardingParty) (bsgp-BoardingParty myvalues 1))
((OccForce) (bsgp-BoardingParty myvalues 0))
((Distance) (bsgp-Distance myvalues))
((GamePhase) (bsgp-Phase myvalues useCF))
((OPG) (bsgp-1PG myvalues))
((Damage) (bsgp-Damage myvalues))
((BoardSpecial) (bsgp-BoardSpecial myvalues))
((Assignments) (bsgp-Assignments myvalues))
((Graveyard) (bsgp-Graveyard image myvalues))
((Cylons) (bsgp-Cylons myvalues))
((Sector) (bsgp-Sector myvalues TRUE showships))
((CylonFleet) (bsgp-Sector myvalues FALSE showships))
((Scar) (bsgp-ShipsHRV (car myvalues) 4 1 showships))
((Basestar) (bsgp-Basestar myvalues))
((Civilians) (bsgp-ShipsCivilians (car myvalues) (cdr myvalues)))
((Objective) (bsgp-Objective myvalues))
((Allies) (bsgp-Allies myvalues useDB))
((Trauma) (bsgp-TrLoy myvalues "Trauma"))
((LoyaltyCards) (bsgp-TrLoy myvalues "LoyaltyCards"))
((Mutiny) (bsgp-TrLoy myvalues "Mutiny"))
((BGColor) (bsgp-BGColor myvalues))
((SearchForHome) (bsgp-SearchForHome myvalues))
((Option)
(case (string->symbol (car myvalues))
((ShowShips) (set! showships 1))
((View) (set! showimage 1))
((JPG) (set! jpgimage 1))
((OutlineCounters) (set! outlineoption TRUE))
)
)
) ;case
) ;while
(set! fname (string-append filepath (bsgp-make-fname gamename gameturn) ".xcf"))
; we need to reset drawable because if there was outlinging (with creation & destruction of layers), it may no longer be valid
(set! drawable (car (gimp-image-get-active-drawable image)))
(logit (gimp-file-save 0 image drawable fname fname))
(when (= jpgimage 1)
(gimp-image-flatten image)
(set! drawable (car (gimp-image-get-active-drawable image)))
(set! fname2 (string-append filepath (bsgp-make-fname gamename gameturn) ".jpg"))
(logit (file-jpeg-save 1 image drawable fname2 fname2 0.5 0 1 0 "Generated by bsgp-Run" 0 1 0 0))
)
(when (= showimage 1)
(gimp-image-delete image)
(set! image (car (gimp-file-load 1 fname fname)))
(set! drawable (car (gimp-image-get-active-drawable image)))
(gimp-display-new image)
(gimp-image-clean-all image)
)
) ;if
(begin
(initlog filepath) ;do this to make sure there is a valid log file open
(logit "Invalid data, no Game record found.")
)
) ;when
(logit "End")
(when (port? datafile) (close-input-port datafile))
(initlog "")
) ;let*
) ;define
(define (bsgp-make-fname gamename turnname)
(string-append "BSGP " gamename " - " turnname))
(define (btoint boolres)
; this takes a boolean (#t or #f) and turns it into the GIMP integer equivalent
(if (eq? #t boolres) TRUE FALSE))
(define (MoveTokenToPlayer layerpos playerid)
(gimp-drawable-set-visible (vector-ref mylayers layerpos) TRUE)
(gimp-layer-translate (vector-ref mylayers layerpos) 0 (* cardoffsetY (-- playerid)))
)
(define (p_getused posname)
(let*
(
(mycnt 0)
(mypos nil)
)
(set! mypos (p_getlayerpos posname))
(while (= (car (gimp-drawable-get-visible (vector-ref mylayers mypos))) TRUE)
(set! mypos (++ mypos))
(set! mycnt (++ mycnt))
)
mycnt
) ;let
) ;define
;
(define (p_getlayerpos layername)
(let*
(
(offsets #(0 6 1 6 4
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
2 5 30 6 1
7 6 7 4 4
12 14 6 6 32 6
10 2 7 7 7 7
1 9 38 3 35
1 9 1 2 2 1 1 1 1 5
2 1 1 1 1 1 1 3)
)
(names #("Filter" "Turn" "Reserves" "FuelCntr" "Distance"
"CivCntr" "Destiny" "CrisisCntr" "PoliticsCntr" "PlayerCardCntr"
"QuorumCntr" "LoyaltyCntr" "TraumaCntr" "MutinyCntr" "Eliminated" "FuelDial" "ResourceDamage" "DamagedCivs" "DestroyedBasestar" "DeadViper" "JumpTrack"
"PursuitTrack" "Current" "DamageToken"
"PlayerToken" "Pilot" "PilotMkVII" "PilotAR" "Scar" "Special" "CurrentMission" "CurrentMissionStatus"
"FinalDest" "JumpDistance" "ReserveToken" "CivToken" "Cylon"
"SuperCrisis" "Assign" "OccForce" "Centurion" "Civilian"
"Viper" "ViperMkVII" "AssaultRaptor" "Raider" "HeavyRaider" "BasestarDmg"
"Basestar" "SkillCard" "LoyaltyCard" "Trauma" "Mutiny" "Stranded"
"1PG" "PlayerCard" "BlankCard5" "Allies" "NCCivToken"
"CrisisToken" "HubDestroyed" "RebelBasestarToken" "CylonLocations" "CylonFleet" "NewCaprica" "Demetrius" "RebelBasestar" "PoliticsDeck" "TreacheryDeck"
"PegasusDestroyed" "ColonialOneDestroyed" "ColonialOneDaybreak" "Pegasus" "Graveyard" "Logo" "Borders" "MainBoard")
)
(fnd nil)
(cnt 0)
(totaloffset 0)
)
(while (< cnt (vector-length offsets))
(set! totaloffset (+ totaloffset (vector-ref offsets cnt)))
(when (string=? layername "ALL")
(logit (string-append (number->string cnt) ": " (vector-ref names cnt) "(" (number->string totaloffset) ")")); (" (number->string (vector-ref offsets (+ cnt 1) )) ")"))
)
(when (string=? layername (vector-ref names cnt))
(set! fnd totaloffset)
(set! cnt (vector-length offsets))
)
(set! cnt (++ cnt))
)
(when (and (null? fnd) (not (string=? layername "ALL"))) (logit (string-append "ERROR - Could not find Layer: " layername)))
fnd
)
) ;p_getlayerpos
;
(define (bsgp-ResourceDamage myvalues)
(let*
(
(layerpos (p_getlayerpos "ResourceDamage"))
)
(when (= (car myvalues) 1) (gimp-drawable-set-visible (vector-ref mylayers layerpos) TRUE))
(when (= (cadr myvalues) 1) (gimp-drawable-set-visible (vector-ref mylayers (+ layerpos 1)) TRUE))
)
)
(define (bsgp-Counters myvalues layerpos)
(let*
(
(fmt (vector -1 -1 -1 -1 -1 -1 -1 ; Filters, turn
2 2 2 2 2 2 ; Reserves
1 1 1 1 ; Resources
0 3 3 3 0 ; Distance, Civilians, Destiny
3 3 3 3 3 3 3 ; Crises, Quorum, Supers, Mutiny
0 0 0 0 0 0 0 ; Skills
0 0 0 0 0 0 0 0 ; Hands, Quorum
0 0 0 0 0 0 0 ; loyalty counts
0 0 0 0 0 0 0 ; trauma counts
0 0 0 0 0 0 0) ; mutiny counts
)
;fmt values: 0=number only, 1=number + Dial, 2 = x##, 3=x ##
(dial (vector 8 8 10 12))
(dial_id nil)
(dial_layerid nil)
(dial_rot nil)
(rot1 (* 22.5 0.0175)) ;22.5 degrees in radians
)
(while (and (not (null? myvalues)) (number? (car myvalues)))
(case (vector-ref fmt layerpos)
((0) (gimp-text-layer-set-text (vector-ref mylayers layerpos) (number->string (car myvalues))))
((1)
(gimp-text-layer-set-text (vector-ref mylayers layerpos) (number->string (car myvalues)))
(set! dial_id (- layerpos (p_getlayerpos "FuelCntr")))
(set! dial_layerid (vector-ref mylayers (+ (p_getlayerpos "FuelDial") dial_id)))
(set! dial_rot (* (- (car myvalues) (vector-ref dial dial_id)) rot1))
(gimp-drawable-transform-rotate-default dial_layerid dial_rot TRUE 0 0 TRUE TRANSFORM-RESIZE-ADJUST)
)
((2) (gimp-text-layer-set-text (vector-ref mylayers layerpos) (string-append (if (> 10 (car myvalues)) "x " "x") (number->string (car myvalues)))))
((3) (gimp-text-layer-set-text (vector-ref mylayers layerpos) (string-append (if (> 100 (car myvalues)) "x " "x") (number->string (car myvalues)))))
) ;case
(when (and (= outlineoption TRUE) (not (= layerpos (p_getlayerpos "Distance")) )) ;we don't do an outline for distance, it's black already
(outlineText (vector-ref mylayers layerpos) 6 '(0 0 0))
(set! mylayers (cadr (gimp-image-get-layers image)))
)
(set! myvalues (cdr myvalues))
(set! layerpos (++ layerpos))
) ;while
) ;let
) ;define
(define (bsgp-DeadVipers vipercnt)
(let*
(
(deadpos (p_getlayerpos "DeadViper"))
)
(while (> vipercnt 0)
(gimp-drawable-set-visible (vector-ref mylayers deadpos) TRUE)
(set! deadpos (++ deadpos))
(set! vipercnt (-- vipercnt))
) ;while
) ;let
) ;define
(define (bsgp-JumpTrack myvalues)
(let*
(
(JumpLayerpos (p_getlayerpos "JumpTrack"))
(curjump JumpLayerpos)
(jumpstate nil)
)
(set! jumpstate (car myvalues))
(while (< curjump (+ JumpLayerpos 5))
(when (= curjump (+ jumpstate JumpLayerpos))
(gimp-drawable-set-visible (vector-ref mylayers curjump) TRUE)
(set! curjump (+ JumpLayerpos 5))
)
(set! curjump (++ curjump))
) ;while
(when (= (length myvalues) 2) ;we have a pursuittrack value
(set! jumpstate (cadr myvalues))
(set! JumpLayerpos (p_getlayerpos "PursuitTrack"))
(set! curjump JumpLayerpos)
(while (< curjump (+ JumpLayerpos 4))
(when (= curjump (+ jumpstate JumpLayerpos))
(gimp-drawable-set-visible (vector-ref mylayers curjump) TRUE)
(set! curjump (+ JumpLayerpos 4))
)
(set! curjump (++ curjump))
) ;while
) ;when
); let
);define
(define (bsgp-BoardingParty myvalues whichtype)
; this is used for both the centurions on Galactica and the occupation forces on New Caprica
; whichtype: 1=centurions, 2=occupation forces
(let*
(
(curCentpos nil)
(offsetX nil)
(offsetY nil)
(curloc nil)
(curcnt nil)
(totalcent 0)
(centoffx nil)
(centoffy nil)
)
(set! curloc myvalues)
(while (not (null? curloc))
(set! totalcent (+ totalcent (car curloc)))
(set! curloc (cdr curloc))
)
(if (= whichtype 1)
(begin
(set! curCentpos (+ (p_getlayerpos "Centurion") (-- totalcent)))
(set! centoffx 49)
(set! centoffy 20)
)
(begin
(set! curCentpos (+ (p_getlayerpos "OccForce") (-- totalcent)))
(set! centoffx 150)
(set! centoffy -20)
)
) ;if
(set! curloc 0)
(while (not (null? myvalues))
(when (< 0 (car myvalues))
(set! curcnt (car myvalues))
(while (> curcnt 0)
(gimp-layer-set-visible (vector-ref mylayers curCentpos) TRUE)
(set! offsetX (* curloc centoffx))
(set! offsetY (* (-- curcnt) centoffy))
(gimp-layer-translate (vector-ref mylayers curCentpos) offsetX offsetY)
(set! curCentpos (-- curCentpos))
(set! curcnt (-- curcnt))
)
) ;when
(set! curloc (++ curloc))
(set! myvalues (cdr myvalues))
) ;while
) ;let
) ;define
(define (bsgp-EliminatedCharacters myvalues)
(let*
(
(c_elimpos (p_getlayerpos "Eliminated"))
(playerid 0)
)
(while (not (null? myvalues))
(set! playerid (- (car myvalues) 1))
(logit playerid)
(gimp-layer-set-visible (vector-ref mylayers (+ c_elimpos playerid)) TRUE)
(gimp-layer-translate (vector-ref mylayers (+ c_elimpos playerid)) 0 (* cardoffsetY playerid))
(set! myvalues (cdr myvalues))
)
) ; let
) ; define
(define (bsgp-Characters image myvalues)
;bsgp-Characters is for the initial setup.
(let*
(
(c_playerpos (p_getlayerpos "PlayerCard"))
(c_tokenpos (p_getlayerpos "PlayerToken"))
(playerid 0)
(curoffset 0)
(playerpos nil)
(tokenpos nil)
(playername nil)
(playercnt nil)
(cntr nil)
(plyroffset nil)
)
(set! playercount (length myvalues)) ;this is a global that is used by other functions
(set! playercnt (length myvalues))
(while (< playercnt 7)
(gimp-drawable-set-visible (vector-ref mylayers (+ (p_getlayerpos "BlankCard5") (- playercnt 4))) TRUE)
(gimp-drawable-set-visible (vector-ref mylayers (+ (p_getlayerpos "PlayerCardCntr") playercnt)) FALSE)
(gimp-drawable-set-visible (vector-ref mylayers (+ (p_getlayerpos "SkillCard") playercnt)) FALSE)
(set! playercnt (++ playercnt))
)
(while (not (null? myvalues))
; get the name of the current player
; walk the cards until it's found
; put the card in the correct place and make it visible
; find the token for the player and move it into the correct order
(set! playerpos (+ c_playerpos playerid))
(set! tokenpos (+ c_tokenpos playerid))
(set! playername (car myvalues))
(set! plyroffset -1)
(set! cntr 0)
(while (< cntr 38)
(when (string=5? playername (car (gimp-drawable-get-name (vector-ref mylayers (+ playerpos cntr)))))
(set! plyroffset cntr)
(set! cntr 38)
) ;when
(set! cntr (++ cntr))
) ;while
(when (= plyroffset -1) (logit (string-append "ERROR - Could not find character: " playername)))
; so now I know where the card and token are relative to the current
; we need to make card visible and move it to the right place
; the token will be made visible by bsgp-players when it is put in a location
(MoveTokenToPlayer (+ playerpos plyroffset) (++ playerid))
; now we need to reorganize the layers
;the layers need to be moved up playeroffset times, I believe...
(set! cntr plyroffset)
(while (> cntr 0)
(gimp-image-raise-layer image (vector-ref mylayers (+ playerpos plyroffset)))
(gimp-image-raise-layer image (vector-ref mylayers (+ tokenpos plyroffset)))
(set! cntr (-- cntr))
) ;while
;the layers are no longer in the same order as mylayers, so refresh it
(set! mylayers (cadr (gimp-image-get-layers image)))
(set! myvalues (cdr myvalues))
(set! playerid (++ playerid))
) ;while
) ;let
) ;define
(define (bsgp-Roles myvalues)
; roles myvalues is of the form (CurrentPlayerID PresidentID QuorumCnt AdmiralID NukeCnt [CAGID] [MutID])
; note that the id's are all 1-based, to match the source file
(let*
(
(c_tokenpos (p_getlayerpos "Current"))
(c_qcardtxt (p_getlayerpos "QuorumCntr"))
)
; Current Player
(MoveTokenToPlayer c_tokenpos (car myvalues))
(set! myvalues (cdr myvalues)) ; Pop off the Current Player - top is now PresidentID
; President - Seal, Quorum card back, count
(MoveTokenToPlayer (+ c_tokenpos 1) (car myvalues)) ; President Seal
(MoveTokenToPlayer (+ c_tokenpos 2) (car myvalues)) ; Quorum Cards
(MoveTokenToPlayer c_qcardtxt (car myvalues)) ; Quorum Cards counter
; Quorum card count text
(bsgp-Counters (list (cadr myvalues)) c_qcardtxt)
(set! myvalues (cddr myvalues)) ; Pop off the President and Quorum count - top is now AdmiralID
; Admiral - Insignia, nukes
(MoveTokenToPlayer (+ c_tokenpos 3) (car myvalues)) ; Admiral Seal
(when (> (cadr myvalues) 0) (MoveTokenToPlayer (+ c_tokenpos 4) (car myvalues)) ) ; Nuke 1
(when (> (cadr myvalues) 1) (MoveTokenToPlayer (+ c_tokenpos 5) (car myvalues)) ) ; Nuke 2
(when (> (cadr myvalues) 2) (MoveTokenToPlayer (+ c_tokenpos 6) (car myvalues)) ) ; Nuke 3
(set! myvalues (cddr myvalues)) ; Pop off the Admiral and Nukes - top is now CAGID
; CAG insignia
(when (> (car myvalues) 0) (MoveTokenToPlayer (+ c_tokenpos 7) (car myvalues)) )
; Mutineer
(when (> (cadr myvalues) 0) (MoveTokenToPlayer (+ c_tokenpos 8) (cadr myvalues)))
) ;let
) ;define
;
(define (bsgp-TrLoy myvalues tokentype)
; display of trauma token counts and loyalty card counts are identical and are only show by request.
(let*
(
(cntr 0)
(tokenpos nil)
(cntrpos nil)
)
; we need to show the tokens and counters
(if (string=? tokentype "Trauma")
(begin
(set! tokenpos (p_getlayerpos "Trauma"))
(set! cntrpos (p_getlayerpos "TraumaCntr"))
)
(if (string=? tokentype "Mutiny")
(begin
(set! tokenpos (p_getlayerpos "Mutiny"))
(set! cntrpos (p_getlayerpos "MutinyCntr"))
)
(begin
(set! tokenpos (p_getlayerpos "LoyaltyCard"))
(set! cntrpos (p_getlayerpos "LoyaltyCntr"))
)
)
) ; if
(while (< cntr playercount)
(when (or (> (car myvalues) 0) (string=? tokentype "Trauma"))
(gimp-drawable-set-visible (vector-ref mylayers (+ tokenpos cntr)) TRUE)
(when (or (> (car myvalues) 0) (string=? tokentype "Trauma"))
(gimp-drawable-set-visible (vector-ref mylayers (+ cntrpos cntr)) TRUE)
(gimp-text-layer-set-text (vector-ref mylayers (+ cntrpos cntr)) (number->string (car myvalues)) )
(when (= outlineoption TRUE)
(outlineText (vector-ref mylayers (+ cntrpos cntr)) 6 '(0 0 0))
(set! mylayers (cadr (gimp-image-get-layers image)))
)
)
)
(set! myvalues (cdr myvalues))
(set! cntr (++ cntr))
); while
);let
) ;bsgp-TrLoy
(define (bsgp-1PG myvalues)
; flag once-per-game abalities as having been used.
(let*
(
(c_1pgpos (p_getlayerpos "1PG")) ;position in the layer vector of the first 1PG image
(cntr 0)
)
(while (not (null? myvalues))
(case (car myvalues)
((0) (gimp-drawable-set-visible (vector-ref mylayers (+ c_1pgpos cntr)) TRUE))
((2) (MoveTokenToPlayer (+ c_1pgpos 7) (+ cntr 1)))
((3) (MoveTokenToPlayer (+ c_1pgpos 8) (+ cntr 1)))
)
(set! myvalues (cdr myvalues))
(set! cntr (++ cntr))
) ;while
) ;let
) ;define
(define (bsgp-Cylons myvalues)
;Format: "Cylons",<playerid>,<CylonType>,<SuperCrisis Count>,<InfMode> [,<playerid>,<CylonType>,<SuperCrisis Count>,<InfMode> [,...]]
;CylonType Valid Values:
;"C" = Revealed Cylon
;"LS" = Cylon Leader w/Sympathetic Agenda
;"LH" = Cylon Leader w/Hostile Agenda
;"L" = Cylon Leader w/Motives
;"S" = Sympathetic Cylon
;<InfMode>= 1 for Infiltrator, otherwise 0
(let*
(
(c_cylonpos (p_getlayerpos "Cylon"))
(c_supercrisis (p_getlayerpos "SuperCrisis"))
(cylon nil)
(playerid nil)
(cylonoffset nil)
(scused 0)
)
(while (not (null? myvalues))
(case (string->symbol (cadr myvalues))
((C) (set! cylonoffset (p_getused "Cylon")))
((LS) (set! cylonoffset 2))
((LH) (set! cylonoffset 3))
((S) (set! cylonoffset 2))
((L) (set! cylonoffset 4)) ; Motives - Sympathetic for now
)
(MoveTokenToPlayer (+ c_cylonpos cylonoffset) (car myvalues))
(when (string=? "S" (cadr myvalues)) (MoveTokenToPlayer (+ c_cylonpos 5) (car myvalues)) ) ; Sympathetic Cylon banner
(when (= (cadddr myvalues) 1) (MoveTokenToPlayer (+ c_cylonpos 6) (car myvalues)) ) ; Infiltrator
; Super-Crisis Cards
(when (> (caddr myvalues) 0)
; find first available SC and use it...
(set! scused (p_getused "SuperCrisis"))
(gimp-drawable-set-visible (vector-ref mylayers (+ c_supercrisis scused)) TRUE)
(gimp-layer-translate (vector-ref mylayers (+ c_supercrisis scused )) 0 (* cardoffsetY (-- (car myvalues))))
(gimp-text-layer-set-text (vector-ref mylayers (+ c_supercrisis scused)) (number->string (caddr myvalues)))
(gimp-drawable-set-visible (vector-ref mylayers (+ c_supercrisis scused 1)) TRUE)
(gimp-layer-translate (vector-ref mylayers (+ c_supercrisis scused 1)) 0 (* cardoffsetY (-- (car myvalues))))
) ;when
(set! myvalues (cddddr myvalues))
) ;while
) ;let*
) ;define
(define (bsgp-Damage myvalues)
; show galactica damage tokens
(let*
(
; (c_damagetxtpos (p_getlayerpos "DamageCntr"))
; (c_damagedisppos (p_getlayerpos "DamageDispToken"))
(c_damagepos (p_getlayerpos "DamageToken"))
(damoff nil)
; (dmgcnt 0)
)
(while (not (null? myvalues))
(set! damoff 0)
(while (< damoff 10)
(when (string=5? (car (gimp-layer-get-name (vector-ref mylayers (+ c_damagepos damoff)))) (car myvalues))
(gimp-drawable-set-visible (vector-ref mylayers (+ c_damagepos damoff)) TRUE)
(set! damoff 10)
; (set! dmgcnt (++ dmgcnt))
)
(set! damoff (++ damoff))
) ;while
(set! myvalues (cdr myvalues))
) ;while
; (gimp-drawable-set-visible (vector-ref mylayers c_damagetxtpos) TRUE)
; (gimp-drawable-set-visible (vector-ref mylayers c_damagedisppos) TRUE)
; (bsgp-Counters (list dmgcnt) 12)
) ;let*
) ;define
(define (bsgp-Distance myvalues)
(let*
(
(c_jumppos (p_getlayerpos "JumpDistance"))
(jumpcnt 0)
(distance 0)
(disttmp 0)
)
(while (not (null? myvalues))
(case (string->symbol (car myvalues))
((LD)
(gimp-drawable-set-visible (vector-ref mylayers (+ c_jumppos (* 5 jumpcnt))) TRUE)
(gimp-text-layer-set-text (vector-ref mylayers (+ c_jumppos (* 5 jumpcnt))) "LEGENDARY")
(gimp-drawable-set-visible (vector-ref mylayers (+ c_jumppos (* 5 jumpcnt) 2)) TRUE)
(set! distance (++ distance))
) ; Legendary Discovery
((LT)
(gimp-drawable-set-visible (vector-ref mylayers (+ c_jumppos (* 5 jumpcnt))) TRUE)
(gimp-text-layer-set-text (vector-ref mylayers (+ c_jumppos (* 5 jumpcnt))) "ROAD LESS TRAVELED")
(gimp-drawable-set-visible (vector-ref mylayers (+ c_jumppos (* 5 jumpcnt) 2)) TRUE)
(set! distance (++ distance))
) ; The Road Less Traveled
((DP)
(gimp-drawable-set-visible (vector-ref mylayers (+ c_jumppos (* 5 jumpcnt))) TRUE)
(gimp-text-layer-set-text (vector-ref mylayers (+ c_jumppos (* 5 jumpcnt))) "DIGGING UP THE PAST")
(gimp-drawable-set-visible (vector-ref mylayers (+ c_jumppos (* 5 jumpcnt) 2)) TRUE)
(set! distance (++ distance))
) ; The Road Less Traveled
((SH)
(gimp-drawable-set-visible (vector-ref mylayers (+ c_jumppos (* 5 jumpcnt))) TRUE)
(gimp-text-layer-set-text (vector-ref mylayers (+ c_jumppos (* 5 jumpcnt))) "THE SEARCH FOR HOME")
(gimp-drawable-set-visible (vector-ref mylayers (+ c_jumppos (* 5 jumpcnt) 3)) TRUE)
(set! distance (+ 2 distance))
) ; The Road Less Traveled
((FE)
(gimp-drawable-set-visible (vector-ref mylayers (+ c_jumppos (* 5 jumpcnt))) TRUE)
(gimp-text-layer-set-text (vector-ref mylayers (+ c_jumppos (* 5 jumpcnt))) "FRAK EARTH")
(gimp-drawable-set-visible (vector-ref mylayers (+ c_jumppos (* 5 jumpcnt) 2)) TRUE)
(set! distance (-- distance))
) ; Frak Earth
(else
(set! disttmp (car myvalues))
(when (string? disttmp) (set! disttmp (string->number disttmp)))
(gimp-drawable-set-visible (vector-ref mylayers (+ c_jumppos (* 5 jumpcnt) disttmp 1)) TRUE)
(set! distance (+ distance (abs disttmp)))
) ;else
) ;case
(set! jumpcnt (++ jumpcnt))
(set! myvalues (cdr myvalues))
) ;while
(bsgp-Counters (list distance) (p_getlayerpos "Distance"))
) ;let
) ;define
(define (bsgp-BoardSpecial myvalues)
; show special board conditions (Ambush, Jammed, etc...)
(let*
(
(c_specpos (p_getlayerpos "Special"))
(specoff nil)
(hoffset nil)
(voffset nil)
)
(while (not (null? myvalues))
(if (string=5? (car myvalues) "HUB D")
(gimp-drawable-set-visible (vector-ref mylayers (p_getlayerpos "HubDestroyed")) TRUE)
(if (string=5? (car myvalues) "COLON") ;check for colonial one
(gimp-drawable-set-visible (vector-ref mylayers (p_getlayerpos "ColonialOneDestroyed")) TRUE)
(if (string=5? (car myvalues) "PEGAS") ;check for Pegasus
(gimp-drawable-set-visible (vector-ref mylayers (p_getlayerpos "PegasusDestroyed")) TRUE)
(begin
(if (even? specialcnt)
(set! hoffset 0)
(set! hoffset 1)
)
(set! voffset (quotient specialcnt 2))
(set! specoff 0)
(while (< specoff 8)
(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)
)
) ;when
(set! specoff (++ specoff))
) ;while
) ;begin
) ;if
) ;if
) ; if
(set! myvalues (cdr myvalues))
) ;while
) ;let
) ;define
(define (bsgp-SearchForHome myvalues)
(let*
(
(rebel_overlay (car myvalues))
(mission_name (string-append "MISSION: " (cadr myvalues)))
(mission_side (caddr myvalues))
(cntr nil)
)
(begin
; First, set the Rebel Basestar Token (Human/Cylon) or the Filter (before the Cylon Civil War Mission is played)
(cond ((string=? rebel_overlay "Unallied") (gimp-layer-set-visible (vector-ref mylayers (+ (p_getlayerpos "Filter") 5)) 1))
((string=? rebel_overlay "Human") (gimp-layer-set-visible (vector-ref mylayers (p_getlayerpos "RebelBasestarToken")) 1))
((string=? rebel_overlay "Cylon") (gimp-layer-set-visible (vector-ref mylayers (+ (p_getlayerpos "RebelBasestarToken") 1)) 1))
) ; cond
; Now, we acivate and place the current mission layer based on the ever-mobile Demetrius board
(set! cntr 0)
(while (< cntr 9)
(when (string=? mission_name (car (gimp-drawable-get-name (vector-ref mylayers (+ (p_getlayerpos "CurrentMission") cntr)))))
(gimp-layer-set-visible (vector-ref mylayers (+ (p_getlayerpos "CurrentMission") cntr)) 1) ; Activate the current mission layer
(gimp-layer-set-offsets (vector-ref mylayers (+ (p_getlayerpos "CurrentMission") cntr)) ; Reposition the current mission layer based on Demetrius
(+ (car (gimp-drawable-offsets (vector-ref mylayers (p_getlayerpos "Demetrius")))) 610)
(+ (cadr (gimp-drawable-offsets (vector-ref mylayers (p_getlayerpos "Demetrius")))) 45)
)
(set! cntr 9)
) ;when
(set! cntr (++ cntr))
) ;while
; Last, IF the card needs this info, place the "face up" or "face down" layer, but only for Search for Home and Digging up the Past missions
(cond
((and (string-ci=? mission_side "Passed") (or (string-ci=? mission_name "MISSION: The Search for Home") (string-ci=? mission_name "MISSION: Digging Up the Past"))) (begin
(gimp-layer-set-visible (vector-ref mylayers (p_getlayerpos "CurrentMissionStatus")) 1)
(gimp-layer-set-offsets (vector-ref mylayers (p_getlayerpos "CurrentMissionStatus"))
(+ (car (gimp-drawable-offsets (vector-ref mylayers (p_getlayerpos "Demetrius")))) 610)
(+ (cadr (gimp-drawable-offsets (vector-ref mylayers (p_getlayerpos "Demetrius")))) 185)
)
))
((and (string-ci=? mission_side "Failed") (or (string-ci=? mission_name "MISSION: The Search for Home") (string-ci=? mission_name "MISSION: Digging Up the Past"))) (begin
(gimp-layer-set-visible (vector-ref mylayers (+ (p_getlayerpos "CurrentMissionStatus") 1)) 1)
(gimp-layer-set-offsets (vector-ref mylayers (+ (p_getlayerpos "CurrentMissionStatus") 1))
(+ (car (gimp-drawable-offsets (vector-ref mylayers (p_getlayerpos "Demetrius")))) 610)
(+ (cadr (gimp-drawable-offsets (vector-ref mylayers (p_getlayerpos "Demetrius")))) 185)
)
))
) ; cond
)
) ; let
) ;define
; (gimp-drawable-set-visible (vector-ref mylayers (+ (p_getlayerpos "CurrentMission") (car myvalues))) 1)
(define (bsgp-Assignments myvalues)
; show player assignements
(let*
(
(c_asgnpos (p_getlayerpos "Assign"))
(asgnoff nil)
(asgnname nil)
(asgnid nil)
)
(while (not (null? myvalues))
(set! asgnname (car myvalues))
(set! asgnid (-- (cadr myvalues)))
(set! asgnoff 0)
(while (< asgnoff 6)
(when (string=5? (car (gimp-layer-get-name (vector-ref mylayers (+ c_asgnpos asgnoff)))) asgnname)
(gimp-drawable-set-visible (vector-ref mylayers (+ c_asgnpos asgnoff)) TRUE)
(gimp-layer-translate (vector-ref mylayers (+ c_asgnpos asgnoff)) 0 (- (* asgnid cardoffsetY) (* (vector-ref asgncnt asgnid) 32)))
(vector-set! asgncnt asgnid (++ (vector-ref asgncnt asgnid)))
(set! asgnoff 6)
) ;when
(set! asgnoff (++ asgnoff))
) ;while
(set! myvalues (cddr myvalues))
) ;while
) ;let
) ;bsgp-Assignements
;
(define (bsgp-Players myvalues useDB)
; Players is of the form (Players (<locname> <locname> <locname> <locname> <locname> [...]))
; where <locname> is the string name of the location of that player...
(let*
(
(c_playerpos (p_getlayerpos "PlayerToken"))
(lockey (vector '("Press Room" 185 210) '("President's Office" 340 210) '("Administration" 495 200)
'("Caprica" 810 220) '("Cylon Fleet" 920 220) '("Human Fleet" 1030 220) '("Resurrection Ship" 1140 220)
'("Basestar Bridge" 345 220)
'("Weapons Control" 475 765) '("Communications" 645 765) '("Research Lab" 815 765) '("Sickbay" 1155 765)
'("FTL Control" 305 860) '("Armory" 985 860)
'("Command" 475 960) '("Admiral's Quarters" 645 960) '("Hangar Deck" 815 960) '("Brig" 1155 960)
'("Pegasus CIC" 40 145) '("Airlock" 240 170) '("Main Batteries" 445 170) '("Engine Room" 655 145)
'("Medical Center" 1630 585) '("Resistance HQ" 1785 585)
'("Detention" 1625 780) '("Occupation Authority" 1790 785) '("Breeder's Canyon" 1935 785) '("Shipyard" 2080 785)
'("Quorum Chamber" 95 210) '("Hub Destroyed" 1140 220)
'("Bridge" 55 110) '("Tactical Plot" 245 110) '("Captain's Cabin" 425 110)
'("Hybrid Tank" 95 110) '("Datastream" 345 140) '("Raider Bay" 590 110)
'("Stranded on Caprica") '("Eliminated")
'("Sector 1") '("Sector 2") '("Sector 3") '("Sector 4") '("Sector 5") '("Sector 6") )
)
; '("Engine Room" 2cardoffsetY 1230)
(loccnt (make-vector (vector-length lockey) 0))
(plyrloc '())
(plyrpos c_playerpos)
(locoff nil)
(plyrfnd nil)
(locid nil)
(cnt nil)
(offset nil)
(diff nil)
(offlst nil)
(c_pwidth 100)
(pilotname nil)
(pilotpos nil)
(vipertype '())
(c_pilotpos nil)
(coloff 0)
(c_colonialoneend 2) ; The original C1 locations shift to the right with Daybreak.
(c_basestarbridge 7) ; Basestar bridge moves if there are too many boards in play.
(c_pegasusstart 18) ; Pegasus now also moves!
(c_demetriusstart 30) ; Demetrius moves all the time
(c_rbbstart 33) ; Rebel Basestar moves all the time too
(c_stranded 36)
(c_eliminated 37)
(c_sectorstart 38) ; 38 not-Space Locations
(pilotloc #( ((155 1090) (155 800) (250 750)) ((655 515) (655 595) (655 675))
((965 515) (965 595) (965 675)) ( (1230 730) (1315 960) (1250 1150))
((965 1280) (965 1360) (965 1440)) ((655 1280) (655 1360) (655 1440) )))
(sector nil)
(myloc nil)
(boardoffsetX nil)
(boardoffsetY nil)
)
(while (not (null? myvalues))
(set! locoff 0) ; iteration counter/location ID
(set! plyrfnd -1)
(while (< locoff (vector-length lockey))
(when (string=5? (car myvalues) (car (vector-ref lockey locoff))) ; 5-Char match
(set! plyrfnd locoff) ; Location match ID
(logit (car myvalues))
(logit plyrfnd)
(when (>= plyrfnd c_sectorstart) ; pilot in space
(if (string=? (car myvalues) (car (vector-ref lockey locoff)))
(set! vipertype (append vipertype (list 0))) ;exact match means we're in a standard viper
(if (string=? (car myvalues) (string-append (car (vector-ref lockey locoff)) "*"))
(set! vipertype (append vipertype (list 1))) ; Viper MkVIIs append a *
(set! vipertype (append vipertype (list 2))) ; Assault Raptors append a !
)
)
; (when (not (list? vipertype)) (set! vipertype (list vipertype)))
) ; Pilot
(set! locoff (vector-length lockey)) ; Quick way to exit the while
);when
(set! locoff (++ locoff))
) ;while
(vector-set! loccnt plyrfnd (++ (vector-ref loccnt plyrfnd))) ; loccnt is a vector for counting the number of players in each Location. This increments that count for the current player.
(set! plyrloc (append plyrloc (list plyrfnd))) ; plyrloc is a vector of each player's locIDs
(set! myvalues (cdr myvalues))
) ;while
; set up the offsets based on the number of tokens in a given location
(set! locid 0)
(while (< locid c_sectorstart) ;ignore the sectors
(set! cnt (vector-ref loccnt locid)) ; Fetch the number of number of players in locid
(when (> cnt 0)
(if (= cnt 1)
(set! offlst '(0))
(begin
(set! offset (* (* (/ (-- cnt) cnt) c_pwidth) -1))
(set! diff (* (/ 2 cnt) c_pwidth))
(set! offlst '())
(while (> cnt 0)
(set! offlst (append offlst (list offset)))
(set! offset (+ offset diff))