Mercurial > sypikslang
changeset 33:12c33aac7684
Gate certain missions by reputation.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Sun, 06 May 2012 21:27:33 +0200 |
parents | 00aff02bc6fc |
children | 20ed2843adec |
files | gamelib/gamestate.py gamelib/missions.py gamelib/tests/repl_game.py |
diffstat | 3 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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 = []
--- 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:
--- 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)