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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
|
"use strict"
var game, view, states = {}
const SUF = "Suffragist"
const OPP = "Opposition"
const region_count = 6
const us_states_count = region_count * 8
const era_cards_count = 17
const first_support_card = 1
const last_support_card = 52
const first_opposition_card = 53
const last_opposition_card = 104
const first_strategy_card = 105
const last_strategy_card = 116
const first_states_card = 117
const last_states_card = 128
const MAX_SUPPORT_BUTTONS = 12
const MAX_OPPOSITION_BUTTONS = 6
const GREEN_CHECK_VICTORY = 36
const RED_X_VICTORY = 13
const WEST = 1
const PLAINS = 2
const SOUTH = 3
const MIDWEST = 4
const ATLANTIC_APPALACHIA = 5
const NORTHEAST = 6
const PURPLE = 1
const YELLOW = 2
const PURPLE_OR_YELLOW = 3
const RED = 4
const GREEN_CHECK = 5
const RED_X = 6
const REST_OF_TURN = 1
const REST_OF_GAME = 2
const BALLOT_BOX = 3
const D4 = 4
const D6 = 6
const D8 = 8
const COLOR_CODE = {
[PURPLE]: "P",
[YELLOW]: "Y",
[PURPLE_OR_YELLOW]: "PY",
[RED]: "R",
[GREEN_CHECK]: "GV",
[RED_X]: "RX",
}
const COLOR_NAMES = {
[PURPLE]: "Purple",
[YELLOW]: "Yellow",
[PURPLE_OR_YELLOW]: "Purple or Yellow",
[RED]: "Red",
[GREEN_CHECK]: "Green Check",
[RED_X]: "Red X",
}
const { CARDS } = require("./cards.js")
const { US_STATES } = require("./data.js")
function opponent_name() {
if (game.active === SUF) {
return OPP
} else {
return SUF
}
}
function next_player() {
if (game.active === SUF)
game.active = OPP
else
game.active = SUF
}
// #region CARD & HAND FUNCTIONS
function is_support_card(c) {
return c >= first_support_card && c <= last_support_card
}
function is_opposition_card(c) {
return c >= first_opposition_card && c <= last_opposition_card
}
function find_card(name) {
return CARDS.findIndex((x) => x && x.name === name)
}
function draw_card(deck) {
if (deck.length === 0)
throw Error("can't draw from empty deck")
return deck.pop()
}
function player_hand() {
if (game.active === SUF) {
return game.support_hand
} else {
return game.opposition_hand
}
}
function opponent_hand() {
if (game.active === SUF) {
return game.opposition_hand
} else {
return game.support_hand
}
}
function player_buttons() {
if (game.active === SUF) {
return game.support_buttons
} else {
return game.opposition_buttons
}
}
function opponent_buttons() {
if (game.active === SUF) {
return game.opposition_buttons
} else {
return game.support_buttons
}
}
function player_claimed() {
if (game.active === SUF) {
return game.support_claimed
} else {
return game.opposition_claimed
}
}
function player_deck() {
if (game.active === SUF) {
return game.support_deck
} else {
return game.opposition_deck
}
}
function opponent_deck() {
if (game.active === SUF) {
return game.opposition_deck
} else {
return game.support_deck
}
}
function is_player_claimed_card(c) {
return player_claimed().includes(c)
}
function player_set_aside() {
if (game.active === SUF) {
return game.support_set_aside
} else {
return game.opposition_set_aside
}
}
function set_aside_player_hand() {
let aside = player_set_aside()
let hand = player_hand()
set_clear(aside)
for (let c of hand)
aside.push(c)
set_clear(hand)
}
function restore_player_hand() {
let aside = player_set_aside()
let hand = player_hand()
set_clear(hand)
for (let c of aside)
hand.push(c)
set_clear(aside)
}
// #endregion
// #region US_STATES & REGIONS FUNCTIONS
function anywhere() {
return Array.from(Array(us_states_count), (e,i)=>i+1)
}
function find_us_state(name) {
return US_STATES.findIndex((x) => x && x.name === name)
}
function us_states(...args) {
return args.map(find_us_state).sort()
}
function region_us_states(...args) {
const indexes = []
US_STATES.forEach((element, index) => {
if (element && args.includes(element.region)) indexes.push(index)
})
return indexes
}
function region_us_states_except(region, excluded) {
const to_remove = new Set(excluded)
return region_us_states(region).filter( x => !to_remove.has(x) )
}
function us_state_region(s) {
return US_STATES[s].region
}
function us_state_name(s) {
return US_STATES[s].name
}
function free_campaigner(color) {
const start = (color === YELLOW) ? 2 : color === RED ? 4 : 0
const index = game.campaigners.indexOf(0, start)
return index > (start + 1) ? -1 : index
}
function add_campaigner(color, region) {
const index = free_campaigner(color)
if (index !== -1) {
game.campaigners[index] = region
} else {
throw Error("No free campaigners")
}
log(`Placed ${COLOR_CODE[color]}R in R${region}.`)
}
function player_campaigners() {
if (game.active === SUF) {
return game.campaigners.slice(0, 4)
} else {
return game.campaigners.slice(4)
}
}
function for_each_player_campaigner(fn) {
let i = (game.active === SUF) ? 1 : 5
for (let r of player_campaigners()) {
if (r)
fn(i)
i++
}
}
function campaigner_region(c) {
return game.campaigners[c - 1]
}
function move_campaigner(c, region) {
log(`Moved ${COLOR_CODE[campaigner_color(c)]}R to R${region}.`)
game.campaigners[c - 1] = region
}
// RED cubes (6 bits), YELLOW cubes (7 bits), PURPLE cubes (7 bits), RED_X (1 bit), GREEN_CHECK (1 bit),
const GREEN_CHECK_SHIFT = 0
const GREEN_CHECK_MASK = 1 << GREEN_CHECK_SHIFT
const RED_X_SHIFT = 1
const RED_X_MASK = 1 << RED_X_SHIFT
const PURPLE_SHIFT = 2
const PURPLE_MASK = 127 << PURPLE_SHIFT
const YELLOW_SHIFT = 9
const YELLOW_MASK = 127 << YELLOW_SHIFT
const RED_SHIFT = 16
const RED_MASK = 63 << RED_SHIFT
function is_green_check(u) {
return (game.us_states[u] & GREEN_CHECK_MASK) === GREEN_CHECK_MASK
}
function set_green_check(u) {
game.us_states[u] |= GREEN_CHECK_MASK
}
function clear_green_check(u) {
game.us_states[u] &= ~GREEN_CHECK_MASK
}
function is_red_x(u) {
return (game.us_states[u] & RED_X_MASK) === RED_X_MASK
}
function set_red_x(u) {
game.us_states[u] |= RED_X_MASK
}
function clear_red_x(u) {
game.us_states[u] &= ~RED_X_MASK
}
function count_green_checks() {
let result = 0
for (let s = 1; s <= us_states_count; ++s) {
if (is_green_check(s))
result += 1
}
return result
}
function count_red_xs() {
let result = 0
for (let s = 1; s <= us_states_count; ++s) {
if (is_red_x(s))
result += 1
}
return result
}
function purple_cubes(u) {
return (game.us_states[u] & PURPLE_MASK) >> PURPLE_SHIFT
}
function set_purple_cubes(u, x) {
game.us_states[u] = (game.us_states[u] & ~PURPLE_MASK) | (x << PURPLE_SHIFT)
}
function yellow_cubes(u) {
return (game.us_states[u] & YELLOW_MASK) >> YELLOW_SHIFT
}
function set_yellow_cubes(u, x) {
game.us_states[u] = (game.us_states[u] & ~YELLOW_MASK) | (x << YELLOW_SHIFT)
}
function red_cubes(u) {
return (game.us_states[u] & RED_MASK) >> RED_SHIFT
}
function set_red_cubes(u, x) {
game.us_states[u] = (game.us_states[u] & ~RED_MASK) | (x << RED_SHIFT)
}
function support_cubes(u) {
return purple_cubes(u) + yellow_cubes(u)
}
function player_cubes(u) {
if (game.active === SUF)
return support_cubes(u)
else
return red_cubes(u)
}
function opponent_cubes(u) {
if (game.active === SUF)
return red_cubes(u)
else
return support_cubes(u)
}
function color_cubes(cube, u) {
if (cube === PURPLE)
return purple_cubes(u)
else if (cube === YELLOW)
return yellow_cubes(u)
else if (cube === PURPLE_OR_YELLOW)
return purple_cubes(u) + yellow_cubes(u)
else
return red_cubes(u)
}
function set_color_cubes(cube, u, x) {
if (cube === PURPLE)
set_purple_cubes(u, x)
else if (cube === YELLOW)
set_yellow_cubes(u, x)
else
set_red_cubes(u, x)
}
function us_states_with_color_cubes(us_states, cube) {
return us_states.filter( x => color_cubes(cube, x) > 0 )
}
function add_cube(cube, us_state) {
log(`Added ${COLOR_CODE[cube]}C in S${us_state}.`)
if ((cube === RED && support_cubes(us_state) > 0) || (cube !== RED && red_cubes(us_state) > 0))
throw new Error("Can't add cube when opponent still has cubes there")
if (is_green_check(us_state) || is_red_x(us_state))
throw new Error("Can't add cube with green_check / red_x")
set_color_cubes(cube, us_state, color_cubes(cube, us_state) + 1)
}
function remove_cube(cube, us_state) {
log(`Removed ${COLOR_CODE[cube]}C from S${us_state}.`)
if ((cube === PURPLE && !purple_cubes(us_state)) || (cube === YELLOW && !yellow_cubes(us_state)) || (cube === RED && !red_cubes(us_state)))
throw new Error("Can't remove cube that aint there")
if (is_green_check(us_state) || is_red_x(us_state))
throw new Error("Can't remove cube in us_state with green_check / red_x")
set_color_cubes(cube, us_state, color_cubes(cube, us_state) - 1)
}
function remove_green_check(us_state) {
log(`Removed ${COLOR_CODE[GREEN_CHECK]} from S${us_state}.`)
if (!is_green_check(us_state))
throw new Error("Can't remove a green check that aint there")
clear_green_check(us_state)
}
function remove_red_x(us_state) {
log(`Removed ${COLOR_CODE[RED_X]} from S${us_state}.`)
if (!is_red_x(us_state))
throw new Error("Can't remove a red x that aint there")
clear_red_x(us_state)
}
// #endregion
// #region PUBLIC FUNCTIONS
exports.scenarios = [ "Standard" ]
exports.roles = [ SUF, OPP ]
function gen_action(action, argument) {
if (argument === undefined) {
view.actions[action] = 1
} else {
if (!(action in view.actions))
view.actions[action] = []
view.actions[action].push(argument)
}
}
function gen_action_card(c) {
gen_action("card", c)
}
function gen_action_region(r) {
gen_action("region", r)
}
function gen_action_us_state(s) {
gen_action("us_state", s)
}
function gen_action_purple_cube(s) {
gen_action("purple_cube", s)
}
function gen_action_yellow_cube(s) {
gen_action("yellow_cube", s)
}
function gen_action_red_cube(s) {
gen_action("red_cube", s)
}
function gen_action_green_check(s) {
gen_action("green_check", s)
}
function gen_action_red_x(s) {
gen_action("red_x", s)
}
function gen_action_campaigner(c) {
gen_action("campaigner", c)
}
exports.action = function (state, player, action, arg) {
game = state
if (states[game.state] && action in states[game.state]) {
states[game.state][action](arg, player)
} else {
if (action === "undo" && game.undo && game.undo.length > 0)
pop_undo()
else
throw new Error("Invalid action: " + action)
}
return game
}
exports.resign = function (state, player) {
game = state
if (game.state !== "game_over") {
if (player === SUF)
goto_game_over(OPP, "Suffragist resigned.")
if (player === OPP)
goto_game_over(SUF, "Opposition resigned.")
}
return game
}
function goto_game_over(result, victory) {
game.state = "game_over"
game.active = "None"
game.result = result
game.victory = victory
log_br()
log(game.victory)
return true
}
const pluralize = (count, noun, suffix = 's') =>
`${count} ${noun}${count !== 1 ? suffix : ''}`;
// #endregion
// #region SETUP
exports.setup = function (seed, _scenario, _options) {
game = {
seed: seed,
log: [],
undo: [],
active: null,
state: null,
played_card: 0,
selected_cards: [],
turn: 0,
round: 0,
congress: 0,
us_states: new Array(us_states_count + 1).fill(0),
nineteenth_amendment: 0,
campaigners: [0, 0, 0, 0, 0, 0], // purple, purple, yellow, yellow, red, red
strategy_deck: [],
strategy_draw: [],
states_draw: [],
persistent_turn: [],
persistent_game: [],
persistent_ballot: [],
support_deck: [],
support_hand: [],
support_set_aside: [],
support_claimed: [],
support_buttons: 0,
opposition_deck: [],
opposition_hand: [],
opposition_set_aside: [],
opposition_claimed: [],
opposition_buttons: 0,
}
log_h1("Votes for Women")
setup_game()
game.active = SUF
start_turn()
return game
}
function setup_game() {
// init card decks & shuffle
game.support_deck = init_player_cards(first_support_card)
game.support_hand.push(first_support_card)
game.opposition_deck = init_player_cards(first_opposition_card)
game.opposition_hand.push(first_opposition_card)
for (let c = first_strategy_card; c <= last_strategy_card; ++c) {
game.strategy_deck.push(c)
}
for (let c = first_states_card; c <= last_states_card; ++c)
game.states_draw.push(c)
shuffle(game.states_draw)
shuffle(game.strategy_deck)
game.states_draw.splice(-3) // 3 states card aren't used
game.states_draw.sort()
log_h2("States Cards")
for (let c of game.states_draw)
log(`C${c}`)
game.strategy_draw = game.strategy_deck.splice(-3) // draw 3 strategy cards
log_h2("Strategy Cards")
for (let c of game.strategy_draw)
log(`C${c}`)
}
function init_player_cards(first_card) {
let c = first_card
let early = []
let middle = []
let late = []
for (let n = 0; n < era_cards_count; ++n)
early.push(++c)
for (let n = 0; n < era_cards_count; ++n)
middle.push(++c)
for (let n = 0; n < era_cards_count; ++n)
late.push(++c)
shuffle(early)
shuffle(middle)
shuffle(late)
return [].concat(late, middle, early)
}
// #endregion
// #region VIEW
// JSON Schema for view data
exports.VIEW_SCHEMA = {
type: "object",
properties: {
log: {type: "array", items: {type: "string"}},
active: {type: "string"},
prompt: {type: "string"},
actions: {type: "object", nullable: true},
played_card: {type: "integer", minimum: 0},
selected_campaigner: {type: "integer", minimum: 1},
selected_us_state: {type: "integer", minimum: 1},
turn: {type: "integer", minimum: 1, maximum: 6},
round: {type: "integer", minimum: 0, maximum: 6},
congress: {type: "integer", minimum: 0, maximum: 6},
us_states: {type: "array", minItems: us_states_count + 1, maxItems: us_states_count + 1, items: {type: "integer", minimum: 0}},
nineteenth_amendment: {type: "integer", minimum: 0, maximum: 1},
campaigners: {type: "array", minItems: 6, maxItems: 6, items: {type: "integer", minimum: 0, maximum: region_count}},
green_checks: {type: "integer", minimum: 0, maximum: GREEN_CHECK_VICTORY},
red_xs: {type: "integer", minimum: 0, maximum: RED_X_VICTORY},
strategy_deck: {type: "integer", minimum: 0, maximum: 12},
strategy_draw: {type: "array", maxItems: 3, items: {type: "integer", minimum: 1, maximum: 128}},
states_draw: {type: "array", maxItems: 9, items: {type: "integer", minimum: 1, maximum: 128}},
persistent_turn: {type: "array", items: {type: "integer", minimum: 1, maximum: 128}},
persistent_game: {type: "array", items: {type: "integer", minimum: 1, maximum: 128}},
persistent_ballot: {type: "array", items: {type: "integer", minimum: 1, maximum: 128}},
support_deck: {type: "integer", minimum: 0, maximum: 52},
support_hand: {type: "integer", minimum: 1},
support_claimed: {type: "array", items: {type: "integer", minimum: 1, maximum: 128}},
support_buttons: {type: "integer", minimum: 0, maximum: MAX_SUPPORT_BUTTONS},
opposition_deck: {type: "integer", minimum: 0, maximum: 52},
opposition_hand: {type: "integer", minimum: 1},
opposition_claimed: {type: "array", items: {type: "integer", minimum: 1, maximum: 128}},
opposition_buttons: {type: "integer", minimum: 0, maximum: MAX_OPPOSITION_BUTTONS},
hand: {type: "array", items: {type: "integer", minimum: 1, maximum: 128}},
set_aside: {type: "array", items: {type: "integer", minimum: 1, maximum: 128}},
selected_cards: {type: "array", items: {type: "integer", minimum: 1, maximum: 128}},
},
required: [
"log", "active", "prompt", "turn", "congress", "us_states", "campaigners",
"strategy_deck", "strategy_draw", "states_draw",
"support_deck", "support_hand", "support_claimed", "support_buttons",
"opposition_deck", "opposition_hand", "opposition_claimed", "opposition_buttons",
],
additionalProperties: false
}
exports.view = function(state, player) {
game = state
view = {
log: game.log,
active: game.active,
prompt: null,
actions: null,
played_card: game.played_card,
selected_campaigner: game.selected_campaigner,
selected_us_state: game.selected_us_state,
turn: game.turn,
round: game.round,
congress: game.congress,
us_states: game.us_states,
nineteenth_amendment: game.nineteenth_amendment,
campaigners: game.campaigners,
green_checks: 0,
red_xs: 0,
strategy_deck: game.strategy_deck.length,
strategy_draw: game.strategy_draw,
states_draw: game.states_draw,
persistent_turn: game.persistent_turn,
persistent_game: game.persistent_game,
persistent_ballot: game.persistent_ballot,
support_deck: game.support_deck.length,
support_hand: game.support_hand.length,
support_claimed: game.support_claimed,
support_buttons: game.support_buttons,
opposition_deck: game.opposition_deck.length,
opposition_hand: game.opposition_hand.length,
opposition_claimed: game.opposition_claimed,
opposition_buttons: game.opposition_buttons,
hand: [],
set_aside: [],
selected_cards: [],
}
if (game.nineteenth_amendment) {
view.green_checks = count_green_checks()
view.red_xs = count_red_xs()
}
if (player === SUF) {
view.hand = game.support_hand
view.set_aside = game.support_set_aside
view.selected_cards = game.selected_cards
} else if (player === OPP) {
view.hand = game.opposition_hand
view.set_aside = game.opposition_set_aside
view.selected_cards = game.selected_cards
}
if (game.state === "game_over") {
view.prompt = game.victory
} else if (player === "Observer" || (game.active !== player && game.active !== "Both")) {
if (states[game.state]) {
let inactive = states[game.state].inactive
view.prompt = `Waiting for ${game.active} to ${inactive}...`
} else {
view.prompt = "Unknown state: " + game.state
}
} else {
view.actions = {}
if (states[game.state])
states[game.state].prompt(player)
else
view.prompt = "Unknown state: " + game.state
if (view.actions.undo === undefined) {
if (game.undo && game.undo.length > 0)
view.actions.undo = 1
else
view.actions.undo = 0
}
}
return view
}
// #endregion
// #region FLOW OF PLAY
function start_turn() {
game.turn += 1
log_h1("Turn " + game.turn)
goto_planning_phase()
}
function goto_planning_phase() {
log_h2("Planning")
game.state = "planning_phase"
}
states.planning_phase = {
inactive: "do Planning.",
prompt() {
view.prompt = "Planning: Draw cards."
gen_action("draw")
},
draw() {
for (let n = 0; n < 6; ++n) {
game.support_hand.push(draw_card(game.support_deck))
game.opposition_hand.push(draw_card(game.opposition_deck))
}
log("Suffragist drew 7 cards.")
log("Opposition drew 7 cards.")
end_planning_phase()
}
}
function end_planning_phase() {
if (game.support_hand.length !== 7)
throw Error("ASSERT game.support_hand.length === 7")
if (game.opposition_hand.length !== 7)
throw Error("ASSERT game.opposition_hand.length === 7")
if (game.turn === 1) {
goto_operations_phase()
} else {
goto_strategy_phase()
}
}
function goto_strategy_phase() {
log_h2("Strategy")
game.state = "strategy_phase"
game.active = SUF
game.support_committed = 0
}
states.strategy_phase = {
inactive: "do Strategy.",
prompt() {
if (game.active === SUF) {
view.prompt = `Strategy: ${pluralize(game.support_committed, 'button')} committed.`
if (game.support_buttons > 0) {
gen_action("commit_1_button")
}
gen_action("done")
} else {
view.prompt = `Strategy: Suffragist committed ${pluralize(game.support_committed, 'button')}.`
view.actions.defer = 0
view.actions.match = 0
view.actions.supersede = 0
if (game.support_committed > 0) {
view.actions.defer = 1
view.prompt += ` Defer with 0 buttons.`
}
if (game.opposition_buttons >= game.support_committed) {
view.actions.match = 1
view.prompt += ` Match with ${pluralize(game.support_committed, 'button')}.`
}
if (game.opposition_buttons > game.support_committed) {
view.actions.supersede = 1
view.prompt += ` Supersede with ${pluralize(game.support_committed + 1, 'button')}.`
}
}
},
commit_1_button() {
push_undo()
game.support_buttons -= 1
game.support_committed += 1
},
done() {
log(`Suffragist committed ${game.support_committed} BM.`)
game.active = OPP
},
defer() {
log(`Opposition deferred.`)
game.active = SUF
game.state = 'select_strategy_card'
},
match () {
log(`Opposition matched.`)
game.opposition_buttons -= game.support_committed
end_strategy_phase()
},
supersede() {
const amount = game.support_committed + 1
log(`Opposition superseded with ${amount} BM.`)
game.opposition_buttons -= amount
game.state = 'select_strategy_card'
}
}
function claim_strategy_card(c) {
log(`${game.active} selected C${c}.`)
array_remove_item(game.strategy_draw, c)
player_claimed().push(c)
if (game.strategy_deck.length)
game.strategy_draw.push(draw_card(game.strategy_deck))
}
states.select_strategy_card = {
inactive: "select Strategy card.",
prompt() {
view.prompt = "Select Strategy card."
for (let c of game.strategy_draw)
gen_action("card", c)
},
card(c) {
claim_strategy_card(c)
if (game.vm) {
vm_next()
} else {
end_strategy_phase()
}
}
}
function end_strategy_phase() {
delete game.support_committed
goto_operations_phase()
}
function goto_operations_phase() {
log_h2("Operations")
game.state = "operations_phase"
game.active = SUF
game.round = 1
begin_player_round()
}
const THE_CIVIL_WAR = find_card("The Civil War")
const WAR_IN_EUROPE = find_card("War in Europe")
const FIFTEENTH_AMENDMENT = find_card("Fifteenth Amendment")
const EIGHTEENTH_AMENDMENT = find_card("Eighteenth Amendment")
const SOUTHERN_STRATEGY = find_card("Southern Strategy")
const _1918_PANDEMIC = find_card("1918 Pandemic")
const A_THREAT_TO_THE_IDEAL_OF_WOMANHOOD = find_card("A Threat to the Ideal of Womanhood")
function has_extra_event_cost() {
return game.active === SUF && (game.persistent_turn.includes(_1918_PANDEMIC) || game.persistent_turn.includes(A_THREAT_TO_THE_IDEAL_OF_WOMANHOOD))
}
function can_play_event(c) {
if (game.active === SUF && is_opposition_card(c))
return false
if (game.active === OPP && is_support_card(c))
return false
// Playable if *The Civil War* is in effect
if (c === 5 && !game.persistent_turn.includes(THE_CIVIL_WAR))
return false
// Playable if *The Civil War* is not in effect
if ([6, 7, 18].includes(c) && game.persistent_turn.includes(THE_CIVIL_WAR))
return false
// Playable if *War in Europe* is in effect.
if (c === 45 && !game.persistent_turn.includes(WAR_IN_EUROPE))
return false
// Playable if *Fifteenth Amendment* is in effect
if ([7, 55, 69].includes(c) && !game.persistent_game.includes(FIFTEENTH_AMENDMENT))
return false
// Playable if *Eighteenth Amendment* is not in effect
if ([68, 83, 92, 96].includes(c) && game.persistent_game.includes(EIGHTEENTH_AMENDMENT))
return false
// Playable if *Southern Strategy* is in effect
if ([82, 85, 94, 95].includes(c) && !game.persistent_game.includes(SOUTHERN_STRATEGY))
return false
// Needs 19th amendment to have passed
if ([102, 106].includes(c) && !game.nineteenth_amendment)
return false
let cost = 0
// Spend 4 buttons to select
if ([39, 100].includes(c))
cost += 4
// Suffragist must pay 1 button to play event during 1918 Pandemic or A Threat to the Ideal of Womanhood
if (has_extra_event_cost())
cost += 1
if (player_buttons() < cost)
return false
// Playable if it is Turn 5 or Turn 6
if (c === 113 && game.turn < 5)
return false
return true
}
function count_player_active_campaigners() {
return player_campaigners().filter(value => value !== 0).length
}
function has_player_active_campaigners() {
return player_campaigners().some(value => value !== 0)
}
function remove_claimed_card(c) {
array_remove_item(player_claimed(), c)
}
function discard_card_from_hand(c) {
array_remove_item(player_hand(), c)
}
function end_play_card(c) {
if (is_player_claimed_card(c)) {
remove_claimed_card(c)
} else {
discard_card_from_hand(c)
}
delete game.count
delete game.dice
delete game.roll
game.played_card = 0
game.state = "operations_phase"
}
function can_campaign() {
return (game.active !== SUF || !game.persistent_turn.includes(WAR_IN_EUROPE) || player_buttons())
}
function can_organize() {
return (game.active === SUF && game.support_buttons < MAX_SUPPORT_BUTTONS) || (game.active === OPP && game.opposition_buttons < MAX_OPPOSITION_BUTTONS)
}
function can_lobby() {
return !game.nineteenth_amendment && (
(game.active === SUF && game.congress < 6) || (game.active === OPP && game.congress > 0))
}
function update_card_played(c) {
if (is_player_claimed_card(c)) {
game.has_played_claimed = 1
} else {
game.has_played_hand = 1
}
}
states.operations_phase = {
inactive: "Play a Card.",
prompt() {
let can_play_hand = false
let can_play_claimed = false
if (!game.has_played_hand) {
for (let c of player_hand()) {
if (can_play_event(c)) {
gen_action("card_event", c)
can_play_hand = true
}
if (has_player_active_campaigners()) {
if (can_campaign()) {
gen_action("card_campaigning", c)
can_play_hand = true
}
if (can_organize()) {
gen_action("card_organizing", c)
can_play_hand = true
}
if (can_lobby()) {
gen_action("card_lobbying", c)
can_play_hand = true
}
}
}
}
if (!game.has_played_claimed) {
// only one claimed card can be played per turn
for (let c of player_claimed()) {
if (can_play_event(c)) {
gen_action("card_event", c)
can_play_claimed = true
}
}
}
if (can_play_hand && can_play_claimed) {
view.prompt = "Operations: Play a card from Hand or Claimed card (optional)."
} else if (can_play_hand) {
view.prompt = "Operations: Play a card from Hand."
} else if (can_play_claimed) {
view.prompt = "Operations: Play a Claimed card (optional)."
} else {
view.prompt = "Operations: Done."
}
if (game.has_played_hand)
gen_action("done")
},
card_event(c) {
push_undo()
update_card_played(c)
play_card_event(c)
},
card_campaigning(c) {
push_undo()
log_h3(`C${c} - Campaigning`)
log_br()
update_card_played(c)
goto_campaigning(c)
},
card_organizing(c) {
push_undo()
log_h3(`C${c} - Organizing`)
log_br()
update_card_played(c)
goto_organizing(c)
},
card_lobbying(c) {
push_undo()
log_h3(`C${c} - Lobbying`)
log_br()
update_card_played(c)
goto_lobbying(c)
},
done() {
end_player_round()
}
}
function play_card_event(c) {
log_h3(`C${c} - Event`)
if (has_extra_event_cost())
decrease_player_buttons(1)
log_br()
goto_event(c)
}
function begin_player_round() {
log_round(`Round ${game.round}`)
}
function end_player_round() {
clear_undo()
delete game.has_played_claimed
delete game.has_played_hand
if (game.active === SUF) {
game.active = OPP
} else {
if (game.round < 6) {
game.active = SUF
game.round += 1
} else {
goto_cleanup_phase()
return
}
}
begin_player_round()
}
function discard_persistent_card(cards, c) {
log(`C${c} discarded.`)
array_remove_item(cards, c)
}
function goto_cleanup_phase() {
log_h2("Cleanup")
if (game.turn < 6) {
// any cards in the “Cards in Effect for the Rest of the Turn box”
// are placed in the appropriate discard pile.
for (let c of game.persistent_turn)
log(`C${c} discarded.`)
game.persistent_turn = []
if (game.support_hand.length !== 1)
throw Error("ASSERT game.support_hand.length === 1")
if (game.opposition_hand.length !== 1)
throw Error("ASSERT game.opposition_hand.length === 1")
} else {
// At the end of Turn 6, if the Nineteenth
// Amendment has not been sent to the states for
// ratification, the game ends in an Opposition victory.
if (!game.nineteenth_amendment) {
goto_game_over(OPP, "Opposition wins the game.")
return
}
// If the Nineteenth Amendment has been sent to the
// states for ratification but neither player has won
// the necessary number of states for victory, the game
// advances to Final Voting.
// Any cards in the “Cards in Effect for the Rest of the Turn box”
// and “Cards in Effect for the Rest of the Game box” are placed in
// the appropriate discard pile.
for (let c of game.persistent_turn)
log(`C${c} discarded.`)
game.persistent_turn = []
for (let c of game.persistent_game)
log(`C${c} discarded.`)
game.persistent_game = []
}
game.state = "cleanup_phase"
}
states.cleanup_phase = {
inactive: "do Cleanup.",
prompt() {
view.prompt = "Cleanup."
if (game.turn < 6)
gen_action("next_turn")
else
gen_action("final_voting")
},
next_turn() {
start_turn()
},
final_voting() {
goto_final_voting()
}
}
function goto_final_voting() {
log_h1("Final Voting")
log(`Suffragist has ${count_green_checks()} of ${GREEN_CHECK_VICTORY} States.`)
log(`Opposition has ${count_red_xs()} of ${RED_X_VICTORY} States.`)
game.active = SUF
game.state = "final_voting_select_state"
}
states.final_voting_select_state = {
inactive: "do Final Voting.",
prompt() {
view.prompt = "Final Voting: Select a state."
if (game.active === SUF)
view.prompt += ` You need ${GREEN_CHECK_VICTORY - count_green_checks()} more States for victory.`
else
view.prompt += ` You need ${RED_X_VICTORY - count_red_xs()} more States for victory.`
let us_states = anywhere()
set_filter(us_states, s => !(is_green_check(s) || is_red_x(s)))
for (let s of us_states) {
gen_action_us_state(s)
}
},
us_state(s) {
push_undo()
game.selected_us_state = s
log_h2(`Final Voting for S${game.selected_us_state}`)
goto_final_voting_roll()
}
}
const VOTER_REGISTRATION = find_card("Voter Registration")
const VOTER_SUPPRESSION = find_card("Voter Suppression")
function final_voting_dice(player) {
if (player === SUF && game.persistent_ballot.includes(VOTER_REGISTRATION))
return D8
if (player === OPP && game.persistent_ballot.includes(VOTER_SUPPRESSION))
return D8
else
return D6
}
function goto_final_voting_roll() {
game.roll = 0
game.opponent_roll = 0
game.dice = final_voting_dice(game.active)
game.opponent_dice = final_voting_dice(opponent_name())
let plus_support_cubes = support_cubes(game.selected_us_state)
let plus_opposition_cubes = red_cubes(game.selected_us_state)
if (plus_support_cubes)
log(`Suffragist gets +${plus_support_cubes}.`)
if (plus_opposition_cubes)
log(`Opposition gets +${plus_opposition_cubes}.`)
game.drm = (game.active === SUF) ? plus_support_cubes : plus_opposition_cubes
game.opponent_drm = (game.active === SUF) ? plus_opposition_cubes : plus_support_cubes
game.state = "final_voting_roll"
}
states.final_voting_roll = {
inactive: "do Final Voting.",
prompt() {
view.prompt = `Final Voting for ${us_state_name(game.selected_us_state)}: `
if (!game.roll) {
if (game.drm)
view.prompt += `You get +${game.drm}. `
else if (game.opponent_drm)
view.prompt += `${opponent_name()} gets +${game.opponent_drm}. `
view.prompt += "Roll dice."
gen_action("roll")
} else {
view.prompt += `${opponent_name()} rolled ${game.opponent_roll}`
if (game.opponent_drm)
view.prompt += ` (+${game.opponent_drm})`
view.prompt += `, You rolled ${game.roll}`
if (game.drm)
view.prompt += ` (+${game.drm})`
view.prompt += '.'
// only reroll when you can and when it makes sense
if (player_buttons() > 0 && game.roll < game.dice)
gen_action("reroll")
gen_action("next")
}
},
roll() {
game.persistent_ballot.includes(VOTER_REGISTRATION)
game.roll = roll_ndx(1, game.dice, `${game.active} rolled`)
game.opponent_roll = roll_ndx(1, game.opponent_dice, `${opponent_name()} rolled`)
},
reroll() {
decrease_player_buttons(1)
game.roll = roll_ndx(1, game.dice, `${game.active} re-rolled`)
},
next() {
next_player()
game.state = "final_voting_opponent"
}
}
states.final_voting_opponent = {
inactive: "do Final Voting.",
prompt() {
view.prompt = `Final Voting for ${us_state_name(game.selected_us_state)}: `
view.prompt += `${opponent_name()} rolled ${game.roll}`
if (game.drm)
view.prompt += ` (+${game.drm})`
view.prompt += `, You rolled ${game.opponent_roll}`
if (game.opponent_drm)
view.prompt += ` (+${game.opponent_drm})`
view.prompt += '.'
// only reroll when you can and when it makes sense
if (player_buttons() > 0 && game.opponent_roll < game.opponent_dice)
gen_action("reroll")
gen_action("next")
},
reroll() {
decrease_player_buttons(1)
game.opponent_roll = roll_ndx(1, game.opponent_dice, `${game.active} re-rolled`)
},
next() {
goto_final_voting_result()
}
}
const MISS_FEBB_WINS_THE_LAST_VOTE = find_card("Miss Febb Wins the Last Vote")
function goto_final_voting_result() {
clear_undo()
let support_roll = game.active === OPP ? game.roll : game.opponent_roll
let opposition_roll = game.active === SUF ? game.roll : game.opponent_roll
let plus_support_cubes = support_cubes(game.selected_us_state)
let plus_opposition_cubes = red_cubes(game.selected_us_state)
let support_total = support_roll + plus_support_cubes
let opposition_total = opposition_roll + plus_opposition_cubes
log_br()
// log(`Suffragist ${support_roll} + ${plus_support_cubes} = ${support_total}`)
// log(`Opposition ${opposition_roll} + ${plus_opposition_cubes} = ${opposition_total}`)
log(`${support_roll} (+${plus_support_cubes}) = ${support_total} vs. ${opposition_roll} (+${plus_opposition_cubes}) = ${opposition_total}`)
if (support_total > opposition_total)
game.voting_winner = SUF
else if (opposition_total > support_total)
game.voting_winner = OPP
else if (game.persistent_ballot.includes(MISS_FEBB_WINS_THE_LAST_VOTE))
game.voting_winner = SUF
else
game.voting_winner = OPP
if (game.voting_winner === SUF)
ratify_nineteenth_amendment(game.selected_us_state)
else
reject_nineteenth_amendment(game.selected_us_state)
log_br()
log(`Suffragist won ${count_green_checks()} of ${GREEN_CHECK_VICTORY} States.`)
log(`Opposition won ${count_red_xs()} of ${RED_X_VICTORY} States.`)
game.state = "final_voting_result"
}
states.final_voting_result = {
inactive: "do Final Voting.",
prompt() {
if (game.active === game.voting_winner) {
view.prompt = `Final Voting for ${us_state_name(game.selected_us_state)}: You win!`
} else {
view.prompt = `Final Voting for ${us_state_name(game.selected_us_state)}: ${game.voting_winner} wins.`
}
gen_action("next")
},
next() {
if (check_victory())
return
game.state = "final_voting_select_state"
delete game.selected_us_state
game.voting_winner = null
}
}
// #endregion
// #region NON-EVENT CARD ACTIONS
const SUPPORT_CAMPAIGNING_BOOST = [
find_card("Property Rights for Women"),
find_card("Marie Louise Bottineau Baldwin"),
find_card("Prison Tour Special")
]
const OPPOSITION_CAMPAIGNING_BOOST = [
find_card("Beer Brewers"),
find_card("Conservative Opposition"),
find_card("Big Liquor’s Big Money")
]
function has_campaigning_boost() {
for (let c of game.persistent_turn) {
if (game.active === SUF && SUPPORT_CAMPAIGNING_BOOST.includes(c))
return true
if (game.active === OPP && OPPOSITION_CAMPAIGNING_BOOST.includes(c))
return true
}
return false
}
function goto_campaigning(c) {
game.played_card = c
game.state = 'campaigning'
game.count = count_player_active_campaigners()
if (has_campaigning_boost())
game.dice = D6
else
game.dice = D4
game.roll = []
}
states.campaigning = {
inactive: "do Campaigning.",
prompt() {
if (!game.roll.length) {
view.prompt = `Campaigning: Roll ${game.count} d${game.dice}.`
gen_action("roll")
} else {
view.prompt = `Campaigning: You rolled ${game.roll.join(", ")}.`
if (player_buttons() > 0)
gen_action("reroll")
gen_action("next")
}
},
roll() {
game.roll = roll_ndx_list(game.count, game.dice)
},
reroll() {
decrease_player_buttons(1)
game.roll = roll_ndx_list(game.count, game.dice, "Re-rolled")
},
next() {
goto_campaigning_assign()
}
}
function goto_campaigning_assign() {
if (!game.campaigning) {
game.campaigning = {
dice_idx: 0,
assigned: [],
count: 0,
region: 0,
moved: false
}
}
if (game.campaigning.assigned.length !== game.count) {
game.state = "campaigning_assign"
} else {
delete game.selected_campaigner
delete game.campaigning
if (game.vm)
vm_next()
else
end_play_card(game.played_card)
}
}
states.campaigning_assign = {
inactive: "do Campaigning.",
prompt() {
let die = game.roll[game.campaigning.dice_idx]
view.prompt = `Campaigning: Assign ${die} to a Campaigner.`
for_each_player_campaigner(c => {
if (!set_has(game.campaigning.assigned, c))
gen_action_campaigner(c)
})
},
campaigner(c) {
push_undo()
let die = game.roll[game.campaigning.dice_idx]
goto_campaigning_add_cubes(c, die)
}
}
function campaigner_color(c) {
if (c <= 2) {
return PURPLE
} else if (c <= 4) {
return YELLOW
} else {
return RED
}
}
function goto_campaigning_add_cubes(campaigner, die) {
game.selected_campaigner = campaigner
set_add(game.campaigning.assigned, campaigner)
log_br()
log(`Assigned ${DICE_COLOR[game.dice]}${die} to ${COLOR_CODE[campaigner_color(campaigner)]}R in R${campaigner_region(campaigner)}.`)
game.campaigning.count = die
game.campaigning.added = 0
game.campaigning.moved = false
game.state = "campaigning_add_cubes"
}
function filter_us_states(us_states) {
// If a state has already ratified or rejected the Nineteenth Amendment –
// and therefore has a V or X in the state – cubes may not be added to that state.
if (game.nineteenth_amendment) {
set_filter(us_states, s => !(is_green_check(s) || is_red_x(s)))
}
// When The Civil War is in effect, for the remainder of the turn, the Suffragist player
// may not add :purple_or_yellow_cube to any state in the Atlantic & Appalachia and South regions.
if (game.active === SUF && game.persistent_turn.includes(THE_CIVIL_WAR)) {
let excluded = region_us_states(ATLANTIC_APPALACHIA, SOUTH)
set_filter(us_states, s => !set_has(excluded, s))
}
}
states.campaigning_add_cubes = {
inactive: "do Campaigning.",
prompt() {
let has_opponent_cubes = false
let can_move = false
if (!game.campaigning.added && player_buttons() > 0 && !game.campaigning.moved) {
gen_action("move")
can_move = true
}
let us_states = region_us_states(campaigner_region(game.selected_campaigner))
filter_us_states(us_states)
for (let s of us_states) {
if (opponent_cubes(s)) {
has_opponent_cubes = true
if (game.active === SUF) {
gen_action_red_cube(s)
} else {
if (purple_cubes(s))
gen_action_purple_cube(s)
if (yellow_cubes(s))
gen_action_yellow_cube(s)
}
} else {
gen_action_us_state(s)
}
}
if (us_states.length) {
view.prompt = `Campaigning: Add a ${COLOR_NAMES[campaigner_color(game.selected_campaigner)]} cube.`
if (has_opponent_cubes)
view.prompt += " or remove an Opponent's cube"
if (can_move) {
view.prompt += " or Move to another Region"
}
view.prompt += "."
} else {
view.prompt = `Campaigning: No available States to add a ${COLOR_NAMES[campaigner_color(game.selected_campaigner)]} cube.`
gen_action("done")
}
},
done() {
end_campaigning_add_cube()
},
move() {
push_undo()
game.state = "campaigning_move"
},
purple_cube(s) {
push_undo()
remove_cube(PURPLE, s)
after_campaigning_add_cube(s)
},
yellow_cube(s) {
push_undo()
remove_cube(YELLOW, s)
after_campaigning_add_cube(s)
},
red_cube(s) {
push_undo()
remove_cube(RED, s)
after_campaigning_add_cube(s)
},
us_state(s) {
push_undo()
add_cube(campaigner_color(game.selected_campaigner), s)
after_campaigning_add_cube(s)
}
}
function after_campaigning_add_cube(us_state) {
if (player_cubes(us_state) === 4) {
on_4th_cube(us_state)
if (check_victory())
return true
}
game.campaigning.added += 1
if (game.campaigning.added === game.campaigning.count) {
end_campaigning_add_cube()
}
}
function end_campaigning_add_cube() {
delete game.selected_campaigner
if (game.campaigning.dice_idx < game.roll.length)
game.campaigning.dice_idx += 1
goto_campaigning_assign()
}
states.campaigning_move = {
inactive: "do Campaigning.",
prompt() {
view.prompt = "Campaigning: Select region to move the Campaigner to."
let current_region = campaigner_region(game.selected_campaigner)
for (let r = 1; r <= region_count; r++) {
if (r !== current_region)
gen_action_region(r)
}
},
region(r) {
push_undo()
decrease_player_buttons(1)
move_campaigner(game.selected_campaigner, r)
game.campaigning.moved = true
game.state = "campaigning_add_cubes"
}
}
function goto_organizing(c) {
game.played_card = c
game.state = 'organizing'
game.count = count_player_active_campaigners()
}
states.organizing = {
inactive: "receive buttons.",
prompt() {
view.prompt = `Organizing: Receive ${pluralize(game.count, 'button')}`
gen_action("next")
},
next() {
push_undo()
if (game.count)
increase_player_buttons(game.count)
end_play_card(game.played_card)
}
}
const PROCESSIONS_FOR_SUFFRAGE = find_card("Processions for Suffrage")
function has_lobbying_boost() {
return game.active === SUF && game.persistent_turn.includes(PROCESSIONS_FOR_SUFFRAGE)
}
function goto_lobbying(c) {
game.played_card = c
game.state = 'lobbying'
game.count = count_player_active_campaigners()
game.roll = -1
if (has_lobbying_boost())
game.dice = D8
else
game.dice = D6
}
states.lobbying = {
inactive: "do Lobbying.",
prompt() {
if (game.roll === -1) {
view.prompt = `Lobbying: Roll ${game.count} d${game.dice}.`
gen_action("roll")
} else {
view.prompt = `Lobbying: You rolled ${game.roll} sixes (or higher).`
if (player_buttons() > 0 && game.roll < game.count)
gen_action("reroll")
gen_action("next")
}
},
roll() {
game.roll = roll_ndx_count_success(game.count, game.dice)
},
reroll() {
decrease_player_buttons(1)
game.roll = roll_ndx_count_success(game.count, game.dice, "Re-rolled")
},
next() {
if (game.roll > 0) {
game.count = game.roll
if (game.active === SUF) {
game.state = "lobbying_add_congress"
} else {
game.state = "lobbying_remove_congress"
}
} else {
end_play_card(game.played_card)
}
}
}
function ratify_nineteenth_amendment(us_state) {
log(`S${us_state} voted ${COLOR_CODE[GREEN_CHECK]}.`)
game.us_states[us_state] = 0
set_green_check(us_state)
}
function reject_nineteenth_amendment(us_state) {
log(`S${us_state} voted ${COLOR_CODE[RED_X]}.`)
game.us_states[us_state] = 0
set_red_x(us_state)
}
function trigger_nineteenth_amendment() {
if (game.nineteenth_amendment)
throw Error("ASSERT: nineteenth_amendment already set")
log("Congress passed the Nineteenth Amendment.")
game.nineteenth_amendment = 1
game.congress = 0
let green_check = 0
let red_x = 0
for (let s = 1; s <= us_states_count; ++s) {
if (support_cubes(s) >= 4) {
ratify_nineteenth_amendment(s)
green_check += 1
if (green_check >= GREEN_CHECK_VICTORY)
return goto_game_over(SUF, "Suffragist wins the game.")
} else if (opponent_cubes(s) >= 4) {
reject_nineteenth_amendment(s)
red_x += 1
if (red_x >= RED_X_VICTORY)
return goto_game_over(OPP, "Opposition wins the game.")
}
}
return false
}
function check_victory() {
if (!game.nineteenth_amendment)
return false
if (count_green_checks() >= GREEN_CHECK_VICTORY) {
goto_game_over(SUF, "Suffragist wins the game.")
return true
} else if (count_red_xs() >= RED_X_VICTORY) {
goto_game_over(OPP, "Opposition wins the game.")
return true
}
return false
}
// XXX similar to states.vm_add_congress, refactor?
states.lobbying_add_congress = {
inactive: "add a Congressional marker.",
prompt() {
view.prompt = `Lobbying: Add ${pluralize(game.count, 'Congressional marker')}.`
gen_action("congress")
},
congress() {
game.congress = Math.min(game.congress + game.count, 6)
log(`Congress +${game.count} CM.`)
if (game.congress >= 6) {
if (trigger_nineteenth_amendment())
return
}
end_play_card(game.played_card)
}
}
// XXX similar to states.vm_remove_congress, refactor?
states.lobbying_remove_congress = {
inactive: "remove a Congressional marker.",
prompt() {
view.prompt = `Lobbying: Remove ${pluralize(game.count, 'Congressional marker')}.`
gen_action("congress")
},
congress() {
game.congress = Math.max(game.congress - game.count, 0)
log(`Congress -${game.count} CM.`)
end_play_card(game.played_card)
}
}
// #endregion
// #region EVENTS GENERIC
function goto_event(c) {
game.played_card = c
goto_vm(c)
}
function end_event() {
let c = game.vm.fp
game.vm = null
end_play_card(c)
}
function goto_vm(proc) {
game.state = "vm"
game.vm = {
prompt: 0,
fp: proc,
ip: 0,
}
vm_exec()
}
function event_prompt(str) {
if (typeof str === "undefined")
str = CODE[game.vm.fp][game.vm.prompt][1]
if (typeof str === "function")
str = str()
view.prompt = CARDS[game.vm.fp].name + ": " + str
}
function vm_assert_argcount(n) {
const argcount = CODE[game.vm.fp][game.vm.ip].length - 1
if (argcount !== n)
throw Error(`ASSERT Invalid number of arguments on event ${game.vm.fp}: ${argcount} instead of ${n}`)
}
function vm_inst(a) {
return CODE[game.vm.fp][game.vm.ip][a]
}
function vm_operand(a) {
let x = CODE[game.vm.fp][game.vm.ip][a]
if (a > 0 && typeof x === "function")
return x()
return x
}
function vm_operand_us_states(x) {
let s = vm_operand(x)
if (typeof s === "number")
return [ s ]
return s
}
function vm_exec() {
vm_inst(0)()
}
function vm_next() {
game.vm.ip ++
vm_exec()
}
function vm_prompt() {
game.vm.prompt = game.vm.ip
vm_next()
}
function vm_log() {
log(vm_operand(1))
vm_next()
}
function vm_return() {
// game.state = "vm_return"
end_event()
}
states.vm_return = {
inactive: "finish playing the event.",
prompt() {
event_prompt("Done.")
view.actions.end_event = 1
},
end_event() {
end_event()
},
done() {
end_event()
},
}
function vm_if() {
if (!vm_operand(1)) {
let balance = 1
while (balance > 0) {
++game.vm.ip
switch (vm_operand(0)) {
case vm_if:
++balance
break
case vm_endif:
--balance
break
case vm_else:
if (balance === 1)
--balance
break
}
if (game.vm.ip < 0 || game.vm.ip > CODE[game.vm.fp].length)
throw "ERROR"
}
}
vm_next()
}
function vm_else() {
vm_jump(vm_endif, vm_if, 1, 1)
}
function vm_jump(op, nop, dir, step) {
let balance = 1
while (balance > 0) {
game.vm.ip += dir
if (vm_inst(0) === op)
--balance
if (vm_inst(0) === nop)
++balance
if (game.vm.ip < 0 || game.vm.ip > CODE[game.vm.fp].length)
throw "ERROR"
}
game.vm.ip += step
vm_exec()
}
function vm_endif() {
vm_next()
}
// #endregion
// #region EVENTS VfW DSL
function vm_add_campaigner() {
vm_assert_argcount(2)
game.vm.campaigner = vm_operand(1)
game.vm.region = vm_operand(2)
game.state = "vm_add_campaigner"
}
function vm_receive_buttons() {
vm_assert_argcount(1)
game.vm.count = vm_operand(1)
game.state = "vm_receive_buttons"
}
function vm_spend_buttons() {
vm_assert_argcount(1)
game.vm.count = vm_operand(1)
game.state = "vm_spend_buttons"
if (player_buttons() < game.vm.count)
throw Error("ASSERT: Insufficient buttons")
}
function vm_opponent_loses_buttons() {
vm_assert_argcount(1)
game.vm.count = vm_operand(1)
game.state = "vm_opponent_loses_buttons"
}
function vm_add_cubes() {
vm_assert_argcount(3)
game.vm.count = vm_operand(1)
game.vm.cubes = vm_operand(2)
game.vm.us_states = vm_operand_us_states(3)
goto_vm_add_cubes()
}
function vm_add_cubes_limit() {
vm_assert_argcount(4)
game.vm.count = vm_operand(1)
game.vm.cubes = vm_operand(2)
game.vm.us_states = vm_operand_us_states(3)
game.vm.limit = vm_operand(4)
goto_vm_add_cubes()
}
function vm_add_cubes_in_each_of() {
vm_assert_argcount(3)
game.vm.count = vm_operand(1)
game.vm.cubes = vm_operand(2)
game.vm.us_states = vm_operand_us_states(3)
game.vm.in_each_of = true
goto_vm_add_cubes()
}
function vm_add_cubes_in_one_state_of_each_region() {
vm_assert_argcount(2)
game.vm.count = vm_operand(1)
game.vm.cubes = vm_operand(2)
game.vm.us_states = anywhere()
game.vm.in_one_state_of_each_region = true
goto_vm_add_cubes()
}
function vm_add_cubes_per_state_in_any_one_region() {
vm_assert_argcount(2)
game.vm.count = vm_operand(1)
game.vm.cubes = vm_operand(2)
game.vm.us_states = anywhere()
game.vm.per_state_in_any_one_region = true
goto_vm_add_cubes()
}
function vm_remove_cubes_limit() {
vm_assert_argcount(4)
game.vm.count = vm_operand(1)
game.vm.cubes = vm_operand(2)
game.vm.us_states = us_states_with_color_cubes(vm_operand_us_states(3), game.vm.cubes)
game.vm.limit = vm_operand(4)
goto_vm_remove_cubes()
}
function vm_remove_all_cubes() {
vm_assert_argcount(2)
game.vm.cubes = vm_operand(1)
game.vm.us_states = us_states_with_color_cubes(vm_operand_us_states(2), game.vm.cubes)
game.vm.all = true
goto_vm_remove_cubes()
}
function vm_remove_all_cubes_up_to() {
vm_assert_argcount(2)
game.vm.cubes = vm_operand(1)
game.vm.us_states = us_states_with_color_cubes(anywhere(), game.vm.cubes)
game.vm.limit = vm_operand(2)
game.vm.all = true
goto_vm_remove_cubes()
}
function vm_replace() {
vm_assert_argcount(3)
game.vm.what = vm_operand(1)
game.vm.count = vm_operand(2)
game.vm.replacement = vm_operand(3)
game.vm.us_states = anywhere()
set_filter(game.vm.us_states, s => is_green_check(s) || is_red_x(s))
if (!game.nineteenth_amendment || (game.vm.what === GREEN_CHECK && !count_green_checks()) || game.vm.what === RED_X && !count_red_xs()) {
vm_next()
} else {
goto_vm_replace()
}
}
function vm_add_congress() {
vm_assert_argcount(1)
game.vm.count = vm_operand(1)
if (!game.nineteenth_amendment && game.vm.count) {
game.state = "vm_add_congress"
} else {
vm_next()
}
}
function vm_remove_congress() {
vm_assert_argcount(1)
game.vm.count = vm_operand(1)
if (!game.nineteenth_amendment && game.congress > 0 && game.vm.count) {
game.state = "vm_remove_congress"
} else {
vm_next()
}
}
function vm_roll() {
vm_assert_argcount(2)
game.vm.count = vm_operand(1)
game.vm.d = vm_operand(2)
game.state = "vm_roll"
}
function vm_roll_for_success() {
vm_assert_argcount(2)
game.vm.count = vm_operand(1)
game.vm.d = vm_operand(2)
game.vm.for_success = true
game.state = "vm_roll"
}
function vm_roll_list() {
vm_assert_argcount(2)
game.vm.count = vm_operand(1)
game.vm.d = vm_operand(2)
game.vm.roll_list = true
game.state = "vm_roll"
}
function vm_move_each_player_campaigner_free() {
vm_assert_argcount(0)
if (has_player_active_campaigners()) {
game.vm.moved = []
game.state = "move_each_player_campaigner_free"
delete game.selected_campaigner
} else {
vm_next()
}
}
function vm_select_strategy_card() {
vm_assert_argcount(0)
game.state = "select_strategy_card"
}
function vm_select_us_state() {
vm_assert_argcount(0)
game.state = "vm_select_us_state"
delete game.vm.selected_us_state
}
function vm_persistent() {
vm_assert_argcount(2)
let type = vm_operand(1)
let message = vm_operand(2)
switch (type) {
case REST_OF_TURN:
log(message || "Card in Effect for the Rest of the Turn.")
game.persistent_turn.push(game.vm.fp)
break
case REST_OF_GAME:
log(message || "Card in Effect for the Rest of the Game.")
game.persistent_game.push(game.vm.fp)
break
case BALLOT_BOX:
log(message || "Card in Effect for Final Voting.")
game.persistent_ballot.push(game.vm.fp)
break
}
game.vm.persistent = 1
vm_next()
}
function vm_requires_persistent() {
vm_assert_argcount(2)
let type = vm_operand(1)
let card = vm_operand(2)
if (type === REST_OF_TURN && !game.persistent_turn.includes(card))
throw Error(`ASSERT: Card ${card} not in persistent_turn`)
if (type === REST_OF_GAME && !game.persistent_game.includes(card))
throw Error(`ASSERT: Card ${card} not in persistent_game`)
if (type == BALLOT_BOX && !game.persistent_ballot.includes(card))
throw Error(`ASSERT: Card ${card} not in persistent_ballot`)
vm_next()
}
function vm_requires_not_persistent() {
vm_assert_argcount(2)
let type = vm_operand(1)
let card = vm_operand(2)
if (type === REST_OF_TURN && game.persistent_turn.includes(card))
throw Error(`ASSERT: Card ${card} not expected in persistent_turn`)
if (type === REST_OF_GAME && game.persistent_game.includes(card))
throw Error(`ASSERT: Card ${card} not expected in persistent_game`)
if (type === BALLOT_BOX && game.persistent_ballot.includes(card))
throw Error(`ASSERT: Card ${card} not expected in persistent_ballot`)
vm_next()
}
function vm_discard_persistent() {
vm_assert_argcount(2)
let type = vm_operand(1)
let card = vm_operand(2)
if (type !== REST_OF_TURN)
throw Error(`ASSERT: discard_persistent only supported for REST_OF_TURN`)
if (game.persistent_turn.includes(card)) {
discard_persistent_card(game.persistent_turn, card)
} else {
log(`C${card} not in effect.`)
}
vm_next()
}
function vm_campaigning_action() {
vm_assert_argcount(0)
if (has_player_active_campaigners()) {
log_h3("Campaigning Action")
goto_campaigning(game.played_card)
} else {
vm_next()
}
}
function vm_counter_strat() {
vm_assert_argcount(0)
game.state = "vm_counter_strat"
}
function vm_draw_2_play_1_event() {
vm_assert_argcount(0)
clear_undo()
game.vm.draw = []
for (let i = 0; i < 2; ++i) {
let card = draw_card(player_deck())
game.vm.draw.push(card)
player_hand().push(card)
}
log(`${game.active} drew 2 cards.`)
game.state = "vm_draw_2_play_1_event"
}
function vm_draw_6_place_any_on_top_of_draw() {
vm_assert_argcount(0)
goto_vm_place_any_on_top_of_draw()
}
function vm_draw_6_play_1_place_any_on_top_of_draw() {
vm_assert_argcount(0)
game.vm.play_one = -1
goto_vm_place_any_on_top_of_draw()
}
function vm_opponent_discard_2_random_draw_2() {
vm_assert_argcount(0)
clear_undo()
next_player()
game.selected_cards = shuffle(object_copy(player_hand())).slice(0, 2)
log(`Randomly selected ${pluralize(game.selected_cards.length, 'card')} from ${game.active}'s Hand.`)
game.state = "vm_opponent_discard_2_random_draw_2"
}
function vm_show_opponents_hand_discard_1_draw_1() {
vm_assert_argcount(0)
clear_undo()
set_aside_player_hand()
for (let c of opponent_hand())
player_hand().push(c)
log(`${game.active} looked at ${opponent_name()}'s Hand.`)
game.state = "vm_show_opponents_hand_discard_1_draw_1"
}
function vm_select_1_card_from_draw_deck_play_event_shuffle() {
vm_assert_argcount(0)
clear_undo()
set_aside_player_hand()
for (let c of player_deck())
player_hand().push(c)
log(`${game.active} looked at their Draw Deck.`)
game.state = "vm_select_1_card_from_draw_deck_play_event_shuffle"
}
// #endregion
// #region EVENT STATES
states.vm_add_campaigner = {
inactive: "add a Campaigner.",
prompt() {
event_prompt("Add a Campaigner")
gen_action_region(game.vm.region)
},
region(r) {
push_undo()
add_campaigner(game.vm.campaigner, r)
vm_next()
}
}
function increase_player_buttons(count=1) {
log(`${game.active} +${count} BM`)
if (game.active === SUF) {
game.support_buttons = Math.min(game.support_buttons + count, MAX_SUPPORT_BUTTONS)
} else {
game.opposition_buttons = Math.min(game.opposition_buttons + count, MAX_OPPOSITION_BUTTONS)
}
}
function decrease_player_buttons(count=1) {
log(`${game.active} -${count} BM`)
if (game.active === SUF) {
game.support_buttons = Math.max(game.support_buttons - count, 0)
} else {
game.opposition_buttons = Math.max(game.opposition_buttons - count, 0)
}
}
function decrease_opponent_buttons(count=1) {
log(`${opponent_name()} -${count} BM`)
if (game.active === SUF) {
game.opposition_buttons = Math.max(game.opposition_buttons - count, 0)
} else {
game.support_buttons = Math.max(game.support_buttons - count, 0)
}
}
states.vm_receive_buttons = {
inactive: "receive buttons.",
prompt() {
event_prompt(`Receive ${pluralize(game.vm.count, 'button')}`)
gen_action("next")
},
next() {
push_undo()
increase_player_buttons(game.vm.count)
vm_next()
}
}
states.vm_spend_buttons = {
inactive: "spend buttons.",
prompt() {
event_prompt(`Spend ${pluralize(game.vm.count, 'button')}`)
gen_action("next")
},
next() {
push_undo()
decrease_player_buttons(game.vm.count)
vm_next()
}
}
states.vm_opponent_loses_buttons = {
inactive: "make you lose buttons.",
prompt() {
event_prompt(`Opponent loses ${pluralize(game.vm.count, 'button')}`)
gen_action("next")
},
next() {
push_undo()
decrease_opponent_buttons(game.vm.count)
vm_next()
}
}
function goto_vm_add_cubes() {
game.state = "vm_add_cubes"
if (game.vm.cubes === PURPLE_OR_YELLOW) {
game.vm.cube_color = 0
} else {
game.vm.cube_color = game.vm.cubes
}
game.vm.added = []
filter_us_states(game.vm.us_states)
if (!game.vm.us_states.length)
vm_next()
}
states.vm_add_cubes = {
inactive: "add a cube.",
prompt() {
if (game.vm.cubes === PURPLE_OR_YELLOW) {
view.actions.purple = (game.vm.cube_color !== PURPLE)
view.actions.yellow = (game.vm.cube_color !== YELLOW)
// Alternatively allow a click on a campaigner to switch color
for_each_player_campaigner(c => {
if (game.vm.cube_color !== campaigner_color(c))
gen_action_campaigner(c)
})
}
let has_opponent_cubes = false
for (let s of game.vm.us_states) {
if (opponent_cubes(s)) {
has_opponent_cubes = true
if (game.active === SUF) {
gen_action_red_cube(s)
} else {
if (purple_cubes(s))
gen_action_purple_cube(s)
if (yellow_cubes(s))
gen_action_yellow_cube(s)
}
} else if (game.vm.cube_color) {
gen_action_us_state(s)
}
}
if (!game.vm.cube_color) {
if (!has_opponent_cubes)
event_prompt("Choose a cube color to add.")
else
event_prompt("Choose a cube color to add or remove an Opponent's cube.")
} else {
if (!has_opponent_cubes)
event_prompt(`Add a ${COLOR_NAMES[game.vm.cube_color]} cube.`)
else
event_prompt(`Add a ${COLOR_NAMES[game.vm.cube_color]} cube or remove an Opponent's cube.`)
}
},
purple() {
game.vm.cube_color = PURPLE
},
yellow() {
game.vm.cube_color = YELLOW
},
campaigner(c) {
game.vm.cube_color = campaigner_color(c)
},
purple_cube(s) {
push_undo()
remove_cube(PURPLE, s)
after_vm_add_cube(s)
},
yellow_cube(s) {
push_undo()
remove_cube(YELLOW, s)
after_vm_add_cube(s)
},
red_cube(s) {
push_undo()
remove_cube(RED, s)
after_vm_add_cube(s)
},
us_state(s) {
push_undo()
add_cube(game.vm.cube_color, s)
after_vm_add_cube(s)
}
}
function claim_states_card(us_state) {
for (let c of game.states_draw) {
if (US_STATES[us_state].name === CARDS[c].name) {
array_remove_item(game.states_draw, c)
player_claimed().push(c)
log(`Claimed C${c}.`)
return
}
}
}
function on_4th_cube(us_state) {
// claim state cards when 4 cubes have been added
claim_states_card(us_state)
if (game.nineteenth_amendment) {
// replace cubes with checks / Xs
if (game.active === SUF) {
ratify_nineteenth_amendment(us_state)
} else {
reject_nineteenth_amendment(us_state)
}
}
}
function after_vm_add_cube(us_state) {
if (player_cubes(us_state) === 4) {
on_4th_cube(us_state)
if (game.nineteenth_amendment)
set_delete(game.vm.us_states, us_state)
if (check_victory())
return true
}
map_incr(game.vm.added, us_state, 1)
if (game.vm.in_one_state_of_each_region) {
for (let other of region_us_states(us_state_region(us_state)))
if (us_state !== other)
set_delete(game.vm.us_states, other)
}
if (game.vm.per_state_in_any_one_region && map_get(game.vm.added, us_state) === 1) {
// only need to do this for the the first cube in the state
set_filter(game.vm.us_states, s => us_state_region(us_state) === us_state_region(s))
}
if (game.vm.limit) {
if (map_get(game.vm.added, us_state) === game.vm.limit)
set_delete(game.vm.us_states, us_state)
if (map_count(game.vm.added) === game.vm.count)
return vm_next()
} else {
if (map_get(game.vm.added, us_state) === game.vm.count)
set_delete(game.vm.us_states, us_state)
}
if (!game.vm.us_states.length)
vm_next()
}
function goto_vm_remove_cubes() {
game.state = "vm_remove_cubes"
game.vm.removed = []
}
states.vm_remove_cubes = {
inactive: "remove a cube.",
prompt() {
event_prompt(`Remove a ${COLOR_NAMES[game.vm.cubes]} cube.`)
for (let s of game.vm.us_states) {
if ((game.vm.cubes === PURPLE || game.vm.cubes === PURPLE_OR_YELLOW) && purple_cubes(s))
gen_action_purple_cube(s)
if ((game.vm.cubes === YELLOW || game.vm.cubes === PURPLE_OR_YELLOW) && yellow_cubes(s))
gen_action_yellow_cube(s)
if (game.vm.cubes === RED && red_cubes(s))
gen_action_red_cube(s)
}
},
purple_cube(s) {
push_undo()
remove_cube(PURPLE, s)
after_vm_remove_cube(s)
},
yellow_cube(s) {
push_undo()
remove_cube(YELLOW, s)
after_vm_remove_cube(s)
},
red_cube(s) {
push_undo()
remove_cube(RED, s)
after_vm_remove_cube(s)
}
}
function after_vm_remove_cube(us_state) {
map_incr(game.vm.removed, us_state, 1)
if (game.vm.all) {
if (map_key_count(game.vm.removed) === game.vm.limit) {
// remove all other states from eligible list when we reached our limit
set_filter(game.vm.us_states, s => map_has(game.vm.removed, s))
}
if (!color_cubes(game.vm.cubes, us_state)) {
set_delete(game.vm.us_states, us_state)
if (game.vm.limit && map_key_count(game.vm.removed) === game.vm.limit)
return vm_next()
}
} else {
if (!color_cubes(game.vm.cubes, us_state) || map_get(game.vm.removed, us_state) === game.vm.limit)
set_delete(game.vm.us_states, us_state)
if (map_count(game.vm.removed) === game.vm.count)
return vm_next()
}
if (!game.vm.us_states.length)
vm_next()
}
function goto_vm_replace() {
game.state = "vm_replace"
game.vm.removed = []
}
states.vm_replace = {
inactive: "do a replacement",
prompt() {
if (game.vm.replacement !== GREEN_CHECK && game.vm.replacement !== RED_X) {
event_prompt(`Replace a ${COLOR_NAMES[game.vm.what]} with ${pluralize(game.vm.count, COLOR_NAMES[game.vm.replacement] + ' cube')}.`)
} else {
event_prompt(`Replace a ${COLOR_NAMES[game.vm.what]} with ${COLOR_NAMES[game.vm.replacement]}.`)
}
for (let s of game.vm.us_states) {
if (game.vm.what === GREEN_CHECK && is_green_check(s))
gen_action_green_check(s)
if (game.vm.what === RED_X && is_red_x(s))
gen_action_red_x(s)
}
},
green_check(s) {
push_undo()
remove_green_check(s)
if (game.vm.replacement !== RED_X) {
game.vm.cubes = game.vm.replacement
game.vm.us_states = [s]
goto_vm_add_cubes()
} else {
reject_nineteenth_amendment(s)
vm_next()
}
},
red_x(s) {
push_undo()
remove_red_x(s)
if (game.vm.replacement !== GREEN_CHECK) {
game.vm.cubes = game.vm.replacement
game.vm.us_states = [s]
goto_vm_add_cubes()
} else {
ratify_nineteenth_amendment(s)
vm_next()
}
}
}
states.vm_add_congress = {
inactive: "add a Congressional marker.",
prompt() {
event_prompt(`Add ${pluralize(game.vm.count, 'Congressional marker')}.`)
gen_action("congress")
},
congress() {
game.congress = Math.min(game.congress + game.vm.count, 6)
log(`Congress +${game.vm.count} CM.`)
if (game.congress >= 6) {
if (trigger_nineteenth_amendment())
return
}
vm_next()
}
}
states.vm_remove_congress = {
inactive: "remove a congressional marker.",
prompt() {
event_prompt(`Remove ${pluralize(game.vm.count, 'Congressional marker')}.`)
gen_action("congress")
},
congress() {
game.congress = Math.max(game.congress - game.vm.count, 0)
log(`Congress -${game.vm.count} CM.`)
vm_next()
}
}
const DICE_COLOR = {
[D4]: "B", // blue
[D6]: "D", // red
[D8]: "W", // white
}
function roll_ndx(n, x, prefix="Rolled") {
clear_undo()
let result = 0
let summary = []
for (let i = 0; i < n; ++i) {
let roll = random(x) + 1
result += roll
summary.push(DICE_COLOR[x] + roll)
}
log(prefix + " " + summary.join(" "))
return result
}
function roll_ndx_list(n, x, prefix="Rolled") {
clear_undo()
let result = []
let summary = []
for (let i = 0; i < n; ++i) {
let roll = random(x) + 1
result.push(roll)
summary.push(DICE_COLOR[x] + roll)
}
log(prefix + " " + summary.join(" "))
return result
}
function roll_ndx_count_success(n, x, prefix="Rolled") {
clear_undo()
let result = 0
let summary = []
for (let i = 0; i < n; ++i) {
let roll = random(x) + 1
if (roll >= 6)
result += 1
summary.push(DICE_COLOR[x] + roll)
}
log(prefix + " " + summary.join(" "))
return result
}
states.vm_roll = {
inactive: "roll dice.",
prompt() {
if (game.vm.roll) {
if (game.vm.roll_list)
event_prompt(`You rolled ${game.vm.roll.join(", ")}.`)
else
event_prompt(`You rolled ${game.vm.roll}.`)
} else if (game.vm.count === 1) {
event_prompt("Roll a die.")
} else {
event_prompt("Roll dice.")
}
if (!game.vm.roll) {
gen_action("roll")
} else {
if (player_buttons() > 0 && (!game.vm.for_success || game.vm.roll < 3))
gen_action("reroll")
gen_action("next")
}
},
roll() {
if (game.vm.roll_list)
game.vm.roll = roll_ndx_list(game.vm.count, game.vm.d)
else
game.vm.roll = roll_ndx(game.vm.count, game.vm.d)
},
reroll() {
decrease_player_buttons(1)
if (game.vm.roll_list)
game.vm.roll = roll_ndx_list(game.vm.count, game.vm.d, "Re-rolled")
else
game.vm.roll = roll_ndx(game.vm.count, game.vm.d, "Re-rolled")
},
next() {
vm_next()
}
}
states.vm_select_us_state = {
inactive: "select a state.",
prompt() {
if (!game.vm.selected_us_state) {
event_prompt("Select one state.")
for (let s of anywhere()) {
gen_action_us_state(s)
}
} else {
event_prompt(`Selected ${us_state_name(game.vm.selected_us_state)}.`)
gen_action("done")
}
},
us_state(s) {
push_undo()
game.vm.selected_us_state = s
},
done() {
log(`Selected S${game.vm.selected_us_state}.`)
vm_next()
}
}
states.move_each_player_campaigner_free = {
inactive: "move a campaigner.",
prompt() {
if (!game.selected_campaigner) {
event_prompt("Select a Campaigner.")
for_each_player_campaigner(c => {
if (!set_has(game.vm.moved, c))
gen_action_campaigner(c)
})
} else {
event_prompt("Select region to move the Campaigner to.")
let current_region = campaigner_region(game.selected_campaigner)
for (let r = 1; r <= region_count; r++) {
if (r !== current_region)
gen_action_region(r)
}
}
},
campaigner(c) {
push_undo()
game.selected_campaigner = c
},
region(r) {
push_undo()
move_campaigner(game.selected_campaigner, r)
set_add(game.vm.moved, game.selected_campaigner)
delete game.selected_campaigner
if (game.vm.moved.length === count_player_active_campaigners()) {
delete game.selected_campaigner
vm_next()
}
}
}
states.vm_counter_strat = {
inactive: "remove a persistent event card.",
prompt() {
event_prompt("Select a persistent event card to discard.")
for (let c of game.persistent_turn)
gen_action_card(c)
},
card(c) {
push_undo()
discard_persistent_card(game.persistent_turn, c)
vm_next()
}
}
states.vm_draw_2_play_1_event = {
inactive: "choose which card to play.",
prompt() {
event_prompt("Select which card to play for its event.")
let can_play = false
for (let c of game.vm.draw) {
if (can_play_event(c)) {
gen_action_card(c)
can_play = true
}
}
if (!can_play)
gen_action("skip")
},
card(c) {
push_undo()
end_play_card(game.played_card)
let other = game.vm.draw.find(x => x !== c)
discard_card_from_hand(other)
log(`Discarded C${other}.`)
delete game.vm.draw
play_card_event(c)
},
skip() {
log("None of the cards could be played for their event.")
for (let c of game.vm.draw) {
discard_card_from_hand(c)
}
delete game.vm.draw
vm_next()
}
}
function goto_vm_place_any_on_top_of_draw() {
clear_undo()
game.vm.draw = []
game.selected_cards = []
let draw_count = Math.min(player_deck().length, 6)
for (let i = 0; i < draw_count; ++i) {
let card = draw_card(player_deck())
game.vm.draw.push(card)
player_hand().push(card)
}
log(`${game.active} drew ${draw_count} cards.`)
game.state = "vm_place_any_on_top_of_draw"
}
states.vm_place_any_on_top_of_draw = {
inactive: "choose which cards to put on top of their Draw Deck.",
prompt() {
let can_play = false
if (game.vm.play_one && !game.selected_cards.length) {
event_prompt("Select which card to play as Event.")
for (let c of game.vm.draw) {
if (can_play_event(c)) {
gen_action_card(c)
can_play = true
}
}
} else {
event_prompt("Select which cards to put on top of your Draw Deck.")
for (let c of game.vm.draw) {
if (!game.selected_cards.includes(c))
gen_action_card(c)
}
}
if (!game.vm.play_one || game.selected_cards.length) {
gen_action("done")
} else if (!can_play) {
gen_action("skip")
}
},
card(c) {
push_undo()
game.selected_cards.push(c)
},
skip() {
log("None of the drawn cards could be played for their Event.")
delete game.vm.play_one
},
done() {
// first selected card is the to be played event card
if (game.vm.play_one)
game.vm.play_one = game.selected_cards.shift()
log(`${game.active} selected ${pluralize(game.selected_cards.length, 'card')} to put on top of their Draw Deck.`)
// XXX does this order make sense? first selected card goes on top.
for (let c of game.selected_cards.reverse()) {
player_deck().push(c)
array_remove_item(game.vm.draw, c)
array_remove_item(player_hand(), c)
}
// rest goes to the bottom, except for the to be played event card
for (let c of game.vm.draw) {
if (c !== game.vm.play_one) {
player_deck().unshift(c)
array_remove_item(player_hand(), c)
}
}
delete game.vm.draw
game.selected_cards = []
if (game.vm.play_one) {
end_play_card(game.played_card)
play_card_event(game.vm.play_one)
} else {
vm_next()
}
}
}
states.vm_opponent_discard_2_random_draw_2 = {
inactive: "discard 2 random cards and then draw 2 cards.",
prompt() {
event_prompt("You must discard 2 random cards and then draw 2 cards.")
gen_action("next")
},
next() {
for (let c of game.selected_cards) {
discard_card_from_hand(c)
log(`Discarded C${c}.`)
}
// XXX if we could discard less than two, should we also draw less than two?
for (let i = 0; i < game.selected_cards.length; ++i) {
let card = draw_card(player_deck())
player_hand().push(card)
}
log(`${game.active} drew ${pluralize(game.selected_cards.length, 'card')}.`)
game.selected_cards = []
next_player()
vm_next()
}
}
const CAMPAIGNER_CARDS = [
1, 19, 36, 53, 71, 84, 108, 114
]
states.vm_show_opponents_hand_discard_1_draw_1 = {
inactive: "discard one card from of your hand.",
prompt() {
event_prompt("Select one card from your opponent's Hand to discard.")
let can_discard = false
for (let c of player_hand()) {
// exclude cards with campaigners on them
if (!CAMPAIGNER_CARDS.includes(c)) {
gen_action_card(c)
can_discard = true
}
}
if (!can_discard)
gen_action("skip")
},
card(c) {
restore_player_hand()
log(`Discarded C${c}.`)
array_remove_item(opponent_hand(), c)
opponent_hand().push(draw_card(opponent_deck()))
log(`${opponent_name()} drew 1 card.`)
vm_next()
},
skip() {
restore_player_hand()
log("None of the Opponent's cards could be discarded.")
vm_next()
}
}
states.vm_select_1_card_from_draw_deck_play_event_shuffle = {
inactive: "play one card from their Draw Deck as Event.",
prompt() {
event_prompt("Select one card from your Draw Deck and play for its Event.")
let can_play = false
for (let c of player_hand()) {
if (can_play_event(c)) {
gen_action_card(c)
can_play = true
}
}
if (!can_play)
gen_action("skip")
},
card(c) {
restore_player_hand()
log(`Selected C${c}.`)
player_hand().push(c)
array_remove_item(player_deck(), c)
log(`Shuffled ${game.active}'s Deck.`)
shuffle(player_deck())
end_play_card(game.played_card)
play_card_event(c)
},
skip() {
restore_player_hand()
log("None of the cards could be played for their Event.")
log(`Shuffled ${game.active}'s Deck.`)
shuffle(player_deck())
vm_next()
}
}
// #endregion
// #region LOGGING
function log(msg) {
game.log.push(msg)
}
function log_br() {
if (game.log.length > 0 && game.log[game.log.length - 1] !== "")
game.log.push("")
}
function logi(msg) {
game.log.push(">" + msg)
}
function log_h1(msg) {
log_br()
log(".h1 " + msg)
log_br()
}
function log_h2(msg) {
log_br()
log(".h2 " + msg)
log_br()
}
function log_h3(msg) {
log_br()
log(".h3 " + msg)
}
function log_round(msg) {
log_br()
if (game.active === SUF)
log(".h3.suf " + msg)
else
log(".h3.opp " + msg)
log_br()
}
function log_sep() {
log(".hr")
}
// #endregion
// #region COMMON LIBRARY
function clear_undo() {
if (game.undo.length > 0)
game.undo = []
}
function push_undo() {
let copy = {}
for (let k in game) {
let v = game[k]
if (k === "undo")
continue
else if (k === "log")
v = v.length
else if (typeof v === "object" && v !== null)
v = object_copy(v)
copy[k] = v
}
game.undo.push(copy)
}
function pop_undo() {
let save_log = game.log
let save_undo = game.undo
game = save_undo.pop()
save_log.length = game.log
game.log = save_log
game.undo = save_undo
}
function random(range) {
// An MLCG using integer arithmetic with doubles.
// https://www.ams.org/journals/mcom/1999-68-225/S0025-5718-99-00996-5/S0025-5718-99-00996-5.pdf
// m = 2**35 − 31
return (game.seed = game.seed * 200105 % 34359738337) % range
}
function shuffle(list) {
// Fisher-Yates shuffle
for (let i = list.length - 1; i > 0; --i) {
let j = random(i + 1)
let tmp = list[j]
list[j] = list[i]
list[i] = tmp
}
return list
}
// Fast deep copy for objects without cycles
function object_copy(original) {
if (Array.isArray(original)) {
let n = original.length
let copy = new Array(n)
for (let i = 0; i < n; ++i) {
let v = original[i]
if (typeof v === "object" && v !== null)
copy[i] = object_copy(v)
else
copy[i] = v
}
return copy
} else {
let copy = {}
for (let i in original) {
let v = original[i]
if (typeof v === "object" && v !== null)
copy[i] = object_copy(v)
else
copy[i] = v
}
return copy
}
}
// Array remove and insert (faster than splice)
function array_remove_item(array, item) {
let n = array.length
for (let i = 0; i < n; ++i)
if (array[i] === item)
return array_remove(array, i)
}
function array_remove(array, index) {
let n = array.length
for (let i = index + 1; i < n; ++i)
array[i - 1] = array[i]
array.length = n - 1
}
// insert item at index (faster than splice)
function array_insert(array, index, item) {
for (let i = array.length; i > index; --i)
array[i] = array[i - 1]
array[index] = item
return array
}
function array_remove_pair(array, index) {
let n = array.length
for (let i = index + 2; i < n; ++i)
array[i - 2] = array[i]
array.length = n - 2
}
function array_insert_pair(array, index, key, value) {
for (let i = array.length; i > index; i -= 2) {
array[i] = array[i-2]
array[i+1] = array[i-1]
}
array[index] = key
array[index+1] = value
}
function set_clear(set) {
set.length = 0
}
function set_has(set, item) {
let a = 0
let b = set.length - 1
while (a <= b) {
let m = (a + b) >> 1
let x = set[m]
if (item < x)
b = m - 1
else if (item > x)
a = m + 1
else
return true
}
return false
}
function set_add(set, item) {
let a = 0
let b = set.length - 1
while (a <= b) {
let m = (a + b) >> 1
let x = set[m]
if (item < x)
b = m - 1
else if (item > x)
a = m + 1
else
return set
}
return array_insert(set, a, item)
}
function set_delete(set, item) {
let a = 0
let b = set.length - 1
while (a <= b) {
let m = (a + b) >> 1
let x = set[m]
if (item < x)
b = m - 1
else if (item > x)
a = m + 1
else
return array_remove(set, m)
}
return set
}
function set_filter(set, predicate_fn) {
let hole = 0
for (let i = 0; i < set.length; i++) {
if (predicate_fn(set[i])) {
if (hole !== i)
set[hole] = set[i]
hole++
}
}
set.length = hole
}
function set_toggle(set, item) {
let a = 0
let b = set.length - 1
while (a <= b) {
let m = (a + b) >> 1
let x = set[m]
if (item < x)
b = m - 1
else if (item > x)
a = m + 1
else
return array_remove(set, m)
}
return array_insert(set, a, item)
}
function map_clear(map) {
map.length = 0
}
function map_has(map, key) {
let a = 0
let b = (map.length >> 1) - 1
while (a <= b) {
let m = (a + b) >> 1
let x = map[m<<1]
if (key < x)
b = m - 1
else if (key > x)
a = m + 1
else
return true
}
return false
}
function map_get(map, key, missing) {
let a = 0
let b = (map.length >> 1) - 1
while (a <= b) {
let m = (a + b) >> 1
let x = map[m<<1]
if (key < x)
b = m - 1
else if (key > x)
a = m + 1
else
return map[(m<<1)+1]
}
return missing
}
function map_set(map, key, value) {
let a = 0
let b = (map.length >> 1) - 1
while (a <= b) {
let m = (a + b) >> 1
let x = map[m<<1]
if (key < x)
b = m - 1
else if (key > x)
a = m + 1
else {
map[(m<<1)+1] = value
return
}
}
array_insert_pair(map, a<<1, key, value)
}
function map_incr(map, key, value) {
let a = 0
let b = (map.length >> 1) - 1
while (a <= b) {
let m = (a + b) >> 1
let x = map[m<<1]
if (key < x)
b = m - 1
else if (key > x)
a = m + 1
else {
map[(m<<1)+1] += value
return
}
}
array_insert_pair(map, a<<1, key, value)
}
function map_delete(map, item) {
let a = 0
let b = (map.length >> 1) - 1
while (a <= b) {
let m = (a + b) >> 1
let x = map[m<<1]
if (item < x)
b = m - 1
else if (item > x)
a = m + 1
else {
array_remove_pair(map, m<<1)
return
}
}
}
function map_for_each(map, f) {
for (let i = 0; i < map.length; i += 2)
f(map[i], map[i+1])
}
function map_count(map) {
let result = 0
for (let i = 0; i < map.length; i += 2)
result += map[i+1]
return result
}
function map_key_count(map) {
return map.length >> 1
}
// #endregion
// #region GENERATED EVENT CODE
const CODE = []
CODE[1] = [ // Seneca Falls Convention
[ vm_add_campaigner, PURPLE, NORTHEAST ],
[ vm_add_campaigner, YELLOW, NORTHEAST ],
[ vm_receive_buttons, 2 ],
[ vm_add_cubes, 2, PURPLE_OR_YELLOW, us_states("New York") ],
[ vm_return ],
]
CODE[2] = [ // Property Rights for Women
[ vm_persistent, REST_OF_TURN, "For the remainder of the turn, roll D6 instead of B4 when taking a Campaigning action." ],
[ vm_return ],
]
CODE[3] = [ // Frances Willard
[ vm_add_congress, 1 ],
[ vm_receive_buttons, 2 ],
[ vm_return ],
]
CODE[4] = [ // A Vindication of the Rights of Woman
[ vm_draw_2_play_1_event ],
[ vm_return ],
]
CODE[5] = [ // Union Victory
[ vm_requires_persistent, REST_OF_TURN, find_card("The Civil War") ],
[ vm_roll_for_success, 1, D6 ],
[ vm_if, ()=>(game.vm.roll >= 3) ],
[ vm_receive_buttons, 2 ],
[ vm_discard_persistent, REST_OF_TURN, find_card("The Civil War") ],
[ vm_endif ],
[ vm_return ],
]
CODE[6] = [ // Fifteenth Amendment
[ vm_requires_not_persistent, REST_OF_TURN, find_card("The Civil War") ],
[ vm_roll_for_success, 1, D6 ],
[ vm_if, ()=>(game.vm.roll >= 3) ],
[ vm_add_congress, 2 ],
[ vm_add_cubes_limit, 8, PURPLE_OR_YELLOW, anywhere(), 2 ],
[ vm_persistent, REST_OF_GAME, "" ],
[ vm_endif ],
[ vm_return ],
]
CODE[7] = [ // Reconstruction
[ vm_requires_not_persistent, REST_OF_TURN, find_card("The Civil War") ],
[ vm_requires_persistent, REST_OF_GAME, find_card("Fifteenth Amendment") ],
[ vm_add_cubes_in_each_of, 1, PURPLE_OR_YELLOW, us_states("Virginia", "North Carolina", "South Carolina", "Georgia", "Florida", "Alabama", "Mississippi", "Tennessee", "Arkansas", "Louisiana", "Texas") ],
[ vm_return ],
]
CODE[8] = [ // Petition to Congress
[ vm_add_congress, 1 ],
[ vm_add_cubes_in_one_state_of_each_region, 1, PURPLE_OR_YELLOW ],
[ vm_return ],
]
CODE[9] = [ // Lucy Stone
[ vm_receive_buttons, 1 ],
[ vm_add_cubes_in_one_state_of_each_region, 1, PURPLE_OR_YELLOW ],
[ vm_return ],
]
CODE[10] = [ // Susan B. Anthony Indicted
[ vm_receive_buttons, 1 ],
[ vm_add_cubes_in_one_state_of_each_region, 1, PURPLE_OR_YELLOW ],
[ vm_return ],
]
CODE[11] = [ // Anna Dickinson
[ vm_receive_buttons, 1 ],
[ vm_add_cubes_in_one_state_of_each_region, 1, PURPLE_OR_YELLOW ],
[ vm_return ],
]
CODE[12] = [ // Frederick Douglass
[ vm_roll, 1, D8 ],
[ vm_add_cubes_limit, ()=>(game.vm.roll), PURPLE_OR_YELLOW, region_us_states(NORTHEAST), 1 ],
[ vm_return ],
]
CODE[13] = [ // Frances Harper
[ vm_roll, 1, D8 ],
[ vm_add_cubes_limit, ()=>(game.vm.roll), PURPLE_OR_YELLOW, region_us_states(ATLANTIC_APPALACHIA), 1 ],
[ vm_return ],
]
CODE[14] = [ // The Union Signal
[ vm_receive_buttons, 1 ],
[ vm_add_cubes_in_one_state_of_each_region, 1, PURPLE_OR_YELLOW ],
[ vm_return ],
]
CODE[15] = [ // Sojourner Truth
[ vm_roll, 1, D8 ],
[ vm_add_cubes_limit, ()=>(game.vm.roll), PURPLE_OR_YELLOW, region_us_states(MIDWEST), 1 ],
[ vm_return ],
]
CODE[16] = [ // Pioneer Women
[ vm_roll, 1, D8 ],
[ vm_add_cubes_limit, ()=>(game.vm.roll), PURPLE_OR_YELLOW, region_us_states(PLAINS), 1 ],
[ vm_return ],
]
CODE[17] = [ // Women to the Polls
[ vm_add_cubes_in_each_of, 2, PURPLE_OR_YELLOW, us_states("New Jersey", "Pennsylvania", "Delaware") ],
[ vm_return ],
]
CODE[18] = [ // National Woman’s Rights Convention
[ vm_add_congress, 1 ],
[ vm_add_cubes_in_one_state_of_each_region, 1, PURPLE_OR_YELLOW ],
[ vm_return ],
]
CODE[19] = [ // National American Woman Suffrage Association
[ vm_add_campaigner, PURPLE, ATLANTIC_APPALACHIA ],
[ vm_receive_buttons, 3 ],
[ vm_return ],
]
CODE[20] = [ // Jeannette Rankin
[ vm_roll_for_success, 1, D6 ],
[ vm_if, ()=>(game.vm.roll >= 3) ],
[ vm_add_congress, 1 ],
[ vm_add_cubes, 4, PURPLE_OR_YELLOW, us_states("Montana") ],
[ vm_add_cubes_in_each_of, 2, PURPLE_OR_YELLOW, region_us_states_except(PLAINS, us_states("Montana")) ],
[ vm_endif ],
[ vm_return ],
]
CODE[21] = [ // Ida B. Wells-Barnett
[ vm_receive_buttons, 2 ],
[ vm_add_cubes, 2, PURPLE_OR_YELLOW, us_states("Illinois") ],
[ vm_add_cubes_in_each_of, 1, PURPLE_OR_YELLOW, region_us_states_except(MIDWEST, us_states("Illinois")) ],
[ vm_return ],
]
CODE[22] = [ // The Club Movement
[ vm_receive_buttons, 4 ],
[ vm_return ],
]
CODE[23] = [ // Equality League of Self-Supporting Women
[ vm_receive_buttons, 2 ],
[ vm_add_cubes_in_one_state_of_each_region, 1, PURPLE_OR_YELLOW ],
[ vm_return ],
]
CODE[24] = [ // Emmeline Pankhurst
[ vm_roll, 2, D6 ],
[ vm_add_cubes_limit, ()=>(game.vm.roll), PURPLE_OR_YELLOW, anywhere(), 2 ],
[ vm_return ],
]
CODE[25] = [ // “Debate Us, You Cowards!”
[ vm_roll, 2, D6 ],
[ vm_remove_cubes_limit, ()=>(game.vm.roll), RED, anywhere(), 2 ],
[ vm_return ],
]
CODE[26] = [ // Carrie Chapman Catt
[ vm_receive_buttons, 2 ],
[ vm_add_cubes_in_one_state_of_each_region, 1, PURPLE_OR_YELLOW ],
[ vm_return ],
]
CODE[27] = [ // Alice Paul & Lucy Burns
[ vm_roll, 2, D6 ],
[ vm_remove_cubes_limit, ()=>(game.vm.roll), RED, anywhere(), 2 ],
[ vm_return ],
]
CODE[28] = [ // Inez Milholland
[ vm_add_congress, 1 ],
[ vm_receive_buttons, 2 ],
[ vm_add_cubes_in_one_state_of_each_region, 1, PURPLE_OR_YELLOW ],
[ vm_return ],
]
CODE[29] = [ // Farmers for Suffrage
[ vm_add_cubes_in_each_of, 2, PURPLE_OR_YELLOW, us_states("Wisconsin", "Minnesota", "Iowa", "North Dakota", "South Dakota") ],
[ vm_return ],
]
CODE[30] = [ // Zitkala-Ša
[ vm_add_cubes_in_each_of, 2, PURPLE_OR_YELLOW, us_states("North Dakota", "South Dakota", "Nebraska", "Montana", "Wyoming") ],
[ vm_return ],
]
CODE[31] = [ // Helen Keller
[ vm_roll, 2, D6 ],
[ vm_add_cubes_limit, ()=>(game.vm.roll), PURPLE_OR_YELLOW, anywhere(), 2 ],
[ vm_return ],
]
CODE[32] = [ // Maria de Lopez
[ vm_receive_buttons, 2 ],
[ vm_add_cubes_in_each_of, 2, PURPLE_OR_YELLOW, us_states("California", "Nevada", "Arizona") ],
[ vm_return ],
]
CODE[33] = [ // Marie Louise Bottineau Baldwin
[ vm_persistent, REST_OF_TURN, "For the remainder of the turn, roll D6 instead of B4 when taking a Campaigning action." ],
[ vm_return ],
]
CODE[34] = [ // The West’s Awakening
[ vm_add_cubes_in_each_of, 2, PURPLE_OR_YELLOW, region_us_states(WEST) ],
[ vm_return ],
]
CODE[35] = [ // Southern Strategy
[ vm_receive_buttons, 2 ],
[ vm_add_cubes_in_each_of, 2, PURPLE_OR_YELLOW, region_us_states(SOUTH) ],
[ vm_select_strategy_card ],
[ vm_persistent, REST_OF_GAME, "" ],
[ vm_return ],
]
CODE[36] = [ // Women’s Trade Union League
[ vm_add_campaigner, YELLOW, ATLANTIC_APPALACHIA ],
[ vm_add_congress, 1 ],
[ vm_receive_buttons, 2 ],
[ vm_return ],
]
CODE[37] = [ // The Young Woman Citizen
[ vm_draw_2_play_1_event ],
[ vm_return ],
]
CODE[38] = [ // 1918 Midterm Elections
[ vm_roll_for_success, 1, D6 ],
[ vm_if, ()=>(game.vm.roll >= 3) ],
[ vm_add_congress, 3 ],
[ vm_endif ],
[ vm_return ],
]
CODE[39] = [ // Woodrow Wilson
[ vm_spend_buttons, 4 ],
[ vm_select_strategy_card ],
[ vm_return ],
]
CODE[40] = [ // Maud Wood Park
[ vm_add_congress, 2 ],
[ vm_return ],
]
CODE[41] = [ // Voter Registration
[ vm_persistent, BALLOT_BOX, "The Suffragist player rolls W8 instead of D6 during Final Voting." ],
[ vm_return ],
]
CODE[42] = [ // Processions for Suffrage
[ vm_persistent, REST_OF_TURN, "For the remainder of the turn, roll W8 instead of D6 when taking a Lobbying action. For each 6, 7 or 8 rolled, add 1 CM in Congress." ],
[ vm_return ],
]
CODE[43] = [ // Prison Tour Special
[ vm_persistent, REST_OF_TURN, "For the remainder of the turn, roll D6 instead of B4 when taking a Campaigning action." ],
[ vm_return ],
]
CODE[44] = [ // Victory Map
[ vm_add_cubes_in_each_of, 1, PURPLE_OR_YELLOW, region_us_states(WEST, PLAINS) ],
[ vm_add_cubes_in_each_of, 1, PURPLE_OR_YELLOW, us_states("Texas", "Arkansas", "Illinois", "Michigan", "New York", "Vermont") ],
[ vm_return ],
]
CODE[45] = [ // Women and World War I
[ vm_requires_persistent, REST_OF_TURN, find_card("War in Europe") ],
[ vm_add_cubes_limit, 10, PURPLE_OR_YELLOW, anywhere(), 2 ],
[ vm_return ],
]
CODE[46] = [ // Eighteenth Amendment
[ vm_roll_for_success, 1, D6 ],
[ vm_if, ()=>(game.vm.roll >= 3) ],
[ vm_add_congress, 1 ],
[ vm_receive_buttons, 2 ],
[ vm_persistent, REST_OF_GAME, "" ],
[ vm_endif ],
[ vm_return ],
]
CODE[47] = [ // Mary McLeod Bethune
[ vm_roll, 2, D8 ],
[ vm_remove_cubes_limit, ()=>(game.vm.roll), RED, anywhere(), 2 ],
[ vm_return ],
]
CODE[48] = [ // Make a Home Run for Suffrage
[ vm_roll, 2, D8 ],
[ vm_remove_cubes_limit, ()=>(game.vm.roll), RED, anywhere(), 2 ],
[ vm_return ],
]
CODE[49] = [ // Mary Church Terrell
[ vm_roll, 2, D8 ],
[ vm_add_cubes_limit, ()=>(game.vm.roll), PURPLE_OR_YELLOW, anywhere(), 2 ],
[ vm_return ],
]
CODE[50] = [ // Tea Parties for Suffrage
[ vm_add_congress, 1 ],
[ vm_receive_buttons, 4 ],
[ vm_return ],
]
CODE[51] = [ // Dr. Mabel Ping-Hua Lee
[ vm_roll, 2, D8 ],
[ vm_add_cubes_limit, ()=>(game.vm.roll), PURPLE_OR_YELLOW, anywhere(), 2 ],
[ vm_return ],
]
CODE[52] = [ // Miss Febb Wins the Last Vote
[ vm_persistent, BALLOT_BOX, "The Suffragist player wins all ties during Final Voting." ],
[ vm_return ],
]
CODE[53] = [ // The Patriarchy
[ vm_add_campaigner, RED, SOUTH ],
[ vm_receive_buttons, 4 ],
[ vm_add_cubes_in_each_of, 1, RED, region_us_states(NORTHEAST, ATLANTIC_APPALACHIA, SOUTH, MIDWEST) ],
[ vm_return ],
]
CODE[54] = [ // The Civil War
[ vm_remove_congress, 1 ],
[ vm_persistent, REST_OF_TURN, "For the remainder of the turn, the Suffragist player may not add PYC to any state in the Atlantic & Appalachia and South regions." ],
[ vm_return ],
]
CODE[55] = [ // 15th Divides Suffragists
[ vm_requires_persistent, REST_OF_GAME, find_card("Fifteenth Amendment") ],
[ vm_remove_all_cubes_up_to, PURPLE, 4 ],
[ vm_opponent_loses_buttons, 2 ],
[ vm_return ],
]
CODE[56] = [ // Senator Joseph Brown
[ vm_remove_congress, 1 ],
[ vm_add_cubes, 2, RED, us_states("Georgia") ],
[ vm_return ],
]
CODE[57] = [ // Minor v. Happersett
[ vm_roll_for_success, 1, D6 ],
[ vm_if, ()=>(game.vm.roll >= 3) ],
[ vm_remove_congress, 1 ],
[ vm_add_cubes, 2, RED, us_states("Missouri") ],
[ vm_endif ],
[ vm_return ],
]
CODE[58] = [ // Senate Rejects Suffrage Amendment
[ vm_roll_for_success, 1, D6 ],
[ vm_if, ()=>(game.vm.roll >= 3) ],
[ vm_receive_buttons, 1 ],
[ vm_remove_congress, 1 ],
[ vm_endif ],
[ vm_return ],
]
CODE[59] = [ // South Dakota Rejects Suffrage
[ vm_roll_for_success, 1, D6 ],
[ vm_if, ()=>(game.vm.roll >= 3) ],
[ vm_remove_congress, 1 ],
[ vm_add_cubes, 2, RED, us_states("South Dakota") ],
[ vm_endif ],
[ vm_return ],
]
CODE[60] = [ // Gerrymandering
[ vm_remove_all_cubes_up_to, YELLOW, 2 ],
[ vm_return ],
]
CODE[61] = [ // Border States
[ vm_add_cubes_in_each_of, 1, RED, us_states("Delaware", "Maryland", "West Virginia", "Kentucky", "Missouri") ],
[ vm_return ],
]
CODE[62] = [ // Horace Greeley
[ vm_add_cubes_in_each_of, 2, RED, us_states("New York", "Connecticut") ],
[ vm_return ],
]
CODE[63] = [ // New York Newspapers
[ vm_add_cubes_in_each_of, 2, RED, us_states("New York", "New Jersey") ],
[ vm_return ],
]
CODE[64] = [ // Senator George Vest
[ vm_remove_congress, 1 ],
[ vm_add_cubes, 2, RED, us_states("Missouri") ],
[ vm_return ],
]
CODE[65] = [ // Catharine Beecher
[ vm_roll, 1, D4 ],
[ vm_add_cubes_limit, ()=>(game.vm.roll), RED, anywhere(), 1 ],
[ vm_return ],
]
CODE[66] = [ // Progress, Not Politics
[ vm_draw_6_place_any_on_top_of_draw ],
[ vm_return ],
]
CODE[67] = [ // Southern “Hospitality”
[ vm_add_cubes_in_each_of, 1, RED, us_states("Virginia", "North Carolina", "South Carolina", "Georgia", "Tennessee") ],
[ vm_return ],
]
CODE[68] = [ // Beer Brewers
[ vm_requires_not_persistent, REST_OF_GAME, find_card("Eighteenth Amendment") ],
[ vm_persistent, REST_OF_TURN, "For the remainder of the turn, roll D6 instead of B4 when taking a Campaigning action." ],
[ vm_return ],
]
CODE[69] = [ // Southern Resentment
[ vm_requires_persistent, REST_OF_GAME, find_card("Fifteenth Amendment") ],
[ vm_add_cubes_in_each_of, 1, RED, us_states("Texas", "Louisiana", "Arkansas", "Mississippi", "Alabama") ],
[ vm_return ],
]
CODE[70] = [ // Old Dixie
[ vm_add_cubes_in_each_of, 1, RED, us_states("Louisiana", "Mississippi", "Alabama", "Georgia", "Florida") ],
[ vm_return ],
]
CODE[71] = [ // NAOWS Forms
[ vm_add_campaigner, RED, NORTHEAST ],
[ vm_receive_buttons, 2 ],
[ vm_return ],
]
CODE[72] = [ // Woman and the Republic
[ vm_draw_2_play_1_event ],
[ vm_return ],
]
CODE[73] = [ // The Ladies’ Battle
[ vm_draw_2_play_1_event ],
[ vm_return ],
]
CODE[74] = [ // Backlash to the Movement
[ vm_remove_cubes_limit, 6, PURPLE_OR_YELLOW, anywhere(), 2 ],
[ vm_return ],
]
CODE[75] = [ // Xenophobia
[ vm_remove_all_cubes_up_to, PURPLE, 1 ],
[ vm_remove_all_cubes_up_to, YELLOW, 1 ],
[ vm_return ],
]
CODE[76] = [ // “O Save Us Senators, From Ourselves”
[ vm_add_cubes_in_one_state_of_each_region, 1, RED ],
[ vm_return ],
]
CODE[77] = [ // Emma Goldman
[ vm_roll, 1, D6 ],
[ vm_add_cubes_limit, ()=>(game.vm.roll), RED, anywhere(), 1 ],
[ vm_return ],
]
CODE[78] = [ // The Great 1906 San Francisco Earthquake
[ vm_remove_all_cubes, PURPLE_OR_YELLOW, us_states("California") ],
[ vm_opponent_loses_buttons, 1 ],
[ vm_return ],
]
CODE[79] = [ // A Threat to the Ideal of Womanhood
[ vm_persistent, REST_OF_TURN, "For the remainder of the turn, the Suffragist player must spend 1 BM in order to play a card as an event." ],
[ vm_return ],
]
CODE[80] = [ // “Unwarranted, Unnecessary & Dangerous Interference”
[ vm_add_cubes_in_one_state_of_each_region, 1, RED ],
[ vm_return ],
]
CODE[81] = [ // Conservative Opposition
[ vm_persistent, REST_OF_TURN, "For the remainder of the turn, roll D6 instead of B4 when taking a Campaigning action." ],
[ vm_return ],
]
CODE[82] = [ // The SSWSC
[ vm_requires_persistent, REST_OF_GAME, find_card("Southern Strategy") ],
[ vm_receive_buttons, 2 ],
[ vm_add_cubes_limit, 6, RED, region_us_states(SOUTH), 2 ],
[ vm_return ],
]
CODE[83] = [ // Western Saloons Push Suffrage Veto
[ vm_requires_not_persistent, REST_OF_GAME, find_card("Eighteenth Amendment") ],
[ vm_add_cubes, 2, RED, us_states("Arizona") ],
[ vm_add_cubes_in_each_of, 1, RED, us_states("New Mexico", "Nevada", "Utah") ],
[ vm_return ],
]
CODE[84] = [ // Transcontinental Railroad
[ vm_move_each_player_campaigner_free ],
[ vm_campaigning_action ],
[ vm_return ],
]
CODE[85] = [ // White Supremacy and the Suffrage Movement
[ vm_requires_persistent, REST_OF_GAME, find_card("Southern Strategy") ],
[ vm_remove_all_cubes_up_to, YELLOW, 4 ],
[ vm_opponent_loses_buttons, 2 ],
[ vm_return ],
]
CODE[86] = [ // Senator John Weeks
[ vm_remove_congress, 1 ],
[ vm_add_cubes, 2, RED, us_states("New Hampshire") ],
[ vm_return ],
]
CODE[87] = [ // Senator “Cotton Ed” Smith
[ vm_remove_congress, 1 ],
[ vm_add_cubes, 2, RED, us_states("South Carolina") ],
[ vm_return ],
]
CODE[88] = [ // War in Europe
[ vm_remove_congress, 1 ],
[ vm_persistent, REST_OF_TURN, "For the remainder of the turn, the Suffragist player must spend 1 BM in order to take a Campaigning action." ],
[ vm_return ],
]
CODE[89] = [ // 1918 Pandemic
[ vm_remove_congress, 1 ],
[ vm_persistent, REST_OF_TURN, "For the remainder of the turn, the Suffragist player must spend 1 BM in order to play a card as an event." ],
[ vm_return ],
]
CODE[90] = [ // The Business of Being a Woman
[ vm_draw_2_play_1_event ],
[ vm_return ],
]
CODE[91] = [ // The Eden Sphinx
[ vm_draw_2_play_1_event ],
[ vm_return ],
]
CODE[92] = [ // Big Liquor’s Big Money
[ vm_requires_not_persistent, REST_OF_GAME, find_card("Eighteenth Amendment") ],
[ vm_persistent, REST_OF_TURN, "For the remainder of the turn, roll D6 instead of B4 when taking a Campaigning action." ],
[ vm_return ],
]
CODE[93] = [ // Red Scare
[ vm_remove_all_cubes_up_to, PURPLE, 2 ],
[ vm_return ],
]
CODE[94] = [ // Southern Women’s Rejection League
[ vm_requires_persistent, REST_OF_GAME, find_card("Southern Strategy") ],
[ vm_roll, 1, D8 ],
[ vm_add_cubes_limit, ()=>(game.vm.roll), RED, region_us_states(SOUTH), 2 ],
[ vm_return ],
]
CODE[95] = [ // United Daughters of the Confederacy
[ vm_requires_persistent, REST_OF_GAME, find_card("Southern Strategy") ],
[ vm_roll, 1, D8 ],
[ vm_add_cubes_limit, ()=>(game.vm.roll), RED, region_us_states(SOUTH), 2 ],
[ vm_return ],
]
CODE[96] = [ // Cheers to “No on Suffrage”
[ vm_requires_not_persistent, REST_OF_GAME, find_card("Eighteenth Amendment") ],
[ vm_roll, 1, D8 ],
[ vm_add_cubes_limit, ()=>(game.vm.roll), RED, anywhere(), 2 ],
[ vm_return ],
]
CODE[97] = [ // The Unnecessary Privilege
[ vm_roll, 1, D6 ],
[ vm_add_cubes_limit, ()=>(game.vm.roll), RED, anywhere(), 1 ],
[ vm_return ],
]
CODE[98] = [ // Voter Suppression
[ vm_persistent, BALLOT_BOX, "The Opposition player rolls W8 instead of D6 during Final Voting." ],
[ vm_return ],
]
CODE[99] = [ // Anti-Suffrage Riots
[ vm_opponent_discard_2_random_draw_2 ],
[ vm_return ],
]
CODE[100] = [ // American Constitutional League
[ vm_spend_buttons, 4 ],
[ vm_select_strategy_card ],
[ vm_return ],
]
CODE[101] = [ // The Woman Patriot
[ vm_receive_buttons, 3 ],
[ vm_return ],
]
CODE[102] = [ // Governor Clement’s Veto
[ vm_replace, GREEN_CHECK, 1, RED_X ],
[ vm_return ],
]
CODE[103] = [ // Senator Henry Cabot Lodge
[ vm_remove_congress, 1 ],
[ vm_add_cubes, 2, RED, us_states("Massachusetts") ],
[ vm_return ],
]
CODE[104] = [ // Senator William Borah
[ vm_remove_congress, 1 ],
[ vm_add_cubes, 2, RED, us_states("Utah") ],
[ vm_return ],
]
CODE[105] = [ // Efficient Organizing
[ vm_receive_buttons, 5 ],
[ vm_return ],
]
CODE[106] = [ // Reconsideration
[ vm_if, ()=>(game.active === SUF) ],
[ vm_replace, RED_X, 2, PURPLE_OR_YELLOW ],
[ vm_else ],
[ vm_replace, GREEN_CHECK, 2, RED ],
[ vm_endif ],
[ vm_return ],
]
CODE[107] = [ // Opposition Research
[ vm_opponent_loses_buttons, ()=>(Math.ceil(opponent_buttons()/2)) ],
[ vm_return ],
]
CODE[108] = [ // Change In Plans
[ vm_show_opponents_hand_discard_1_draw_1 ],
[ vm_return ],
]
CODE[109] = [ // Bellwether State
[ vm_select_us_state ],
[ vm_if, ()=>(game.active === SUF) ],
[ vm_remove_all_cubes, RED, ()=>(game.vm.selected_us_state) ],
[ vm_add_cubes, 4, PURPLE_OR_YELLOW, ()=>(game.vm.selected_us_state) ],
[ vm_else ],
[ vm_remove_all_cubes, PURPLE_OR_YELLOW, ()=>(game.vm.selected_us_state) ],
[ vm_add_cubes, 4, RED, ()=>(game.vm.selected_us_state) ],
[ vm_endif ],
[ vm_return ],
]
CODE[110] = [ // Superior Lobbying
[ vm_roll_list, 4, D8 ],
[ vm_if, ()=>(game.active === SUF) ],
[ vm_add_congress, ()=>(game.vm.roll.filter(x => x >= 6).length) ],
[ vm_else ],
[ vm_remove_congress, ()=>(game.vm.roll.filter(x => x >= 6).length) ],
[ vm_endif ],
[ vm_return ],
]
CODE[111] = [ // The Winning Plan
[ vm_draw_6_play_1_place_any_on_top_of_draw ],
[ vm_return ],
]
CODE[112] = [ // Regional Focus
[ vm_if, ()=>(game.active === SUF) ],
[ vm_add_cubes_per_state_in_any_one_region, 1, PURPLE_OR_YELLOW ],
[ vm_else ],
[ vm_add_cubes_per_state_in_any_one_region, 1, RED ],
[ vm_endif ],
[ vm_return ],
]
CODE[113] = [ // Eye on the Future
[ vm_select_1_card_from_draw_deck_play_event_shuffle ],
[ vm_return ],
]
CODE[114] = [ // Transportation
[ vm_move_each_player_campaigner_free ],
[ vm_campaigning_action ],
[ vm_return ],
]
CODE[115] = [ // Counter Strat
[ vm_counter_strat ],
[ vm_return ],
]
CODE[116] = [ // National Focus
[ vm_if, ()=>(game.active === SUF) ],
[ vm_add_cubes_in_one_state_of_each_region, 2, PURPLE_OR_YELLOW ],
[ vm_else ],
[ vm_add_cubes_in_one_state_of_each_region, 2, RED ],
[ vm_endif ],
[ vm_return ],
]
CODE[117] = [ // California
[ vm_draw_2_play_1_event ],
[ vm_return ],
]
CODE[118] = [ // Utah
[ vm_if, ()=>(game.active === SUF) ],
[ vm_add_cubes_limit, 6, PURPLE_OR_YELLOW, region_us_states(WEST), 2 ],
[ vm_else ],
[ vm_add_cubes_limit, 6, RED, region_us_states(WEST), 2 ],
[ vm_endif ],
[ vm_return ],
]
CODE[119] = [ // Montana
[ vm_receive_buttons, 2 ],
[ vm_return ],
]
CODE[120] = [ // Kansas
[ vm_if, ()=>(game.active === SUF) ],
[ vm_add_cubes_limit, 6, PURPLE_OR_YELLOW, region_us_states(PLAINS), 2 ],
[ vm_else ],
[ vm_add_cubes_limit, 6, RED, region_us_states(PLAINS), 2 ],
[ vm_endif ],
[ vm_return ],
]
CODE[121] = [ // Texas
[ vm_if, ()=>(game.active === SUF) ],
[ vm_add_cubes_limit, 6, PURPLE_OR_YELLOW, region_us_states(SOUTH), 2 ],
[ vm_else ],
[ vm_add_cubes_limit, 6, RED, region_us_states(SOUTH), 2 ],
[ vm_endif ],
[ vm_return ],
]
CODE[122] = [ // Georgia
[ vm_receive_buttons, 2 ],
[ vm_return ],
]
CODE[123] = [ // Illinois
[ vm_if, ()=>(game.active === SUF) ],
[ vm_add_cubes_limit, 6, PURPLE_OR_YELLOW, region_us_states(MIDWEST), 2 ],
[ vm_else ],
[ vm_add_cubes_limit, 6, RED, region_us_states(MIDWEST), 2 ],
[ vm_endif ],
[ vm_return ],
]
CODE[124] = [ // Ohio
[ vm_draw_2_play_1_event ],
[ vm_return ],
]
CODE[125] = [ // Pennsylvania
[ vm_if, ()=>(game.active === SUF) ],
[ vm_add_cubes_limit, 6, PURPLE_OR_YELLOW, region_us_states(ATLANTIC_APPALACHIA), 2 ],
[ vm_else ],
[ vm_add_cubes_limit, 6, RED, region_us_states(ATLANTIC_APPALACHIA), 2 ],
[ vm_endif ],
[ vm_return ],
]
CODE[126] = [ // Virginia
[ vm_draw_2_play_1_event ],
[ vm_return ],
]
CODE[127] = [ // New York
[ vm_if, ()=>(game.active === SUF) ],
[ vm_add_cubes_limit, 6, PURPLE_OR_YELLOW, region_us_states(NORTHEAST), 2 ],
[ vm_else ],
[ vm_add_cubes_limit, 6, RED, region_us_states(NORTHEAST), 2 ],
[ vm_endif ],
[ vm_return ],
]
CODE[128] = [ // New Jersey
[ vm_receive_buttons, 2 ],
[ vm_return ],
]
// #endregion
|