Mercurial > sypikslang
view gamelib/products.py @ 48:a2980cc9a060
Factor out some constants
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Mon, 07 May 2012 21:23:54 +0200 |
parents | 1e8f7e694f0c |
children |
line wrap: on
line source
from gamelib import research from gamelib.game_base import Science # Kinds of product. HAND_WEAPON = 'hand weapon' VEHICLE = 'vehicle' DOOMSDAY_DEVICE = 'doomsday device' PATHOGEN = 'pathogen' class Product(Science): ACQUISITION_CHANCE = 0.8 COST = None UPGRADE_REQUIREMENT = 1 STARTING_PRODUCT = False SCIENCE_TYPE = 'product' 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(Product): 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(Product): NAME = "Lightning gun" COST = 300 CATEGORIES = (HAND_WEAPON,) PREREQUISITES = ( (research.Tesla, 1), ) class TeslaTank(Product): NAME = "Tesla tank" COST = 1000 CATEGORIES = (VEHICLE,) PREREQUISITES = ( (research.Tesla, 3), ) class DoomsdayVirus(Product): NAME = "Doomsday virus" COST = 100000 CATEGORIES = (DOOMSDAY_DEVICE, PATHOGEN) PREREQUISITES = ( (research.Biogenetics, 5), )