# HG changeset patch # User Neil Muller # Date 1336318759 -7200 # Node ID 0849ab5304cf7e3a6e82384d0a36b06cdb4e7724 # Parent 10d3db1f1e0851ee81b6fdc0f815279a16886f49 Add more mission result codes diff -r 10d3db1f1e08 -r 0849ab5304cf gamelib/mission.py --- a/gamelib/mission.py Sun May 06 17:39:37 2012 +0200 +++ b/gamelib/mission.py Sun May 06 17:39:19 2012 +0200 @@ -3,6 +3,8 @@ from product import DoomsdayVirus, MachineGun, TeslaGun +MAJOR_SETBACK, FAILURE, SUCCESS, MAJOR_SUCCESS, GAME_WIN = range(5) + class Result(object): """Results of a mission""" @@ -37,7 +39,7 @@ """Attempt the mission with the given equipment list. Returns a result object with the results of the mission.""" - return Result(False, 0, 0, "You can't succceed at this mission") + return Result(FAILURE, 0, 0, "You can't succceed at this mission") class RansomChina(Mission): @@ -60,7 +62,7 @@ if isinstance(item, DoomsdayVirus) and \ item not in self._prior_attempts: self._prior_attempts.add(item) - return Result(True, 1000000, 1, "Trembling at the threat of" + return Result(SUCCESS, 1000000, 1, "Trembling at the threat of" " your doomsday virus, the chinese government pays the" " ransom") elif isinstance(item, DoomsdayVirus): @@ -71,7 +73,7 @@ else: failures.append("You fail to inspire fear with your %s" % item.name) - return Result(False, 0, reputation, "\n".join(failures)) + return Result(FAILURE, 0, reputation, "\n".join(failures)) class RobBank(Mission): @@ -93,15 +95,16 @@ " it's not worth wasting this on something so" " trivial") else: - return Result(True, 1000, 0, "Holding up a bank with only" - " a small vial of clear liquid. Now that is power.") + return Result(SUCCESS, 1000, 0, "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 Result(True, 1000, 0, "The threat of your weapons is" + return Result(SUCCESS, 1000, 0, "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 Result(False, 0, 0, "\n".join(failures)) + return Result(FAILURE, 0, 0, "\n".join(failures)) class DestroyMountRushmore(Mission): @@ -115,5 +118,5 @@ if not self.available: raise RuntimeError('Cannot attempt an unavailable mission') self.available = False - return Result(True, 0, 100, + return Result(SUCCESS, 0, 100, "Mount Rushmore is remarkably easy to destroy.")