# HG changeset patch # User Neil Muller # Date 1336644975 -7200 # Node ID 685301e35f887ad79d0eee8fa92c600ca233cee0 # Parent 7cd716328a442d065f051e56b05c9422da0d5d6f Add a minion cost to missions diff -r 7cd716328a44 -r 685301e35f88 gamelib/gamegui.py --- a/gamelib/gamegui.py Thu May 10 02:37:02 2012 +0200 +++ b/gamelib/gamegui.py Thu May 10 12:16:15 2012 +0200 @@ -130,6 +130,8 @@ def __init__(self, mission, pos, parent): self.mission = mission self.parent = parent + self.game = self.parent.game + self.minions = 0 super(MissionWidget, self).__init__(pos, '%s' % mission.NAME, font_small) selected = ImageDrawable((0, 0, self.WIDTH, self.HEIGHT), @@ -149,12 +151,15 @@ if self.mode == 'SELECTED': # unselect mission self.reset() - else: + elif self.mission.can_attempt(self.game): # select mission and equipment self.mode = 'SELECTED' self.set_state('SELECTED') + self.minions = self.mission.MINIONS_REQUIRED + self.game.minions -= self.minions + self.parent.update_labels() equip = EquipWindow(self.parent.screen, self.mission, - self.parent.game, self) + self.game, self) AddWindow.post(equip) def selected(self): @@ -166,7 +171,9 @@ def reset(self): for equip in self.equipment: # Release funds - self.parent.game.money += equip.COST + self.game.money += equip.COST + self.game.minions += self.minions + self.minions = 0 self.parent.update() self.equipment = [] self.mode = 'NORMAL' @@ -348,7 +355,9 @@ self.points = ValueLabel((10, 75), 'Available Human Resources') self.add_child(self.points) - self.money = ValueLabel((310, 75), 'Money') + self.minions = ValueLabel((310, 75), 'Minions available: ') + self.add_child(self.minions) + self.money = ValueLabel((510, 75), 'Money') self.add_child(self.money) self.milestone = ValueLabel((10, 95), 'Currently taken over') @@ -359,6 +368,7 @@ def update_labels(self): self.points.set_value(self.game.get_available_points()) self.money.set_value(self.game.money) + self.minions.set_value(self.game.minions) self.milestone.set_value(self.game.milestone) self.reputation.set_value(_lookup_reputation(self.game.reputation)) diff -r 7cd716328a44 -r 685301e35f88 gamelib/gamestate.py --- a/gamelib/gamestate.py Thu May 10 02:37:02 2012 +0200 +++ b/gamelib/gamestate.py Thu May 10 12:16:15 2012 +0200 @@ -12,6 +12,7 @@ def __init__(self, init_data=None): self.money = 1000 + self.minions = 1 self.milestone = "basement" # Will be updated on the next turn self.points = 0 @@ -34,6 +35,7 @@ def start_turn(self): # Make more flexible? self.points += 1 + M_VALS[self.milestone] * 2 + self.minions += 1 + M_VALS[self.milestone] * 2 self.turn += 1 self.cur_missions = [] self.cur_allocation = [] @@ -69,6 +71,7 @@ raise RuntimeError('Spent too many points') new_stuff = self.lab.spend_points(self.cur_allocation, self.points) self.points = 0 + self.minions = 0 # Process mission results messages = [] for result in mission_results: @@ -89,6 +92,7 @@ """Serialize the game state into a dict""" data = {} data['money'] = self.money + data['minions'] = self.minions data['reputation'] = self.reputation data['milestone'] = self.milestone data['points'] = self.points @@ -104,6 +108,7 @@ def _load_data(self, data): """Restore the game state""" self.money = data['money'] + self.minions = data['minions'] self.reputation = data['reputation'] self.points = data['points'] self.turn = data['turn'] diff -r 7cd716328a44 -r 685301e35f88 gamelib/missions.py --- a/gamelib/missions.py Thu May 10 02:37:02 2012 +0200 +++ b/gamelib/missions.py Thu May 10 12:16:15 2012 +0200 @@ -37,6 +37,7 @@ MINIMUM_REPUTATION = None MINIMUM_MILESTONE = "neighbourhood" + MINIONS_REQUIRED = 1 def __init__(self, init_data=None): self.data = {} @@ -77,6 +78,9 @@ self.MINIMUM_REPUTATION > state.reputation): # Don't have the reputation required return False + if self.MINIONS_REQUIRED > state.minions: + # Need more minions! + return False return True def attempt(self, equipment, state):