# HG changeset patch # User Neil Muller # Date 1336303528 -7200 # Node ID 9f8def7d70d0870f79c36a09d42afc1211563f1c # Parent b132a56ae4d4cad8b7244e6de70d9bf4e95e34f7 Rework mission objects to include reputation diff -r b132a56ae4d4 -r 9f8def7d70d0 gamelib/mission.py --- a/gamelib/mission.py Sun May 06 13:08:48 2012 +0200 +++ b/gamelib/mission.py Sun May 06 13:25:28 2012 +0200 @@ -12,12 +12,14 @@ NAME = "Generic Mission" SHORT_DESCRIPTION = None LONG_DESCRIPTION = None + available = True - def attempt(self, equipment): + def attempt(self, equipment, state): """Attempt the mission with the given equipment list. - Returns a tuple (success, money, message)""" - return False, 0, "You can't succceed at this mission" + Returns a tuple (success, message). Updates the game + state with the results of the mission.""" + return False, "You can't succceed at this mission" class RansomChina(Mission): @@ -33,22 +35,25 @@ # Track prior approaches to this mission self._prior_attempts = [] - def attempt(self, equipment): + def attempt(self, equipment, state): failures = [] for item in equipment: if isinstance(item, DoomsdayVirus) and \ item not in self._prior_attempts: self._prior_attempts.add(item) - return True, 1000000, "Trembling at the threat of your " \ + state.money += 1000000 + state.reputation += 1 + return True, "Trembling at the threat of your " \ " doomsday virus, the chinese government pays the ransom" elif isinstance(item, DoomsdayVirus): + state.reputation -= 1 failures.append("'Hah, we've developed an antidote to your" " virus, doctor'. You cannot threaten us with that" " again'") else: failures.append("You fail to inspire fear with your %s" % item.name) - return False, 0, "\n".join(failures) + return False, "\n".join(failures) class RobBank(Mission): @@ -59,18 +64,40 @@ " concern. Walk in, clean out the vault, walk out. Couldn't be" \ " simpler." - def attempt(self, equipment): + def attempt(self, equipment, state): failures = [] for item in equipment: if isinstance(item, DoomsdayVirus): - failures.append("The clerk doesn't realise the threat of the" - " vial you hold, and, although watching him die in" - " agony would be statisfying, you decide it's not" - " worth wasting this on something so trivial") + if state.reputation < 10: + failures.append("The clerk doesn't realise the threat of" + " the vial you hold, and, although watching him" + " die in agony would be statisfying, you decide" + " it's not worth wasting this on something so" + " trivial") + else: + state.money + 1000 + return True, "Holding up a bank with only a small vial" \ + " of clear liquid. Now that is power." elif isinstance(item, MachineGun) or isinstance(item, TeslaGun): - return True, 1000, "The threat of your weapons is enough to" \ + state.money += 1000 + return True, "The threat of your weapons is enough to" \ " inspire an impressive level of cooperation" else: failures.append("You fail to inspire fear with your %s" % item.name) return False, 0, "\n".join(failures) + + +class DestroyMountRushmore(Mission): + + NAME = "Destroy Mount Rushmore" + SHORT_DESCRIPTION = "Monuments to other people? Intolerable" + LONG_DESCRIPTION = "While potentially expensive, destroying" \ + " major monument is a good way to secure your reputation." + + def attempt(self, equipment, state): + if not self.available: + return True, "You send a team to kick over the rubble." + self.available = False + state.reputation += 100 + return True, "Mount Rushmore is remarkably easy to destroy."