# HG changeset patch # User Jeremy Thurgood # Date 1336586548 -7200 # Node ID 182fce9f70b6eefccd51f9485c49372e795372b9 # Parent 9d0ad8aeb5987fbe6c2399bacd65f5e24968b57c Propaganda! Also, a fix to blueprint breakthroughs. diff -r 9d0ad8aeb598 -r 182fce9f70b6 gamelib/lab.py --- a/gamelib/lab.py Wed May 09 18:12:01 2012 +0200 +++ b/gamelib/lab.py Wed May 09 20:02:28 2012 +0200 @@ -70,9 +70,9 @@ thing.spend_point() # Next, check for schematic breakthroughs and upgrades - breakthroughs.extend(self.apply_area_research( - thing for thing in things - if isinstance(thing, research.ResearchArea))) + breakthroughs.extend(self.apply_area_research([ + thing for thing in things + if isinstance(thing, research.ResearchArea)])) # Finally, check for research breakthroughs. breakthroughs.extend(self.apply_basic_research(basic_research)) diff -r 9d0ad8aeb598 -r 182fce9f70b6 gamelib/missions.py --- a/gamelib/missions.py Wed May 09 18:12:01 2012 +0200 +++ b/gamelib/missions.py Wed May 09 20:02:28 2012 +0200 @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- # vim:fileencoding=utf-8 ai ts=4 sts=4 et sw=4 -from random import random +from random import randint from gamelib.constants import SUCCESS, FAILURE -from gamelib.schematics import HAND_WEAPON, VEHICLE, PATHOGEN, DOOMSDAY_DEVICE +from gamelib.schematics import cat class Result(object): @@ -100,7 +100,7 @@ " cares how you earn the money.") def attempt(self, equipment, state): - haul = 90 + int(random() * 20) + haul = randint(90, 110) return Result(SUCCESS, haul, -1, ( "You devote your resources to robbing kids in a playpark." " It's not the finest moment in your reign of terror, but at" @@ -137,7 +137,7 @@ " cocktail parties. But not for you. No, not for you at all.")) def attempt_with(self, categorised, state): - dooms = categorised.get(DOOMSDAY_DEVICE, []) + dooms = categorised.get(cat.DOOMSDAY_DEVICE, []) if not dooms: return Result(FAILURE, 0, -1, ( @@ -181,14 +181,14 @@ " on the way home.")) def attempt_with(self, categorised, state): - if any(c in categorised for c in (VEHICLE, HAND_WEAPON)): - return Result(SUCCESS, 5000 + int(random() * 10000), 5, ( + if any(c in categorised for c in (cat.VEHICLE, cat.HAND_WEAPON)): + return Result(SUCCESS, randint(5000, 15000), randint(3, 7), ( "The corruption and oppression continue, but at least" " the proceeds are making their way into *your*" " pockets. And you don't even have to dirty your own" " jackboots.")) - if DOOMSDAY_DEVICE in categorised: + if cat.DOOMSDAY_DEVICE in categorised: return Result(FAILURE, 0, 0, ( "Nobody seems to quite understand what it is you're" " threatening them with. Eventually you have to give up" @@ -210,22 +210,22 @@ " escape.")) def attempt_with(self, categorised, state): - loot = 500 + int(random() * 1000) + loot = randint(500, 1500) - if VEHICLE in categorised: + if cat.VEHICLE in categorised: return Result(FAILURE, 0, 0, ( "Your vehicles are impressively doom-laden, but not really" " suitable for city traffic. You intimidate the traffic" " wardens into letting you off without a fine, but by the" " time you get to the bank it's already closed.")) - if HAND_WEAPON in categorised: + if cat.HAND_WEAPON in categorised: return Result(SUCCESS, loot, 0, ( "The threat of your weapons is enough to inspire an" " impressive level of cooperation. You make off with the" " loot.")) - if PATHOGEN in categorised: + if cat.PATHOGEN in categorised: if state.reputation < 10: return Result(FAILURE, 0, 0, ( "The clerk doesn't realise the threat of" @@ -251,3 +251,40 @@ self.completed = True return Result(SUCCESS, 0, 50, ( "Mount Rushmore is remarkably easy to destroy.")) + + +class DistributePamphlets(Mission): + + NAME = "Distribute pamphlets" + SHORT_DESCRIPTION = "The populace need to be told the truth!" + LONG_DESCRIPTION = ( + "A focused pamphlet distribution campaign will combat the lies being" + " spread about you. Replacing them with better lies, of course.") + + SUCCESS_MESSAGE = ( + "A small army of urchins delivers thousands of cheaply printed" + " pamphlets. %s") + + def attempt_no_equipment(self, state): + rep = randint(-2, 5) + + if rep < 0: + result = ( + "Sadly, the populace was so annoyed by the flood of flyers" + " that nobody took any notice of the content.") + elif rep == 0: + result = "Nobody seems to have noticed." + else: + result = "The public seemed mildly receptive to your propaganda." + + return Result(SUCCESS, 0, rep, self.SUCCESS_MESSAGE % (result,)) + + def attempt_with(self, categorised, state): + rep = randint(5, 10) + + if cat.MIND_CONTROL in categorised: + result = ( + "Your creative use of science has paid off nicely.") + return Result(SUCCESS, 0, rep, self.SUCCESS_MESSAGE % (result,)) + else: + return self.attempt_no_equipment(state) diff -r 9d0ad8aeb598 -r 182fce9f70b6 gamelib/schematics.py --- a/gamelib/schematics.py Wed May 09 18:12:01 2012 +0200 +++ b/gamelib/schematics.py Wed May 09 20:02:28 2012 +0200 @@ -4,11 +4,18 @@ from gamelib.game_base import Science -# Kinds of schematic. -HAND_WEAPON = 'hand weapon' -VEHICLE = 'vehicle' -DOOMSDAY_DEVICE = 'doomsday device' -PATHOGEN = 'pathogen' +class SchematicCategorySet(object): + def __init__(self, *categories): + for cat in categories: + setattr(self, cat, cat.lower().replace('_', ' ')) + +cat = SchematicCategorySet( + 'HAND_WEAPON', + 'VEHICLE', + 'DOOMSDAY_DEVICE', + 'PATHOGEN', + 'MIND_CONTROL', + ) class Schematic(Science): @@ -51,9 +58,9 @@ class MachineGun(Schematic): - NAME = "Machine gun" + NAME = "machine gun" COST = 100 - CATEGORIES = (HAND_WEAPON,) + CATEGORIES = (cat.HAND_WEAPON,) STARTING_PRODUCT = True def __init__(self, points=0): @@ -67,27 +74,36 @@ class LightningGun(Schematic): - NAME = "Lightning gun" + NAME = "lightning gun" COST = 300 - CATEGORIES = (HAND_WEAPON,) + CATEGORIES = (cat.HAND_WEAPON,) PREREQUISITES = ( (research.Tesla, 1), ) class TeslaTank(Schematic): - NAME = "Tesla tank" + NAME = "tesla tank" COST = 1000 - CATEGORIES = (VEHICLE,) + CATEGORIES = (cat.VEHICLE,) PREREQUISITES = ( (research.Tesla, 3), ) class DoomsdayVirus(Schematic): - NAME = "Doomsday virus" + NAME = "doomsday virus" COST = 100000 - CATEGORIES = (DOOMSDAY_DEVICE, PATHOGEN) + CATEGORIES = (cat.DOOMSDAY_DEVICE, cat.PATHOGEN) PREREQUISITES = ( (research.Biogenetics, 5), ) + + +class PropagandaMachine(Schematic): + NAME = "propaganda machine" + COST = 1000 + CATEGORIES = (cat.MIND_CONTROL) + PREREQUISITES = ( + (research.Psychology, 2), + )