Mercurial > sypikslang
diff gamelib/schematics.py @ 49:373c57ab4140
Product -> Schematic.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Mon, 07 May 2012 21:24:23 +0200 |
parents | gamelib/products.py@1e8f7e694f0c |
children | 168cfac9a445 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gamelib/schematics.py Mon May 07 21:24:23 2012 +0200 @@ -0,0 +1,68 @@ +from gamelib import research +from gamelib.game_base import Science + + +# Kinds of schematic. +HAND_WEAPON = 'hand weapon' +VEHICLE = 'vehicle' +DOOMSDAY_DEVICE = 'doomsday device' +PATHOGEN = 'pathogen' + + +class Schematic(Science): + ACQUISITION_CHANCE = 0.8 + COST = None + UPGRADE_REQUIREMENT = 1 + STARTING_PRODUCT = False + SCIENCE_TYPE = 'schematic' + CATEGORIES = () + + def can_spend(self, lab): + extra = self.UPGRADE_REQUIREMENT * self.points + 1 + return lab.meet_requirements(self, extra) + + def is_a(self, category): + return category in self.CATEGORIES + + +class MachineGun(Schematic): + NAME = "Machine gun" + COST = 100 + CATEGORIES = (HAND_WEAPON,) + STARTING_PRODUCT = True + + def __init__(self, points=0): + self.points = 1 + + def spend_point(self): + raise NotImplementedError() + + def can_spend(self, lab): + return False + + +class LightningGun(Schematic): + NAME = "Lightning gun" + COST = 300 + CATEGORIES = (HAND_WEAPON,) + PREREQUISITES = ( + (research.Tesla, 1), + ) + + +class TeslaTank(Schematic): + NAME = "Tesla tank" + COST = 1000 + CATEGORIES = (VEHICLE,) + PREREQUISITES = ( + (research.Tesla, 3), + ) + + +class DoomsdayVirus(Schematic): + NAME = "Doomsday virus" + COST = 100000 + CATEGORIES = (DOOMSDAY_DEVICE, PATHOGEN) + PREREQUISITES = ( + (research.Biogenetics, 5), + )