view gamelib/products.py @ 17:10d3db1f1e08

Set up initial research and rework breakthroughs.
author Jeremy Thurgood <firxen@gmail.com>
date Sun, 06 May 2012 17:39:37 +0200
parents 8865ba0c9c38
children 718d1ec382f7
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):
        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