# HG changeset patch # User Neil Muller # Date 1336814602 -7200 # Node ID 4bbd4a1879f88e87ff6bdf77028ae5dcb18ae94f # Parent 32ef26f410b8dcab50f025699a21b4d930c46a25 Plagiarism! (Only be sure, please, to always call it research) diff -r 32ef26f410b8 -r 4bbd4a1879f8 gamelib/gamestate.py --- a/gamelib/gamestate.py Sat May 12 10:29:36 2012 +0200 +++ b/gamelib/gamestate.py Sat May 12 11:23:22 2012 +0200 @@ -73,9 +73,14 @@ def get_available_points(self): return self.points - len(self.cur_allocation) - def apply_mission_special(self, new_milestone=None): + def apply_mission_special(self, new_milestone=None, new_schematic=None, + new_science=None): if new_milestone: self.milestone = new_milestone + if new_schematic: + self.lab.steal_science(new_schematic) + if new_science: + self.lab.steal_science(new_science) def end_turn(self): # Attempt the missions diff -r 32ef26f410b8 -r 4bbd4a1879f8 gamelib/lab.py --- a/gamelib/lab.py Sat May 12 10:29:36 2012 +0200 +++ b/gamelib/lab.py Sat May 12 11:23:22 2012 +0200 @@ -143,6 +143,7 @@ self.new_research = get_subclasses(research.ResearchArea) self.new_schematics = get_subclasses(schematics.Schematic) self.all_science = [s for s in self.new_research + self.new_schematics] + self._stolen = [] # Track stuff we learnt by theft this turn if init_data is not None: # Load stored state. @@ -193,6 +194,10 @@ elif isinstance(science, schematics.Schematic): self.new_schematics.remove(type(science)) + def steal_science(self, science): + self._gain_science(science) + self._stolen.append(science) + def spend_points(self, things, basic_research): breakthroughs = [] @@ -202,6 +207,10 @@ assert thing.can_spend(self, 1) thing.spend_point() + # Then, gain any stolen science + breakthroughs.extend(self._stolen) + self._stolen = [] + # Next, check for schematic breakthroughs and upgrades breakthroughs.extend(self.apply_area_research([ thing for thing in things diff -r 32ef26f410b8 -r 4bbd4a1879f8 gamelib/missions.py --- a/gamelib/missions.py Sat May 12 10:29:36 2012 +0200 +++ b/gamelib/missions.py Sat May 12 11:23:22 2012 +0200 @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # vim:fileencoding=utf-8 ai ts=4 sts=4 et sw=4 -from random import randint, random +from random import randint, random, choice from gamelib.constants import SUCCESS, FAILURE, GAME_WIN, M_VALS from gamelib.schematics import cat @@ -553,3 +553,65 @@ "The news station's security is surprisingly well prepared." " Prehaps you should rethink your approach?", rep=-randint(5, 10)) + + +class RaidLab(Mission): + NAME = "Raid Rival Lab" + SHORT_DESCRIPTION = "Why not let other people work for you?" + LONG_DESCRIPTION = ( + "While clearly no match for your genius, sometimes your rivals stumble" + " onto something interesting. Surely their results can be put to" + " better use helping your plans?") + + MINIMUM_MILESTONE = "neighbourhood" + + NO_EQUIP_FAILURE = ( + "Your rival may not be the sharpest tool in the shed, but even a" + " fool invests in some defenses. You'll need to be better prepared" + " in the future.") + + def succeed(self, msg, state): + reward = choice(('schematic', 'science', + 'money', 'money', 'money', 'money', 'money', + 'nothing', 'nothing', 'nothing')) + if reward == 'nothing': + msg = msg + (" Unfortunately, not only are these people working" + " on ideas you've already covered, they're flat broke.") + raise Result(SUCCESS, msg, money=0, rep=1) + elif reward == 'money': + msg = msg + (" While their research yields nothing of interest," + " you can repurpose their funding to more worthy causes.") + raise Result(SUCCESS, msg, money=randint(1000, 2000), rep=1) + elif reward == 'schematic': + msg = msg + (" You find the plans for a new device. How did" + " these fools stumble upon this?") + raise Result(SUCCESS, msg, meoney=0, repo=randint(2, 5), + new_schematic=choice(state.lab.new_schematics)) + # New science + msg = msg + (" Their notes are most illuminating. You realise you have" + " sadly neglected research into this field.") + raise Result(SUCCESS, msg, money=0, rep=randint(2, 5), + new_science=choice(state.lab.new_research)) + + def attempt_with(self, categorised, state): + + self.use_equipment(categorised) + + if cat.DOOM in categorised: + self.fail( + "While overwhelming force is always a tempting choice," + " total destruction of the lab will not help you cause.") + + if cat.AI in categorised: + self.succeed("Your AI easily takes control of the lab's network.", + state) + + if self.combat_power(categorised) > randint(20, 40): + self.succeed( + "The resistance is stiff, but your forces prevail" + " thanks to your superior technology.", state) + else: + self.fail( + "The lab is surprisingly well defended for an operation" + " run by a total fool. You vow to return with a better" + " prepared force.")