# HG changeset patch # User Jeremy Thurgood # Date 1336332453 -7200 # Node ID 12c33aac76848b4c7ea511d13e455cbc0c2f4384 # Parent 00aff02bc6fc769d63ac0670feba4422218f1dd6 Gate certain missions by reputation. diff -r 00aff02bc6fc -r 12c33aac7684 gamelib/gamestate.py --- a/gamelib/gamestate.py Sun May 06 20:57:04 2012 +0200 +++ b/gamelib/gamestate.py Sun May 06 21:27:33 2012 +0200 @@ -39,6 +39,13 @@ if isinstance(x, products.Product) and x.COST <= self.money] return available + def get_available_missions(self): + """Return a list of missions we can feasibly attempt""" + available = [x for x in self.missions + if (x.MINIMUM_REPUTATION is None + or x.MINIMUM_REPUTATION <= self.reputation)] + return available + def end_turn(self): # Attempt the missions mission_results = [] diff -r 00aff02bc6fc -r 12c33aac7684 gamelib/missions.py --- a/gamelib/missions.py Sun May 06 20:57:04 2012 +0200 +++ b/gamelib/missions.py Sun May 06 21:27:33 2012 +0200 @@ -35,6 +35,7 @@ NAME = "Generic Mission" SHORT_DESCRIPTION = None LONG_DESCRIPTION = None + MINIMUM_REPUTATION = None available = True def __init__(self, init_data=None): @@ -73,6 +74,7 @@ " successfully threatening the largest country in the world" \ " are great, but the risks are significant. Without " \ "some serious firepower, the chances of success are small." + MINIMUM_REPUTATION = 100 def __init__(self, init_data=None): # Track prior approaches to this mission @@ -145,6 +147,7 @@ SHORT_DESCRIPTION = "Monuments to other people? Intolerable" LONG_DESCRIPTION = "While potentially expensive, destroying" \ " major monument is a good way to secure your reputation." + MINIMUM_REPUTATION = 20 def attempt(self, equipment, state): if not self.available: diff -r 00aff02bc6fc -r 12c33aac7684 gamelib/tests/repl_game.py --- a/gamelib/tests/repl_game.py Sun May 06 20:57:04 2012 +0200 +++ b/gamelib/tests/repl_game.py Sun May 06 21:27:33 2012 +0200 @@ -38,7 +38,7 @@ def display_missions(self): print "Missions:" self.missions = [] - for mission in self.game.missions: + for mission in self.game.get_available_missions(): self.missions.append(mission) print " %s. %s\n %s" % ( len(self.missions), mission.NAME, mission.SHORT_DESCRIPTION)