tharkad/lwotai — pull request #6 by ragram (2014-06-15 14:39:42+00:00)
Title: Two errors in lwot: "Leak" and disruption of cadres when no cells present

I hope I'm leaving this in the right place. I am new to GitHub. I am also not a python programmer but I think I have fixed two errors in the program.
1. The event for cards 84 & 85 (“Leak”) require an ally be changed to neutral. I borrowed the code from card 76 to do this.

elif self.number == 84 or self.number == 85: # Leak
possibles = []
if "Enhanced Measures" in app.markers:
possibles.append("Enhanced Measures")
if "Renditions" in app.markers:
possibles.append("Renditions")
if "Wiretapping" in app.markers:
possibles.append("Wiretapping")
target = random.choice(possibles)
app.markers.remove(target)
app.markers.append("Leak-"+target)
app.outputToHistory("%s removed and can no longer be played." % target, False)
usPrestigeRolls = []
for i in range(3):
usPrestigeRolls.append(random.randint(1,6))
postureRoll = random.randint(1,6)

presMultiplier = 1
if usPrestigeRolls[0] <= 4:
presMultiplier = -1
app.changePrestige(min(usPrestigeRolls[1], usPrestigeRolls[2]) * presMultiplier, False)
if postureRoll <= 4:
app.map["United States"].posture = "Soft"
else:
app.map["United States"].posture = "Hard"
app.outputToHistory("US Posture now %s" % app.map["United States"].posture, True)
allys = app.minorJihadInGoodFairChoice(1, True) # amended here: this starts lines copied from card 76
if not allys:
app.outputToHistory("No Allys to shift.", True)
else:
target = allys[0][0]
app.map[target].alignment = "Neutral"
app.outputToHistory("%s Alignment shifted to Neutral." % target, True)	# end lines copied from 76

2. When cadres were present without cells the disrupt operation was non-functional when Al Anbar was active. This came alive when I modified the end of the ouputToHistory function to include “, False)” . But it looked also to me like the conditions to the statement needed to be added to include the case when Al Anbar was active but “where” was not Syria or Iraq. I made those 2 changes to the handledisrupt() function.

def handleDisrupt(self, where):
numToDisrupt = 1
if "Al-Anbar" in self.markers and (where == "Iraq" or where == "Syria"):
numToDisrupt = 1
elif self.map[where].troops() >= 2 or self.map[where].posture == "Hard":
numToDisrupt = min(2, self.map[where].totalCells(False))
if self.map[where].totalCells(False) <= 0 and self.map[where].cadre > 0: # this was the original following line if "Al-Anbar" not in self.markers:
if "Al-Anbar" not in self.markers or (where != "Iraq" and where != "Syria"): # this is the new line
self.outputToHistory("* Cadre removed in %s" % where, False) # this was added to the line", False"
self.map[where].cadre = 0