Mercurial > sypikslang
changeset 205:d8b0f07a6dbe
boilerplate common pattern
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 12 May 2012 18:59:51 +0200 |
parents | 8d90a63895dd |
children | 2b8b6c9b71eb |
files | gamelib/missions.py |
diffstat | 1 files changed, 13 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/gamelib/missions.py Sat May 12 18:59:34 2012 +0200 +++ b/gamelib/missions.py Sat May 12 18:59:51 2012 +0200 @@ -184,6 +184,9 @@ if failure is not None: self.fail(msg % (failure,), **loot) + def use_equipment_category(self, categorised, category): + self.use_equipment({category: categorised[category]}) + class PlaygroundBully(Mission): @@ -389,8 +392,7 @@ def attempt_with(self, categorised, state): if cat.MIND_CONTROL in categorised: - self.use_equipment( - {cat.MIND_CONTROL: categorised[cat.MIND_CONTROL]}) + self.use_equipment_category(categorised, cat.MIND_CONTROL) self._succ("Your creative use of science has paid off nicely.", randint(5, 10)) @@ -490,16 +492,14 @@ rep=randint(10, 20), new_milestone='city') if cat.AI in categorised: - self.use_equipment( - {cat.AI: categorised[cat.AI]}) + self.use_equipment_category(categorised, cat.AI) self.succeed( "While the AI can't control the entire city, you can at" " least ensure the budget is well spent", money=randint(10000, 30000)) if cat.MIND_CONTROL in categorised: - self.use_equipment( - {cat.MIND_CONTROL: categorised[cat.MIND_CONTROL]}) + self.use_equipment_category(categorised, cat.MIND_CONTROL) self.succeed( "Running a city requires controlling more than just a few" " key people. Still, making the mayor dance to your tune" @@ -921,16 +921,14 @@ def attempt_with(self, categorised, state): if cat.MIND_CONTROL in categorised: - self.use_equipment( - {cat.MIND_CONTROL: categorised[cat.MIND_CONTROL]}) + self.use_equipment_category(categorised, cat.MIND_CONTROL) self.data['completed'] = True self.succeed("With the correct persuasion, the review board" " recognises the significance of your work.", rep=randint(10, 15)) if cat.HAND_WEAPON in categorised: - self.use_equipment( - {cat.HAND_WEAPON: categorised[cat.HAND_WEAPON]}) + self.use_equipment_category(categorised, cat.HAND_WEAPON) self.data['completed'] = True self.succeed("The review board respond favourably to a little" " light intidimation, and your paper is accepted.", @@ -970,16 +968,14 @@ " shelve this plan for now.") if cat.WEATHER_MACHINE in categorised: - self.use_equipment( - {cat.WEATHER_MACHINE: categorised[cat.WEATHER_MACHINE]}) + self.use_equipment_category(categorised, cat.WEATHER_MACHINE) self.succeed( "You cunningly use your device to disrupt the nearby farmers." " The ensuing panic buyng of supplies is easy to exploit for" " profit.", money=randint(5000, 10000), rep=randint(5, 15)) if cat.AI in categorised: - self.use_equipment( - {cat.AI: categorised[cat.AI]}) + self.use_equipment_category(categorised, cat.AI) self.succeed( "You easily survert the local exchange's computer systems." " It hardly seems fair to profit off such a trivial challenge" @@ -987,8 +983,7 @@ money=randint(5000, 10000), rep=randint(2, 5)) if cat.BEAST in categorised: - self.use_equipment( - {cat.BEAST: categorised[cat.BEAST]}) + self.use_equipment_category(categorised, cat.BEAST) self.succeed( "Releasing the monster into the exchange certainly created" " a stir, and there was much running and screaming, but, with" @@ -1007,16 +1002,14 @@ def attempt_with(self, categorised, state): if cat.CLONE in categorised: - self.use_equipment( - {cat.CLONE: categorised[cat.CLONE]}) + self.use_equipment_category(categorised, cat.CLONE) self.data['completed'] = True self.succeed( "Replacing the mayor with a copy under your control. Such" " a genius scheme could only come from a brain as brillant" " as yours.", rep=randint(10, 15)) if cat.MIND_CONTROL in categorised: - self.use_equipment( - {cat.MIND_CONTROL: categorised[cat.CLONE]}) + self.use_equipment_category(categorised, cat.MIND_CONTROL) self.data['completed'] = True self.succeed( "Mind control. It's hardly a novel approach to the problem"