view gamelib/products.py @ 24:23720d0fd9a0

Make SCIENCE_TYPE explicit.
author Jeremy Thurgood <firxen@gmail.com>
date Sun, 06 May 2012 19:17:04 +0200
parents 718d1ec382f7
children 00aff02bc6fc
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
    SCIENCE_TYPE = 'product'

    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