-
Notifications
You must be signed in to change notification settings - Fork 4
/
rftg.h
1171 lines (918 loc) · 28.9 KB
/
rftg.h
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
/*
* Race for the Galaxy AI
*
* Copyright (C) 2009 Keldon Jones
*
* Source file modified by B. Nordli, August 2014.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* Standard headers.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef VERSION
#define VERSION "0.9.4"
#endif
#ifndef RELEASE
#define RELEASE VERSION
#endif
#include <stdio.h>
#include <stdlib.h>
#ifdef WIN32
#include "stdint.h"
#else
#include <stdint.h>
#endif
#include <ctype.h>
#include <string.h>
#include <time.h>
/*
* Default data directory if not otherwise specified.
*/
#ifndef RFTGDIR
# define RFTGDIR "."
#endif
/*
* Maximum number of players.
*/
#define MAX_PLAYER 6
/*
* Maximum number of expansion levels.
*/
#define MAX_EXPANSION 5
/*
* Number of available card designs slots.
*/
#define AVAILABLE_DESIGN 256
/*
* Number of original card designs.
*/
#define MAX_DESIGN 236
/*
* Number of cards in the deck.
*/
#define MAX_DECK 328
/*
* Number of powers per card.
*/
#define MAX_POWER 5
/*
* Number of special VP bonuses per card.
*/
#define MAX_VP_BONUS 6
/*
* Maximum number of pending takeovers.
*/
#define MAX_TAKEOVER 12
/*
* Number of goods.
*/
#define MAX_GOOD 6
/*
* Number of intermediate goals.
*/
#define MAX_GOAL 20
/*
* Number of turn phases.
*/
#define MAX_PHASE 7
/*
* Number of available actions.
*/
#define MAX_ACTION 10
/*
* Number of Search categories.
*/
#define MAX_SEARCH 9
/*
* Number of card locations.
*/
#define MAX_WHERE 8
/*
* Round phases.
*/
#define PHASE_ACTION 0
#define PHASE_EXPLORE 1
#define PHASE_DEVELOP 2
#define PHASE_SETTLE 3
#define PHASE_CONSUME 4
#define PHASE_PRODUCE 5
#define PHASE_DISCARD 6
/*
* Player action choices.
*/
#define ACT_ROUND_START -1
#define ACT_SEARCH 0
#define ACT_EXPLORE_5_0 1
#define ACT_EXPLORE_1_1 2
#define ACT_DEVELOP 3
#define ACT_DEVELOP2 4
#define ACT_SETTLE 5
#define ACT_SETTLE2 6
#define ACT_CONSUME_TRADE 7
#define ACT_CONSUME_X2 8
#define ACT_PRODUCE 9
#define ACT_ROUND_END 10
#define ACT_MASK 0x7f
#define ACT_PRESTIGE 0x80
/*
* Card types.
*/
#define TYPE_WORLD 1
#define TYPE_DEVELOPMENT 2
/*
* Card flags.
*/
#define FLAG_MILITARY 0x1
#define FLAG_WINDFALL 0x2
#define FLAG_START 0x4
#define FLAG_START_RED 0x8
#define FLAG_START_BLUE 0x10
#define FLAG_PROMO 0x20
#define FLAG_REBEL 0x40
#define FLAG_UPLIFT 0x80
#define FLAG_ALIEN 0x100
#define FLAG_TERRAFORMING 0x200
#define FLAG_IMPERIUM 0x400
#define FLAG_CHROMO 0x800
#define FLAG_PRESTIGE 0x1000
#define FLAG_STARTHAND_3 0x2000
#define FLAG_START_SAVE 0x4000
#define FLAG_DISCARD_TO_12 0x8000
#define FLAG_GAME_END_14 0x10000
#define FLAG_TAKE_DISCARDS 0x20000
#define FLAG_SELECT_LAST 0x40000
#define FLAG_EXTRA_SURVEY 0x80000
#define FLAG_NO_PRODUCE 0x100000
#define FLAG_DISCARD_PRODUCE 0x200000
/*
* Good types (and cost).
*/
#define GOOD_ANY 1
#define GOOD_NOVELTY 2
#define GOOD_RARE 3
#define GOOD_GENE 4
#define GOOD_ALIEN 5
/*
* Card locations.
*/
#define WHERE_DECK 0
#define WHERE_DISCARD 1
#define WHERE_HAND 2
#define WHERE_ACTIVE 3
#define WHERE_GOOD 4
#define WHERE_SAVED 5
#define WHERE_ASIDE 6
#define WHERE_CAMPAIGN 7
/*
* Misc card flags.
*/
#define MISC_KNOWN_0 (1 << 0)
#define MISC_KNOWN_1 (1 << 1)
#define MISC_KNOWN_2 (1 << 2)
#define MISC_KNOWN_3 (1 << 3)
#define MISC_KNOWN_4 (1 << 4)
#define MISC_KNOWN_5 (1 << 5)
#define MISC_KNOWN_MASK 0x3f
#define MISC_UNPAID (1 << 6)
#define MISC_FAKE (1 << 7)
#define MISC_USED_0 (1 << 8)
#define MISC_USED_1 (1 << 9)
#define MISC_USED_2 (1 << 10)
#define MISC_USED_3 (1 << 11)
#define MISC_USED_4 (1 << 12)
#define MISC_USED_MASK (0x1f << 8)
#define MISC_USED_SHIFT 8
#define MISC_PRODUCED_MASK (0x7 << 13)
#define MISC_PRODUCED_SHIFT 13
#define MISC_TEMP_MASK (MISC_KNOWN_MASK | MISC_FAKE)
/*
* Search categories.
*/
#define SEARCH_DEV_MILITARY 0
#define SEARCH_MILITARY_WINDFALL 1
#define SEARCH_PEACEFUL_WINDFALL 2
#define SEARCH_CHROMO_WORLD 3
#define SEARCH_ALIEN_WORLD 4
#define SEARCH_CONSUME_TWO 5
#define SEARCH_MILITARY_5 6
#define SEARCH_6_DEV 7
#define SEARCH_TAKEOVER 8
/*
* Campaign flags.
*/
#define CAMP_DRAW_EXTRA 0x1
/*
* Card power effects by phase.
*/
/* Phase one -- Explore */
#define P1_DRAW (1ULL << 0)
#define P1_KEEP (1ULL << 1)
#define P1_DISCARD_ANY (1ULL << 2)
#define P1_DISCARD_PRESTIGE (1ULL << 3)
#define P1_ORB_MOVEMENT (1ULL << 4)
/* Phase two -- Develop */
#define P2_DRAW (1ULL << 0)
#define P2_REDUCE (1ULL << 1)
#define P2_DRAW_AFTER (1ULL << 2)
#define P2_EXPLORE (1ULL << 3)
#define P2_DISCARD_REDUCE (1ULL << 4)
#define P2_SAVE_COST (1ULL << 5)
#define P2_PRESTIGE (1ULL << 6)
#define P2_PRESTIGE_REBEL (1ULL << 7)
#define P2_PRESTIGE_SIX (1ULL << 8)
#define P2_CONSUME_RARE (1ULL << 9)
/* Phase three -- Settle */
#define P3_REDUCE (1ULL << 0)
#define P3_NOVELTY (1ULL << 1)
#define P3_RARE (1ULL << 2)
#define P3_GENE (1ULL << 3)
#define P3_ALIEN (1ULL << 4)
#define P3_DISCARD (1ULL << 5)
#define P3_REDUCE_ZERO (1ULL << 6)
#define P3_MILITARY_HAND (1ULL << 7)
#define P3_EXTRA_MILITARY (1ULL << 8)
#define P3_AGAINST_REBEL (1ULL << 9)
#define P3_AGAINST_CHROMO (1ULL << 10)
#define P3_PER_MILITARY (1ULL << 11)
#define P3_PER_CHROMO (1ULL << 12)
#define P3_IF_IMPERIUM (1ULL << 13)
#define P3_PAY_MILITARY (1ULL << 14)
#define P3_PAY_DISCOUNT (1ULL << 15)
#define P3_PAY_PRESTIGE (1ULL << 16)
#define P3_CONQUER_SETTLE (1ULL << 17)
#define P3_NO_TAKEOVER (1ULL << 18)
#define P3_DRAW_AFTER (1ULL << 19)
#define P3_EXPLORE_AFTER (1ULL << 20)
#define P3_PRESTIGE (1ULL << 21)
#define P3_PRESTIGE_REBEL (1ULL << 22)
#define P3_SAVE_COST (1ULL << 23)
#define P3_PLACE_TWO (1ULL << 24)
#define P3_PLACE_MILITARY (1ULL << 25)
#define P3_PLACE_LEFTOVER (1ULL << 26)
#define P3_PLACE_ZERO (1ULL << 27)
#define P3_CONSUME_RARE (1ULL << 28)
#define P3_CONSUME_GENE (1ULL << 29)
#define P3_CONSUME_ALIEN (1ULL << 30)
#define P3_CONSUME_PRESTIGE (1ULL << 31)
#define P3_AUTO_PRODUCE (1ULL << 32)
#define P3_PRODUCE_PRESTIGE (1ULL << 33)
#define P3_TAKEOVER_REBEL (1ULL << 34)
#define P3_TAKEOVER_IMPERIUM (1ULL << 35)
#define P3_TAKEOVER_MILITARY (1ULL << 36)
#define P3_TAKEOVER_PRESTIGE (1ULL << 37)
#define P3_DESTROY (1ULL << 38)
#define P3_TAKEOVER_DEFENSE (1ULL << 39)
#define P3_PREVENT_TAKEOVER (1ULL << 40)
#define P3_UPGRADE_WORLD (1ULL << 41)
#define P3_FLIP_ZERO (1ULL << 42)
/* Mask of takeover powers */
#define P3_TAKEOVER_MASK (P3_TAKEOVER_REBEL | P3_TAKEOVER_IMPERIUM | \
P3_TAKEOVER_MILITARY | P3_PRESTIGE_TAKEOVER)
/* Phase four -- Consume */
#define P4_TRADE_ANY (1ULL << 0)
#define P4_TRADE_NOVELTY (1ULL << 1)
#define P4_TRADE_RARE (1ULL << 2)
#define P4_TRADE_GENE (1ULL << 3)
#define P4_TRADE_ALIEN (1ULL << 4)
#define P4_TRADE_THIS (1ULL << 5)
#define P4_TRADE_BONUS_CHROMO (1ULL << 6)
#define P4_NO_TRADE (1ULL << 7)
#define P4_TRADE_ACTION (1ULL << 8)
#define P4_TRADE_NO_BONUS (1ULL << 9)
#define P4_CONSUME_ANY (1ULL << 10)
#define P4_CONSUME_NOVELTY (1ULL << 11)
#define P4_CONSUME_RARE (1ULL << 12)
#define P4_CONSUME_GENE (1ULL << 13)
#define P4_CONSUME_ALIEN (1ULL << 14)
#define P4_CONSUME_THIS (1ULL << 15)
#define P4_CONSUME_TWO (1ULL << 16)
#define P4_CONSUME_3_DIFF (1ULL << 17)
#define P4_CONSUME_N_DIFF (1ULL << 18)
#define P4_CONSUME_ALL (1ULL << 19)
#define P4_CONSUME_PRESTIGE (1ULL << 20)
#define P4_GET_CARD (1ULL << 21)
#define P4_GET_2_CARD (1ULL << 22)
#define P4_GET_3_CARD (1ULL << 23)
#define P4_GET_VP (1ULL << 24)
#define P4_GET_PRESTIGE (1ULL << 25)
#define P4_DRAW (1ULL << 26)
#define P4_DRAW_LUCKY (1ULL << 27)
#define P4_DISCARD_HAND (1ULL << 28)
#define P4_ANTE_CARD (1ULL << 29)
#define P4_VP (1ULL << 30)
/* Mask of trade powers */
#define P4_TRADE_MASK (P4_TRADE_ANY | P4_TRADE_NOVELTY | P4_TRADE_RARE | \
P4_TRADE_GENE | P4_TRADE_ALIEN | P4_TRADE_THIS | \
P4_TRADE_BONUS_CHROMO | P4_NO_TRADE)
/* Phase five -- Produce */
#define P5_PRODUCE (1ULL << 0)
#define P5_WINDFALL_ANY (1ULL << 1)
#define P5_WINDFALL_NOVELTY (1ULL << 2)
#define P5_WINDFALL_RARE (1ULL << 3)
#define P5_WINDFALL_GENE (1ULL << 4)
#define P5_WINDFALL_ALIEN (1ULL << 5)
#define P5_NOT_THIS (1ULL << 6)
#define P5_DISCARD (1ULL << 7)
#define P5_DRAW (1ULL << 8)
#define P5_DRAW_IF (1ULL << 9)
#define P5_PRESTIGE_IF (1ULL << 10)
#define P5_DRAW_EACH_NOVELTY (1ULL << 11)
#define P5_DRAW_EACH_RARE (1ULL << 12)
#define P5_DRAW_EACH_GENE (1ULL << 13)
#define P5_DRAW_EACH_ALIEN (1ULL << 14)
#define P5_DRAW_WORLD_GENE (1ULL << 15)
#define P5_DRAW_MOST_PRODUCED (1ULL << 16)
#define P5_DRAW_DIFFERENT (1ULL << 17)
#define P5_DRAW_MOST_NOVELTY (1ULL << 18)
#define P5_DRAW_MOST_RARE (1ULL << 19)
#define P5_DRAW_MOST_GENE (1ULL << 20)
#define P5_PRESTIGE_MOST_CHROMO (1ULL << 21)
#define P5_DRAW_MILITARY (1ULL << 22)
#define P5_DRAW_REBEL (1ULL << 23)
#define P5_DRAW_REBEL_MILITARY (1ULL << 24)
#define P5_DRAW_IMPERIUM (1ULL << 25)
#define P5_DRAW_CHROMO (1ULL << 26)
#define P5_DRAW_5_DEV (1ULL << 27)
#define P5_TAKE_SAVED (1ULL << 28)
#define P5_SHIFT_RARE (1ULL << 29)
/*
* Special victory point flags.
*/
#define VP_NOVELTY_PRODUCTION 0
#define VP_RARE_PRODUCTION 1
#define VP_GENE_PRODUCTION 2
#define VP_ALIEN_PRODUCTION 3
#define VP_NOVELTY_WINDFALL 4
#define VP_RARE_WINDFALL 5
#define VP_GENE_WINDFALL 6
#define VP_ALIEN_WINDFALL 7
#define VP_DEVEL_EXPLORE 8
#define VP_WORLD_EXPLORE 9
#define VP_DEVEL_TRADE 10
#define VP_WORLD_TRADE 11
#define VP_DEVEL_CONSUME 12
#define VP_WORLD_CONSUME 13
#define VP_SIX_DEVEL 14
#define VP_DEVEL 15
#define VP_WORLD 16
#define VP_NONMILITARY_WORLD 17
#define VP_NONMILITARY_TRADE 18
#define VP_REBEL_FLAG 19
#define VP_ALIEN_FLAG 20
#define VP_TERRAFORMING_FLAG 21
#define VP_UPLIFT_FLAG 22
#define VP_IMPERIUM_FLAG 23
#define VP_CHROMO_FLAG 24
#define VP_MILITARY 25
#define VP_TOTAL_MILITARY 26
#define VP_NEGATIVE_MILITARY 27
#define VP_REBEL_MILITARY 28
#define VP_THREE_VP 29
#define VP_KIND_GOOD 30
#define VP_PRESTIGE 31
#define VP_ALIEN_HISTORY 32
#define VP_ALIEN_SCIENCE 33
#define VP_ALIEN_UPLIFT 34
#define VP_NAME 35
/*
* The intermediate goal tiles.
*/
#define GOAL_FIRST_5_VP 0
#define GOAL_FIRST_4_TYPES 1
#define GOAL_FIRST_3_ALIEN 2
#define GOAL_FIRST_DISCARD 3
#define GOAL_FIRST_PHASE_POWER 4
#define GOAL_FIRST_SIX_DEVEL 5
#define GOAL_FIRST_3_UPLIFT 6
#define GOAL_FIRST_4_GOODS 7
#define GOAL_FIRST_8_ACTIVE 8
#define GOAL_FIRST_NEG_MILITARY 9
#define GOAL_FIRST_2_PRESTIGE 10
#define GOAL_FIRST_4_MILITARY 11
#define GOAL_MOST_MILITARY 12
#define GOAL_MOST_BLUE_BROWN 13
#define GOAL_MOST_DEVEL 14
#define GOAL_MOST_PRODUCTION 15
#define GOAL_MOST_EXPLORE 16
#define GOAL_MOST_REBEL 17
#define GOAL_MOST_PRESTIGE 18
#define GOAL_MOST_CONSUME 19
/*
* Choice types we can send to players.
*/
#define CHOICE_ACTION 0
#define CHOICE_START 1
#define CHOICE_DISCARD 2
#define CHOICE_SAVE 3
#define CHOICE_DISCARD_PRESTIGE 4
#define CHOICE_PLACE 5
#define CHOICE_PAYMENT 6
#define CHOICE_SETTLE 7
#define CHOICE_TAKEOVER 8
#define CHOICE_DEFEND 9
#define CHOICE_TAKEOVER_PREVENT 10
#define CHOICE_UPGRADE 11
#define CHOICE_TRADE 12
#define CHOICE_CONSUME 13
#define CHOICE_CONSUME_HAND 14
#define CHOICE_GOOD 15
#define CHOICE_LUCKY 16
#define CHOICE_ANTE 17
#define CHOICE_KEEP 18
#define CHOICE_WINDFALL 19
#define CHOICE_PRODUCE 20
#define CHOICE_DISCARD_PRODUCE 21
#define CHOICE_SEARCH_TYPE 22
#define CHOICE_SEARCH_KEEP 23
#define CHOICE_OORT_KIND 24
#define CHOICE_DEBUG -10
/*
* GUI: Text formatting
*/
#define FORMAT_EM "em"
#define FORMAT_CHAT "chat"
#define FORMAT_PHASE "phase"
#define FORMAT_TAKEOVER "takeover"
#define FORMAT_GOAL "goal"
#define FORMAT_PRESTIGE "prestige"
#define FORMAT_VERBOSE "verbose"
#define FORMAT_DRAW "draw"
#define FORMAT_DISCARD "discard"
#define FORMAT_DEBUG "debug"
/*
* Forward declaration.
*/
struct game;
/*
* A card's special power.
*
* A card may have many of these.
*/
typedef struct power
{
/* Phase power is used in */
int8_t phase;
/* Power's effect code */
uint64_t code;
/* Power's value */
int8_t value;
/* Number of times power may be used */
int8_t times;
} power;
/*
* Location of a power.
*/
typedef struct power_where
{
/* Card index */
int16_t c_idx;
/* Power index */
int8_t o_idx;
/* Pointer to power */
power *o_ptr;
} power_where;
/*
* A card's special VP bonus.
*/
typedef struct vp_bonus
{
/* Points */
int8_t point;
/* Type */
uint64_t type;
/* String for "name" type */
char *name;
} vp_bonus;
/*
* Information about a card design.
*/
typedef struct design
{
/* Name */
char *name;
/* Design index */
int16_t index;
/* Type (development or world) */
int8_t type;
/* Cost to play */
int8_t cost;
/* Victory points given */
int8_t vp;
/* Number of cards in each expansion deck */
int8_t expand[MAX_EXPANSION];
/* Type of good produced (if any) */
int8_t good_type;
/* Flags (military, windfall, alien, rebel, start world, etc) */
uint32_t flags;
/* Number of this design in the deck */
int8_t dup;
/* Number of card powers */
int8_t num_power;
/* List of powers */
power powers[MAX_POWER];
/* Number of vp bonuses */
int8_t num_vp_bonus;
/* List of VP bonuses */
vp_bonus bonuses[MAX_VP_BONUS];
} design;
/*
* Information about an instance of a card.
*/
typedef struct card
{
/* Card's owner (if any) */
int8_t owner;
/* Card's location */
int8_t where;
/* Card's owner at start of phase */
int8_t start_owner;
/* Card's location at start of phase */
int8_t start_where;
/* Miscellaneous card flags */
uint16_t misc;
/* Card design */
design *d_ptr;
/* Card we are covering (if a good) */
int16_t covering;
/* Number of goods placed on this card */
int8_t num_goods;
/* Order played on the table */
int8_t order;
/* Next card index if belonging to player */
int16_t next;
/* Next card index as of start of phase */
int16_t start_next;
} card;
/*
* Collection of function pointers for a player's decisions.
*/
typedef struct decisions
{
/* Initialize */
void (*init)(struct game *g, int who, double factor);
/* Player spots have been rotated */
void (*notify_rotation)(struct game *g, int who);
/* Prepare for a phase */
void (*prepare_phase)(struct game *g, int who, int phase, int arg);
/* Make a choice among those given */
void (*make_choice)(struct game *g, int who, int type, int list[],
int *nl, int special[], int *ns, int arg1,
int arg2, int arg3);
/* Wait for answer to be ready */
void (*wait_answer)(struct game *g, int who);
/* Take sample cards into hand from Explore phase */
void (*explore_sample)(struct game *g, int who, int draw, int keep,
int discard_any);
/* Game over */
void (*game_over)(struct game *g, int who);
/* Shutdown */
void (*shutdown)(struct game *g, int who);
/* Private message */
void (*private_message)(struct game *g, int who, char *msg, char *tag);
} decisions;
/*
* Information about a player.
*/
typedef struct player
{
/* Player's name/color */
char *name;
/* Whether the player is played by the AI */
int8_t ai;
/* Ask player to make decisions */
decisions *control;
/* Action(s) chosen */
int action[2];
/* Previous turn action(s) */
int prev_action[2];
/* Player has used prestige/search action */
int8_t prestige_action_used;
/* Player has used phase bonus */
int8_t phase_bonus_used;
/* Player's start world */
int16_t start;
/* Player's first card of each location */
int16_t head[MAX_WHERE];
/* Player's first card of each location as of the start of the phase */
int16_t start_head[MAX_WHERE];
/* Card chosen in Develop or Settle phase */
int16_t placing;
/* Bonus military accrued so far this phase */
int8_t bonus_military;
/* Bonus settle discount accrued so far this phase */
int8_t bonus_reduce;
/* Partial hand military spent this phase */
int8_t hand_military_spent;
/* Military spent so far this phase */
int8_t military_spent;
/* Number of cards discarded at end of turn */
int8_t end_discard;
/* Goal cards claimed */
int8_t goal_claimed[MAX_GOAL];
/* Progress toward each goal */
int8_t goal_progress[MAX_GOAL];
/* Prestige */
int8_t prestige;
/* Prestige earned this turn */
int8_t prestige_turn;
/* Victory point chips */
int16_t vp;
/* Victory points from goals */
int16_t goal_vp;
/* Total victory points (if game ended now) */
int16_t end_vp;
/* Player is the winner */
int8_t winner;
/* Number of "fake" drawn cards in simulated games */
int16_t fake_hand;
/* Number of cards discarded this turn but not removed from hand */
int16_t fake_discards;
/* Number of cards drawn this round (or last round) */
int8_t drawn_round;
/* Player skipped last Develop phase and hasn't drawn new cards */
int8_t skip_develop;
/* Player skipped last Settle phase and hasn't drawn new cards */
int8_t skip_settle;
/* Lowest hand size of turn */
int8_t low_hand;
/* Counter for cards played */
int8_t table_order;
/* Cards, VP, and prestige earned during the current phase */
int16_t phase_cards;
int16_t phase_vp;
int16_t phase_prestige;
/* Log of player's choices */
int *choice_log;
/* Size and current position of choice log */
int choice_size;
int choice_pos;
/* History of log sizes */
int *choice_history;
/* Last write position for log */
int choice_unread_pos;
} player;
/*
* Information about a game.
*/
typedef struct game
{
/* Campaign in use (if any) */
struct campaign *camp;
/* Status of campaign (if any) */
struct campaign_status *camp_status;
/* Session ID in online server */
int session_id;
/* Current random seed */
unsigned int random_seed;
/* Random seed at start of game */
unsigned int start_seed;
/* Game is a simulation */
int8_t simulation;
/* Who initiated the simulation */
int8_t sim_who;
/* Name of human player */
char *human_name;
/* Players */
player p[MAX_PLAYER];
/* Number of players */
int8_t num_players;
/* This is an "advanced" 2 player game */
int8_t advanced;
/* Number of expansions in use */
int8_t expanded;
/* Disable goals in expanded games */
int8_t goal_disabled;
/* Disable takeovers in second (or later) expansion */
int8_t takeover_disabled;
/* Include promo start worlds in deck */
int8_t promo;
/* Size of deck in use */
int16_t deck_size;
/* Information about each card */
card deck[MAX_DECK];
/* Victory points remaining in the pool */
int8_t vp_pool;
/* Goals active in this game */
short goal_active[MAX_GOAL];
/* Goals yet unclaimed */
short goal_avail[MAX_GOAL];
/* Maximum progress toward a "most" goal */
int8_t goal_most[MAX_GOAL];
/* Number of pending takeovers */
int8_t num_takeover;
/* Worlds targeted for takeover */
int16_t takeover_target[MAX_TAKEOVER];
/* Player attempting each takeover */
int8_t takeover_who[MAX_TAKEOVER];
/* Card holding takeover power */
int16_t takeover_power[MAX_TAKEOVER];
/* Takeover marked for failure */
int8_t takeover_defeated[MAX_TAKEOVER];
/* XXX Current kind of "any" good world */
int8_t oort_kind;
/* Current kind of "any" good giving owner the best score */
int8_t best_oort_kind;
/* Actions selected this round */
int8_t action_selected[MAX_ACTION];
/* Current action */
int8_t cur_action;
/* Current player in phase */
int8_t turn;
/* Current round number */
int8_t round;
/* Game is over */
int8_t game_over;
} game;
/*
* Campaign card order.
*/
typedef struct campaign
{
/* Expansion level needed */
int expanded;
/* Number of players */
int num_players;
/* Game options */
int advanced;
int goal_disabled;
int takeover_disabled;
/* Campaign name */
char *name;
/* Campaign description */
char *desc;
/* Set-aside card order */
design *order[MAX_PLAYER][MAX_DECK];
/* Number of set-aside cards */