view gamelib/products.py @ 20:718d1ec382f7

Deserialise lab data.
author Jeremy Thurgood <firxen@gmail.com>
date Sun, 06 May 2012 18:12:51 +0200
parents 10d3db1f1e08
children 23720d0fd9a0
line wrap: on
line source

from gamelib import research


class Product(object):
    NAME = None
    PREREQUISITES = ()
    ACQUISITION_CHANCE = 0.8
    COST = 0
    UPGRADE_REQUIREMENT = 1
    STARTING_PRODUCT = False

    def __init__(self, points=0):
        self.points = points

    def spend_point(self):
        self.points += 1

    def can_spend(self, lab):
        extra = self.UPGRADE_REQUIREMENT * self.points + 1
        return lab.meet_requirements(self, extra)


class MachineGun(Product):
    NAME = "Machine gun"
    COST = 100
    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"
    PREREQUISITES = (
        (research.Tesla, 1),
        )
    COST = 300


class TeslaTank(Product):
    NAME = "Tesla tank"
    PREREQUISITES = (
        (research.Tesla, 3),
        )


class DoomsdayVirus(Product):
    NAME = "Doomsday virus"
    PREREQUISITES = (
        (research.Biogenetics, 5),
        )
    COST = 1000