changeset 96:50f8476aa929

Some milestones.
author Jeremy Thurgood <firxen@gmail.com>
date Wed, 09 May 2012 21:43:04 +0200
parents 0f437e0584f7
children 069a2d34b8b5
files gamelib/constants.py gamelib/gamestate.py gamelib/missions.py
diffstat 3 files changed, 23 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/constants.py	Wed May 09 21:26:30 2012 +0200
+++ b/gamelib/constants.py	Wed May 09 21:43:04 2012 +0200
@@ -14,3 +14,7 @@
 # Result codes for UI hints
 (MAJOR_SETBACK, FAILURE, SUCCESS, MAJOR_SUCCESS, GAME_WIN, NEW_SCIENCE,
         NEW_SCHEMATIC) = range(7)
+
+# Planning to take over the:
+MILESTONES = ("basement", "neighbourhood", "city", "world")
+M_VALS = dict((name, i) for i, name in enumerate(MILESTONES))
--- a/gamelib/gamestate.py	Wed May 09 21:26:30 2012 +0200
+++ b/gamelib/gamestate.py	Wed May 09 21:43:04 2012 +0200
@@ -12,6 +12,7 @@
 
     def __init__(self, init_data=None):
         self.money = 1000
+        self.milestone = "basement"
         # Will be updated on the next turn
         self.points = 0
         self.reputation = 0
@@ -89,6 +90,7 @@
         data = {}
         data['money'] = self.money
         data['reputation'] = self.reputation
+        data['milestone'] = self.milestone
         data['points'] = self.points
         data['lab'] = self.lab.save_data()
         # Save mission state
--- a/gamelib/missions.py	Wed May 09 21:26:30 2012 +0200
+++ b/gamelib/missions.py	Wed May 09 21:43:04 2012 +0200
@@ -3,7 +3,7 @@
 
 from random import randint
 
-from gamelib.constants import SUCCESS, FAILURE, GAME_WIN
+from gamelib.constants import SUCCESS, FAILURE, GAME_WIN, M_VALS
 from gamelib.schematics import cat
 
 
@@ -34,7 +34,9 @@
     NAME = "Generic Mission"
     SHORT_DESCRIPTION = None
     LONG_DESCRIPTION = None
+
     MINIMUM_REPUTATION = None
+    MINIMUM_MILESTONE = "neighbourhood"
 
     def __init__(self, init_data=None):
         self.data = {}
@@ -66,6 +68,9 @@
 
     def can_attempt(self, state):
         """Can we currently attempt the mission"""
+        if (M_VALS[self.MINIMUM_MILESTONE] > M_VALS[state.milestone]):
+            # Our base of operations is too small
+            return False
         if self.get_data('completed'):
             return False
         if (self.MINIMUM_REPUTATION is not None and
@@ -118,6 +123,8 @@
         "It's not menancing, or lucrative, but when the bills are due, no one"
         " cares how you earn the money.")
 
+    MINIMUM_MILESTONE = "basement"
+
     def attempt(self, equipment, state):
         haul = randint(90, 110)
         return Result(SUCCESS, haul, -1, (
@@ -136,7 +143,9 @@
         " 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
+    MINIMUM_MILESTONE = "city"
 
     def _new_data(self):
         self.data['prior_attempts'] = []
@@ -185,6 +194,7 @@
         "It's a small and fairly useless country, but it's still an actual"
         " government that can be toppled. A good test bed for some of the"
         " larger toys in the armory.")
+
     MINIMUM_REPUTATION = 50
 
     def attempt_no_equipment(self, state):
@@ -216,6 +226,8 @@
         "The security guards and local police are of minor concern. Walk in,"
         " clean out the vault, walk out. Couldn't be simpler.")
 
+    MINIMUM_MILESTONE = "basement"
+
     def attempt_no_equipment(self, state):
         return Result(FAILURE, 0, 0, (
                 "Your attempt to rob the bank barehanded is unsuccessful."
@@ -275,6 +287,8 @@
         "A focused pamphlet distribution campaign will combat the lies being"
         " spread about you. Replacing them with better lies, of course.")
 
+    MINIMUM_MILESTONE = "basement"
+
     SUCCESS_MESSAGE = (
         "A small army of urchins delivers thousands of cheaply printed"
         " pamphlets. %s")
@@ -312,11 +326,9 @@
         "Someone has to rule the world and if it's not you it'd just be"
         " someone less well qualified -- and that would be worse for"
         " everyone.")
+
     MINIMUM_REPUTATION = 200
-
-    SUCCESS_MESSAGE = (
-        "A small army of urchins delivers thousands of cheaply printed"
-        " pamphlets. %s")
+    MINIMUM_MILESTONE = "city"
 
     def attempt_no_equipment(self, state):
         return Result(FAILURE, 0, 0, "It's going to take more than your bare"