Mercurial > sypikslang
changeset 192:57bf6a5e31cb
A rival appears on the scene
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 12 May 2012 15:18:28 +0200 |
parents | 0b746c72cb5b |
children | 9e86ed5343d9 |
files | gamelib/gamegui.py gamelib/missions.py |
diffstat | 2 files changed, 105 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/gamelib/gamegui.py Sat May 12 14:56:54 2012 +0200 +++ b/gamelib/gamegui.py Sat May 12 15:18:28 2012 +0200 @@ -292,7 +292,7 @@ % mission.NAME, font_medium, (255, 255, 255)) self.add_child(title) self.description = TextBox((10, 70, 790, 20), - mission.LONG_DESCRIPTION, font_medium, (255, 255, 255)) + mission.get_description(), font_medium, (255, 255, 255)) self.add_child(self.description) self.parent = parent self.game = game
--- a/gamelib/missions.py Sat May 12 14:56:54 2012 +0200 +++ b/gamelib/missions.py Sat May 12 15:18:28 2012 +0200 @@ -85,6 +85,9 @@ def get_data(self, key): return self.data.get(key, None) + def get_description(self): + return self.LONG_DESCRIPTION + @classmethod def sanity_check(cls): pass @@ -797,3 +800,104 @@ self.fail( "Your forces prove unable to overcome the local" " defenses.") + + +class EliminateRival(Mission): + NAME = "Eliminate Dr. X." + SHORT_DESCRIPTION = "A rival. Inconcievable" + LONG_DESCRIPTION = None # We handle this one specially + MINIONS_REQUIRED = 3 + MINIMUM_MILESTONE = 'city' + MINIMUM_REPUTATION = 50 + + NO_EQUIP_FAILURE = ( + "While you'd like to tear Dr. X apart with your bare hands, you" + " do need to deal with his pathetic defenses first.") + GENERIC_FAILURE = ( + "Somehow, Dr. X has thwarted your attack. You are quite surprised.") + + def _new_data(self): + # How many times has Dr. X been beaten? + self.data['times'] = 0 + self.data['turn'] = 0 + self.data['seen'] = False + + def get_description(self): + if self.get_data('times') == 0: + return ( + "Recently, Dr. X has made some serious claims abut his" + " capabilities. While it's laughable to believe he can" + " actually back up his boasts, such statements cannot go" + " unpunished.") + elif self.get_data('times') == 1: + return ( + "Dr. X has returned. Hasn't he learnt from your previous" + " encounter? This cannot go unpunished.") + return ( + "Dr. X has once again appeared on the scene. You suspect" + " he's mixed his DNA with that of a cockroach, but, " + " regardless of the cause, this cannot be ignored.") + + def can_attempt(self, state): + if self.get_data('completed'): + # does Dr. X return? + if (state.turn > self.get_data('turn') + 2 and + randint(0, 5) < (state.turn - self.get_data('turn'))): + self.data['completed'] = False + return True + else: + return False + elif self.get_data('seen'): + # Once he's appeared, he doesn't go unless completed + return True + if super(EliminateRival, self).can_attempt(state): + self.data['seen'] = True # flag as seen + return True + return False + + def attempt_no_equipment(self, state): + self.fail(self.NO_EQUIP_FAILURE, rep=-randint(10, 15)) + + def attempt_with(self, categorised, state): + + self.use_equipment(categorised) + + if cat.DOOMSDAY_DEVICE in categorised: + self.data['completed'] = True + self.data['times'] += 1 + self.data['turn'] = state.turn + self.succeed( + "You crush Dr. X with your superior technology. He will" + " not forgot this lesson anytime soon.", + rep=randint(10, 20)) + + if cat.AI in categorised: + self.fail( + "Subverting Dr. X's network is simple enough for your AI," + " but you are annoyed to discover that the doctor places" + " little faith in computers, and there is nothing you can" + " do to foil his plans this way") + + if (cat.BEAST in categorised and + self.combat_power(categorised) > randint(40, 60)): + self.data['completed'] = True + self.data['times'] += 1 + self.data['turn'] = state.turn + self.succeed( + "Your creature destroys Dr. X's lab. He will not quickly" + " recover this setback", rep=randint(10, 20)) + + if cat.VEHICLE in categorised: + if self.combat_power(categorised) > randint(40, 60): + self.data['completed'] = True + self.data['times'] += 1 + self.data['turn'] = state.turn + self.succeed( + "Your forces easily overcome the doctor's defenses," + " but Dr. X himself escapes. You are sure, however," + " he will present no further threat to your plans.", + rep=randint(10, 20)) + else: + self.succeed("Dr. X's defenses are better than you" + " anticipated. You'll have to return with more" + " firepower.", rep=-randint(3, 7))