-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathlwotai.py
6696 lines (6314 loc) · 306 KB
/
lwotai.py
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
"""
LWOTai - A Python implementation of the Single-Player AI for Labyrinth: the War on Terror by GMT Games.
Mike Houser, 2011
Thanks to Dave Horn for implementing the Save and Undo system.
1. A save game is created after every single command whether you want it or not. If someone screws up and closes the
window, PC battery dies, crashes, whatever, no problem, load it up again and you will be asked if you want to load
the suspended game.
2. Rollback files are created at the beginning of each turn. You can roll back to any previous turn using the 'roll' or
'rollback' command. You will be prompted to enter the turn to which you want to roll back.
3. An undo file is created after every card played. The player can undo to the last card at any time (with two
exceptions) by typing 'undo'. The exceptions are:
- when you load from a previously suspended game, or
- after executing a rollback. The undo file is removed at that exact point, to prevent the player from undoing
themselves to some other game from the past!
Thanks to Peter Shaw for implementing the Adjust system and for a bunch of bug fixes and cleanup.
"""
# Change indicated by comment with 20150616PS:
# 1. Made use of CTR consistent - was adding CRT but testing for CTR (reported by Morten Kristensen)
#
# Change indicated by comment with 20150312PS:
# 1. Fixed missing line for card 102 (reported by Thomas Chipman)
#
# Change indicated by comment with 20150303PS:
# 1. Prevent double processing when major jihad failure sets besieged status (reported by Magnus Kvevlander)
#
# Changes indicated by comment with 20150131PS:
# 1. Fixed spelling of besieged in Country class
# 2. Added untested countries with data to 'status' command so that 'status' can be used to reconstruct the board
# 3. Fixed 'help dep'
# 4. Added valid global markers, country markers and lapsing markers for use by 'adjust' command
# 5. Added 'adjust' command for ideology, prestige, funding, event markers, lapsing markers and country data
# 6. Additional changes for multiple aid markers when adding or removing
# 7. In plot resolution, remove one aid for each successful roll
# 8. In WOI roll adjustment, add 1 to modifiers for each aid marker
# 9. Ignore "The door of Itjihad is closed" when checking playable if playing as US (reported by Dave Horn)
# 10. Changed removeCell to remove sleeper then Sadr then active if playing as US; but active then sleeper then Sadr if Jihadist
# 11. Fixed test for infectious ideology when setting difficulty
# 12. Added 'summary' command to display state of each track
# 13. Changed message if no Islamist Rule countries at 'turn'
# 14. Changed message when card 1 event activated
import cmd
import os.path
import random
import sys
try:
import cPickle as pickle
except:
import pickle
SUSPEND_FILE = "suspend.lwot"
UNDO_FILE = "undo.lwot"
ROLLBACK_FILE = "turn."
RELEASE = "1.06162015.1"
class Utils:
def __init__(self):
pass
@staticmethod
def require_type_or_none(value, required_type):
"""
Asserts that the given value is either of the given type or is None
:param value: the value to check
:param required_type: the required type
:return: the checked value
"""
if value is None:
return value
return Utils.require_type(value, required_type)
@staticmethod
def require_type(value, required_type):
"""
Asserts that the given value is of the given type
:param value: the value to check
:param required_type: the required type
:return: the checked value
"""
assert isinstance(value, required_type)
return value
@staticmethod
def count(iterable, predicate):
"""
Counts the items in the given iterable that match the given predicate
:param iterable the iterable to filter
:param predicate a function that takes one item and returns a boolean
"""
return sum(1 for item in iterable if predicate(item))
class Alignment:
"""
The alignment of a country relative to the US.
:param name the display name of this alignment
"""
def __init__(self, name):
self.__name = Utils.require_type(name, str)
def __repr__(self):
return self.__name
def __str__(self):
return self.__name
def __eq__(self, other):
if isinstance(other, self.__class__):
return self.__name == other.__name
return False
def __ne__(self, other):
return not self.__eq__(other)
# The possible alignments (or None)
# noinspection PyGlobalUndefined
class Alignments:
def __init__(self):
pass
global ADVERSARY, ALLY, NEUTRAL
ADVERSARY = Alignment("Adversary")
ALLY = Alignment("Ally")
NEUTRAL = Alignment("Neutral")
class Randomizer:
"""Picks things at random"""
def __init__(self):
pass
def pick(self, quantity, candidates):
"""Picks the given quantity of items from the given list of candidates (returns a list)"""
assert quantity <= len(candidates)
new_list = list(candidates)
random.shuffle(new_list)
return new_list[0:quantity]
def pick_one(self, candidates):
"""Picks the one item from the given list of candidates (returns the item)"""
return self.pick(1, candidates)[0]
def roll_d6(self, times):
"""Returns the result of rolling a six-sided die the given number of
times (returns a list of that size containing numbers from 1 to 6)"""
return [self.pick_one(range(1, 7)) for index in range(times)]
class Governance:
def __init__(self, name, max_success_roll, levels_above_poor):
self.__name = Utils.require_type(name, str)
self.__max_success_roll = Utils.require_type(max_success_roll, int)
self.__levels_above_poor = levels_above_poor
def __eq__(self, other):
return isinstance(other, self.__class__) and other.__name == self.__name
def __ne__(self, other):
return not self.__eq__(other)
def __repr__(self):
return 'Governance("{}", {}, {})'.format(self.__name, self.__max_success_roll, self.__levels_above_poor)
def __str__(self):
return self.__name
def max_success_roll(self):
return self.__max_success_roll
def __hash__(self):
return self.max_success_roll()
def is_success(self, roll):
return roll <= self.max_success_roll()
def set_next_better_and_worse(self, next_better, next_worse):
self.__next_better = Utils.require_type_or_none(next_better, Governance)
self.__next_worse = Utils.require_type_or_none(next_worse, Governance)
def improve(self):
if self.__next_better is None:
return self
return self.__next_better
def worsen(self):
if self.__next_worse is None:
return self
return self.__next_worse
def is_better_than(self, other):
return self.__max_success_roll < other.__max_success_roll
def is_worse_than(self, other):
return self.__max_success_roll > other.__max_success_roll
def levels_above_poor(self):
return self.__levels_above_poor
def min_us_ops(self):
return self.__max_success_roll
# The possible Governances (or None)
class Governances:
def __init__(self):
pass
global GOOD, FAIR, POOR, ISLAMIST_RULE
GOOD = Governance("Good", 1, 2)
FAIR = Governance("Fair", 2, 1)
POOR = Governance("Poor", 3, 0)
ISLAMIST_RULE = Governance("Islamist Rule", 4, -1)
# The relative values of governances
GOOD.set_next_better_and_worse(None, FAIR)
FAIR.set_next_better_and_worse(GOOD, POOR)
POOR.set_next_better_and_worse(FAIR, None) # Islamist Rule requires revolution
__values = {
0: None,
1: GOOD,
2: FAIR,
3: POOR,
4: ISLAMIST_RULE
}
@classmethod
def with_index(cls, index):
try:
return cls.__values[index]
except KeyError:
raise ValueError("Invalid governance value - {}".format(index))
class Country:
__alignment = None
__governance = None
app = None
name = ""
type = ""
posture = ""
schengen = False
recruit = 0
troopCubes = 0
activeCells = 0
sleeperCells = 0
oil = False
resources = 0
links = []
markers = []
schengenLink = False
aid = 0
besieged = 0 #20150131PS - fixed spelling
regimeChange = 0
cadre = 0
plots = 0
def __init__(self, theApp, theName, theType, thePosture, theGovernance, theSchengen, theRecruit, no1, no2, no3, theOil, theResources):
self.app = theApp
self.name = theName
self.type = theType
self.posture = thePosture
self.make_governance(theGovernance)
self.schengen = theSchengen
self.recruit = theRecruit
self.troopCubes = 0
self.activeCells = 0
self.sleeperCells = 0
self.oil = theOil
self.resources = theResources
self.aid = 0
self.besieged = 0
self.regimeChange = 0
self.cadre = 0
self.plots = 0
self.links = []
self.markers = []
self.schengenLink = False
def alignment(self):
return self.__alignment
def is_adversary(self):
return self.__alignment == ADVERSARY
def is_ally(self):
return self.__alignment == ALLY
def is_neutral(self):
return self.__alignment == NEUTRAL
def is_aligned(self):
return self.__alignment is not None
def is_unaligned(self):
return self.__alignment is None
def make_adversary(self):
self.__alignment = ADVERSARY
def make_ally(self):
self.__alignment = ALLY
def make_neutral(self):
self.__alignment = NEUTRAL
def is_good(self):
return self.__governance == GOOD
def is_fair(self):
return self.__governance == FAIR
def is_poor(self):
return self.__governance == POOR
def is_islamist_rule(self):
return self.__governance == ISLAMIST_RULE
def is_governed(self):
return self.__governance is not None
def is_ungoverned(self):
return self.__governance is None
def make_good(self):
self.__governance = GOOD
def make_fair(self):
self.__governance = FAIR
def make_poor(self):
self.__governance = POOR
def make_islamist_rule(self):
self.__governance = ISLAMIST_RULE
def make_ungoverned(self):
self.__governance = None
def make_governance(self, governance):
self.__governance = Utils.require_type_or_none(governance, Governance)
def make_hard(self):
"""Sets a Non-Muslim country to Hard posture"""
if self.type == "Non-Muslim":
self.posture = "Hard"
def make_soft(self):
"""Sets a Non-Muslim country to Soft posture"""
if self.type == "Non-Muslim":
self.posture = "Soft"
def remove_posture(self):
"""Removes any posture from a Non-Muslim country"""
if self.type == "Non-Muslim":
self.posture = ""
def remove_plot_marker(self):
"""Removes one plot marker from this country, if any are present"""
if self.plots > 0:
self.plots -= 1
def is_non_recruit_success(self, roll):
return self.is_governed() and self.__governance.is_success(roll)
def is_recruit_success(self, roll, recruit_override = None):
max_recruit_roll = self.max_recruit_roll(recruit_override)
return max_recruit_roll is not None and roll <= max_recruit_roll
def improve_governance(self):
self.__governance = self.__governance.improve()
if self.is_good():
self.regimeChange = 0
self.aid = 0
self.besieged = 0
def worsenGovernance(self):
self.__governance = self.__governance.worsen()
def governance_is_better_than(self, governance):
return self.__governance is not None and self.__governance.is_better_than(governance)
def governance_is_worse_than(self, governance):
return self.__governance is not None and self.__governance.is_worse_than(governance)
def is_muslim(self):
return self.type == "Suni" or self.type == "Shia-Mix"
def is_major_jihad_possible(self, ops, excess_cells_needed, bhutto_in_play):
if self.is_islamist_rule():
return False
if not self.is_muslim():
return False
if bhutto_in_play and self.name == "Pakistan":
return False
if self.totalCells(True) - self.troops() < excess_cells_needed:
return False
ops_needed_from_poor = 1 if self.besieged else 2
ops_needed = ops_needed_from_poor + self.__governance.levels_above_poor()
return ops >= ops_needed
def can_recruit(self, madrassas):
return (self.totalCells(True) > 0 or
self.cadre > 0 or
(madrassas and self.governance_is_worse_than(FAIR)))
def is_regime_change(self):
return self.regimeChange > 0
def is_disruptable(self):
return (
(self.totalCells() > 0 or self.cadre > 0) and
(self.is_ally() or self.troops() >= 2 or self.type == "Non-Muslim")
)
def get_disrupt_summary(self):
postureStr = ""
troopsStr = ""
if self.type == "Non-Muslim":
postureStr = ", Posture %s" % self.posture
else:
troopsStr = ", Troops: %d" % self.troops()
return "%s - %d Active Cells, %d Sleeper Cells, %d Cadre, Ops Reqd %d%s%s" % (self.name, self.activeCells,
self.sleeperCells, self.cadre, self.__governance.min_us_ops(), troopsStr, postureStr)
def max_recruit_roll(self, recruit_override = None):
if recruit_override:
return recruit_override
if self.recruit > 0:
return self.recruit
if self.is_governed():
return self.__governance.max_success_roll()
return None
def governance_as_funding(self):
return self.__governance.max_success_roll()
def get_recruit_score(self, ops):
if self.is_regime_change() and self.troops() - self.totalCells(True) >= 5:
return 100000000
if self.is_islamist_rule() and self.totalCells(True) < 2 * ops:
return 10000000
if not self.is_islamist_rule() and not self.is_regime_change():
return self.max_recruit_roll() * 1000000
return None
def totalCells(self, includeSadr = False):
total = self.activeCells + self.sleeperCells
if includeSadr and "Sadr" in self.markers:
total += 1
return total
def numActiveCells(self):
total = self.activeCells
if "Sadr" in self.markers:
total += 1
return total
def reduce_aid_by(self, aid_lost):
"""Reduces the level of aid by the given amount, but not below zero"""
self.aid = max(self.aid - aid_lost, 0)
def removeActiveCell(self):
self.activeCells -= 1
if self.activeCells < 0: #20150131PS - changed from <= to <
if "Sadr" in self.markers:
self.markers.remove("Sadr")
self.app.outputToHistory("Sadr removed from %s" % self.name, False)
self.activeCells = 0 # 20150131PS - added
return
else:
self.activeCells = 0
self.app.outputToHistory("Active cell Removed to Funding Track", False)
self.app.cells += 1
def troops(self):
troopCount = self.troopCubes
if "NATO" in self.markers:
troopCount += 2
return troopCount
def changeTroops(self, delta):
self.troopCubes += delta
if self.troopCubes < 0:
if "NATO" in self.markers:
self.markers.remove("NATO")
self.app.outputToHistory("NATO removed from %s" % self.name, True)
self.troopCubes = 0
def govStr(self):
if self.is_ungoverned():
return "Untested"
return str(self.__governance)
@staticmethod
def typePretty(theType):
if theType == "Non-Muslim":
return "NM"
elif theType == "Suni":
return "SU"
elif theType == "Shia-Mix":
return "SM"
else:
return "IR"
def countryStr(self):
markersStr = ""
if len(self.markers) != 0:
markersStr = "\n Markers: %s" % ", ".join(self.markers)
if self.type == "Shia-Mix" or self.type == "Suni":
return "%s, %s %s, %d Resource(s)\n Troops:%d Active:%d Sleeper:%d Cadre:%d Aid:%d Besieged:%d Reg Ch:%d Plots:%d %s" % (self.name, self.govStr(), self.__alignment, self.app.countryResources(self.name), self.troops(), self.activeCells, self.sleeperCells, self.cadre, self.aid, self.besieged, self.regimeChange, self.plots, markersStr)
elif self.name == "Philippines":
return "%s - Posture:%s\n Troops:%d Active:%d Sleeper:%d Cadre:%d Plots:%d %s" % (self.name, self.posture, self.troops(), self.activeCells, self.sleeperCells, self.cadre, self.plots, markersStr)
elif self.type == "Non-Muslim" and self.type != "United States": # 20150131PS This is illogical but does no harm
return "%s - Posture:%s\n Active:%d Sleeper:%d Cadre:%d Plots:%d %s" % (self.name, self.posture, self.activeCells, self.sleeperCells, self.cadre, self.plots, markersStr)
elif self.type == "Iran":
return "%s, %s\n Active:%d Sleeper:%d Cadre:%d Plots:%d %s" % (self.name, self.govStr(), self.activeCells, self.sleeperCells, self.cadre, self.plots, markersStr)
def printCountry(self):
print self.countryStr()
class Card:
number = 0
name = ""
type = ""
ops = 0
remove = False
mark = False
lapsing = False
def __init__(self, number, card_type, name, ops, remove, mark, lapsing):
self.number = number
self.name = name
self.type = card_type
self.ops = ops
self.remove = remove
self.mark = mark
self.lapsing = lapsing
def playable(self, side, app, ignoreItjihad):
if self.type == "US" and side == "Jihadist":
return False
elif self.type == "Jihadist" and side == "US":
return False
elif self.type == "US" and side == "US":
if self.number == 1: # Backlash
for country in app.map:
if (app.map[country].type != "Non-Muslim") and (app.map[country].plots > 0):
return True
return False
elif self.number == 2: # Biometrics
return True
elif self.number == 3: # CTR 20150616PS
return app.map["United States"].posture == "Soft"
elif self.number == 2: # Biometrics
return True
elif self.number == 4: # Moro Talks
return True
elif self.number == 5: # NEST
return True
elif self.number == 6 or self.number == 7 : # Sanctions
return "Patriot Act" in app.markers
elif self.number == 8 or self.number == 9 or self.number == 10: # Special Forces
for country in app.map:
if app.map[country].totalCells(True) > 0:
for subCountry in app.map:
if country == subCountry or app.isAdjacent(subCountry, country):
if app.map[subCountry].troops() > 0:
return True
return False
elif self.number == 11: # Abbas
return True
elif self.number == 12: # Al-Azhar
return True
elif self.number == 13: # Anbar Awakening
return (app.map["Iraq"].troops() > 0) or (app.map["Syria"].troops() > 0)
elif self.number == 14: # Covert Action
for country in app.map:
if app.map[country].is_adversary():
return True
return False
elif self.number == 15: # Ethiopia Strikes
return (app.map["Somalia"].is_islamist_rule()) or (app.map["Sudan"].is_islamist_rule())
elif self.number == 16: # Euro-Islam
return True
elif self.number == 17: # FSB
return True
elif self.number == 18: # Intel Community
return True
elif self.number == 19: # Kemalist Republic
return True
elif self.number == 20: # King Abdullah
return True
elif self.number == 21: # Let's Roll
allyGoodPlotCountries = 0
for country in app.map:
if app.map[country].plots > 0:
if app.map[country].is_ally() or app.map[country].is_good():
allyGoodPlotCountries += 1
return allyGoodPlotCountries > 0
elif self.number == 22: # Mossad and Shin Bet
targetCells = 0
targetCells += app.map["Israel"].totalCells()
targetCells += app.map["Jordan"].totalCells()
targetCells += app.map["Lebanon"].totalCells()
return targetCells > 0
elif self.number == 23 or self.number == 24 or self.number == 25: # Predator
numMuslimCellCountries = 0
for country in app.map:
if app.map[country].totalCells(True) > 0:
if app.map[country].type == "Suni" or app.map[country].type == "Shia-Mix":
numMuslimCellCountries += 1
return numMuslimCellCountries > 0
elif self.number == 26: # Quartet
if not "Abbas" in app.markers:
return False
if app.troops <= 4:
return False
for country in app.map:
if app.isAdjacent(country, "Israel"):
if app.map[country].is_islamist_rule():
return False
return True
elif self.number == 27: # Saddam Captured
return app.map["Iraq"].troops() > 0
elif self.number == 28: # Sharia
return app.numBesieged() > 0
elif self.number == 29: # Tony Blair
return True
elif self.number == 30: # UN Nation Building
numRC = app.numRegimeChange()
return (numRC > 0) and ("Vieira de Mello Slain" not in app.markers)
elif self.number == 31: # Wiretapping
if "Leak-Wiretapping" in app.markers:
return False
for country in ["United States", "United Kingdom", "Canada"]:
if app.map[country].totalCells() > 0 or app.map[country].cadre > 0 or app.map[country].plots > 0:
return True
return False
elif self.number == 32: # Back Channel
if app.map["United States"].posture == "Hard":
return False
numAdv = app.numAdversary()
if numAdv <= 0:
return False
app.listAdversaryCountries()
return app.getYesNoFromUser("Do you have a card with a value that exactly matches an Adversary's Resources? (y/n): ")
elif self.number == 33: # Benazir Bhutto
if "Bhutto Shot" in app.markers:
return False
if app.map["Pakistan"].is_islamist_rule():
return False
for countryObj in app.map["Pakistan"].links:
if countryObj.is_islamist_rule():
return False
return True
elif self.number == 34: # Enhanced Measures
if "Leak-Enhanced Measures" in app.markers or app.map["United States"].posture == "Soft":
return False
return app.num_disruptable() > 0
elif self.number == 35: # Hajib
return app.numIslamistRule() == 0
elif self.number == 36: # Indo-Pakistani Talks
if app.map['Pakistan'].is_good() or app.map['Pakistan'].is_fair():
return True
return False
elif self.number == 37: # Iraqi WMD
if app.map["United States"].posture == "Hard" and app.map["Iraq"].is_adversary():
return True
return False
elif self.number == 38: # Libyan Deal
if app.map["Libya"].is_poor():
if app.map["Iraq"].is_ally() or app.map["Syria"].is_ally():
return True
return False
elif self.number == 39: # Libyan WMD
if app.map["United States"].posture == "Hard" and app.map["Libya"].is_adversary() and "Libyan Deal" not in app.markers:
return True
return False
elif self.number == 40: # Mass Turnout
return app.numRegimeChange() > 0
elif self.number == 41: # NATO
return (app.numRegimeChange() > 0) and (app.gwotPenalty() >= 0)
elif self.number == 42: # Pakistani Offensive
return (app.map["Pakistan"].is_ally()) and ("FATA" in app.map["Pakistan"].markers)
elif self.number == 43: # Patriot Act
return True
elif self.number == 44: # Renditions
return (app.map["United States"].posture == "Hard") and ("Leak-Renditions" not in app.markers)
elif self.number == 45: # Safer Now
if app.numIslamistRule() > 0:
return False
for country in app.map:
if app.map[country].is_good():
if app.map[country].totalCells(True) > 0 or app.map[country].plots > 0:
return False
return True
elif self.number == 46: # Sistani
targetCountries = 0
for country in app.map:
if app.map[country].type == "Shia-Mix":
if app.map[country].regimeChange > 0:
if (app.map[country].totalCells(True)) > 0:
targetCountries += 1
return targetCountries > 0
elif self.number == 47: # The door of Itjihad was closed
return True
else:
return False
elif self.type == "Jihadist" and side == "Jihadist":
if "The door of Itjihad was closed" in app.lapsing and not ignoreItjihad:
return False
if self.number == 48: # Adam Gadahn
if app.numCellsAvailable() <= 0:
return False
return app.getYesNoFromUser("Is this the 1st card of the Jihadist Action Phase? (y/n): ")
elif self.number == 49: # Al-Ittihad al-Islami
return True
elif self.number == 50: # Ansar al-Islam
return app.map["Iraq"].governance_is_worse_than(GOOD)
elif self.number == 51: # FREs
return app.map["Iraq"].troops() > 0
elif self.number == 52: # IDEs
for country in app.map:
if app.map[country].regimeChange > 0:
if (app.map[country].totalCells(True)) > 0:
return True
return False
elif self.number == 53: # Madrassas
return app.getYesNoFromUser("Is this the 1st card of the Jihadist Action Phase? (y/n): ")
elif self.number == 54: # Moqtada al-Sadr
return app.map["Iraq"].troops() > 0
elif self.number == 55: # Uyghur Jihad
return True
elif self.number == 56: # Vieira de Mello Slain
for country in app.map:
if app.map[country].regimeChange > 0 and app.map[country].totalCells() > 0:
return True
return False
elif self.number == 57: # Abu Sayyaf
return "Moro Talks" not in app.markers
elif self.number == 58: # Al-Anbar
return "Anbar Awakening" not in app.markers
elif self.number == 59: # Amerithrax
return True
elif self.number == 60: # Bhutto Shot
return app.map["Pakistan"].totalCells() > 0
elif self.number == 61: # Detainee Release
if "GTMO" in app.lapsing or "Renditions" in app.markers:
return False
return app.getYesNoFromUser("Did the US Disrupt during this or the last Action Phase? (y/n): ")
elif self.number == 62: # Ex-KGB
return True
elif self.number == 63: # Gaza War
return True
elif self.number == 64: # Hariri Killed
return True
elif self.number == 65: # HEU
possibles = 0
if app.map["Russia"].totalCells() > 0 and "CTR" not in app.map["Russia"].markers:
possibles += 1
if app.map["Central Asia"].totalCells() > 0 and "CTR" not in app.map["Central Asia"].markers:
possibles += 1
return possibles > 0
elif self.number == 66: # Homegrown
return True
elif self.number == 67: # Islamic Jihad Union
return True
elif self.number == 68: # Jemaah Islamiya
return True
elif self.number == 69: # Kazakh Strain
return app.map["Central Asia"].totalCells() > 0 and "CTR" not in app.map["Central Asia"].markers
elif self.number == 70: # Lashkar-e-Tayyiba
return "Indo-Pakistani Talks" not in app.markers
elif self.number == 71: # Loose Nuke
return app.map["Russia"].totalCells() > 0 and "CTR" not in app.map["Russia"].markers
elif self.number == 72: # Opium
return app.map["Afghanistan"].totalCells() > 0
elif self.number == 73: # Pirates
return app.map["Somalia"].is_islamist_rule() or app.map["Yemen"].is_islamist_rule()
elif self.number == 74: # Schengen Visas
return True
elif self.number == 75: # Schroeder & Chirac
return app.map["United States"].posture == "Hard"
elif self.number == 76: # Abu Ghurayb
targetCountries = 0
for country in app.map:
if app.map[country].regimeChange > 0:
if (app.map[country].totalCells(True)) > 0:
targetCountries += 1
return targetCountries > 0
elif self.number == 77: # Al Jazeera
if app.map["Saudi Arabia"].troops() > 0:
return True
for country in app.map:
if app.isAdjacent("Saudi Arabia", country):
if app.map[country].troops() > 0:
return True
return False
elif self.number == 78: # Axis of Evil
return True
elif self.number == 79: # Clean Operatives
return True
elif self.number == 80: # FATA
return True
elif self.number == 81: # Foreign Fighters
return app.numRegimeChange() > 0
elif self.number == 82: # Jihadist Videos
return True
elif self.number == 83: # Kashmir
return "Indo-Pakistani Talks" not in app.markers
elif self.number == 84 or self.number == 85: # Leak
return ("Enhanced Measures" in app.markers) or ("Renditions" in app.markers) or ("Wiretapping" in app.markers)
elif self.number == 86: # Lebanon War
return True
elif self.number == 87 or self.number == 88 or self.number == 89: # Martyrdom Operation
for country in app.map:
if not app.map[country].is_islamist_rule():
if app.map[country].totalCells(True) > 0:
return True
return False
elif self.number == 90: # Quagmire
if app.prestige >= 7:
return False
for country in app.map:
if app.map[country].regimeChange > 0:
if app.map[country].totalCells(True) > 0:
return True
return False
elif self.number == 91: # Regional al-Qaeda
num = 0
for country in app.map:
if app.map[country].type == "Suni" or app.map[country].type == "Shia-Mix":
if app.map[country].is_ungoverned():
num += 1
return num >= 2
elif self.number == 92: # Saddam
if "Saddam Captured" in app.markers:
return False
return (app.map["Iraq"].is_poor()) and (app.map["Iraq"].is_adversary())
elif self.number == 93: # Taliban
return True
elif self.number == 94: # The door of Itjihad was closed
return app.getYesNoFromUser("Was a country tested or improved to Fair or Good this or last Action Phase.? (y/n): ")
elif self.number == 95: # Wahhabism
return True
else: # Unassociated Events
if side == "Jihadist" and "The door of Itjihad was closed" in app.lapsing and not ignoreItjihad:
return False
if self.number == 96: # Danish Cartoons
return True
elif self.number == 97: # Fatwa
return app.getYesNoFromUser("Do both sides have cards remaining beyond this one? (y/n): ")
elif self.number == 98: # Gaza Withdrawl
return True
elif self.number == 99: # HAMAS Elected
return True
elif self.number == 100: # His Ut-Tahrir
return True
elif self.number == 101: # Kosovo
return True
elif self.number == 102: # Former Soviet Union #20150312PS
return True
elif self.number == 103: # Hizballah
return True
elif self.number == 104 or self.number == 105: # Iran
return True
elif self.number == 106: # Jaysh al-Mahdi
for country in app.map:
if app.map[country].type == "Shia-Mix":
if app.map[country].troops() > 0 and app.map[country].totalCells() > 0:
return True
return False
elif self.number == 107: # Kurdistan
return True
elif self.number == 108: # Musharraf
if "Benazir Bhutto" in app.markers:
return False
return app.map["Pakistan"].totalCells() > 0
elif self.number == 109: # Tora Bora
for country in app.map:
if app.map[country].regimeChange > 0:
if app.map[country].totalCells() >= 2:
return True
return False
elif self.number == 110: # Zarqawi
return app.map["Iraq"].troops() > 0 or app.map["Syria"].troops() > 0 or app.map["Lebanon"].troops() > 0 or app.map["Jordan"].troops() > 0
elif self.number == 111: # Zawahiri
if side == "US":
if "FATA" in app.map["Pakistan"].markers:
return False
if "Al-Anbar" in app.markers:
return False
return app.numIslamistRule() == 0
else:
return True
elif self.number == 112: # Bin Ladin
if side == "US":
if "FATA" in app.map["Pakistan"].markers:
return False
if "Al-Anbar" in app.markers:
return False
return app.numIslamistRule() == 0
else:
return True
elif self.number == 113: # Darfur
return True
elif self.number == 114: # GTMO
return True
elif self.number == 115: # Hambali
possibles = ["Indonesia/Malaysia"]
for countryObj in app.map["Indonesia/Malaysia"].links:
possibles.append(countryObj.name)
for country in possibles:
if app.map[country].totalCells(True) > 0:
if app.map[country].type == "Non-Muslim":
if app.map[country].posture == "Hard":
return True
else:
if app.map[country].is_ally():
return True
elif self.number == 116: # KSM
if side == "US":
for country in app.map:
if app.map[country].plots > 0:
if app.map[country].type == "Non-Muslim" or app.map[country].is_ally():
return True
return False
else:
return True
elif self.number == 117 or self.number == 118: # Oil Price Spike
return True
elif self.number == 119: # Saleh
return True
elif self.number == 120: # US Election
return True
return False
def putsCell(self, app):
if self.number == 48: # Adam Gadahn
return True
elif self.number == 49: # Al-Ittihad al-Islami
return True
elif self.number == 50: # Ansar al-Islam
return True
elif self.number == 51: # FREs
return True
elif self.number == 52: # IDEs
return False
elif self.number == 53: # Madrassas
return True
elif self.number == 54: # Moqtada al-Sadr
return False
elif self.number == 55: # Uyghur Jihad
return True
elif self.number == 56: # Vieira de Mello Slain
return False
elif self.number == 57: # Abu Sayyaf
return True
elif self.number == 58: # Al-Anbar
return True
elif self.number == 59: # Amerithrax
return False
elif self.number == 60: # Bhutto Shot
return False
elif self.number == 61: # Detainee Release
return True
elif self.number == 62: # Ex-KGB
return False
elif self.number == 63: # Gaza War
return False
elif self.number == 64: # Hariri Killed
return False
elif self.number == 65: # HEU
return False
elif self.number == 66: # Homegrown
return True
elif self.number == 67: # Islamic Jihad Union
return True
elif self.number == 68: # Jemaah Islamiya
return True
elif self.number == 69: # Kazakh Strain
return False
elif self.number == 70: # Lashkar-e-Tayyiba
return True
elif self.number == 71: # Loose Nuke
return False
elif self.number == 72: # Opium
return True
elif self.number == 73: # Pirates
return False