Mercurial > sypikslang
comparison gamelib/products.py @ 45:1e8f7e694f0c
Refactor missions and sciences a bit to reduce duplication.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Mon, 07 May 2012 20:44:27 +0200 |
parents | 20ed2843adec |
children |
comparison
equal
deleted
inserted
replaced
44:d35a3762edda | 45:1e8f7e694f0c |
---|---|
1 from gamelib import research | 1 from gamelib import research |
2 from gamelib.game_base import Science | |
2 | 3 |
3 | 4 |
4 # Kinds of product. | 5 # Kinds of product. |
5 HAND_WEAPON = 'hand weapon' | 6 HAND_WEAPON = 'hand weapon' |
6 VEHICLE = 'vehicle' | 7 VEHICLE = 'vehicle' |
7 DOOMSDAY_DEVICE = 'doomsday device' | 8 DOOMSDAY_DEVICE = 'doomsday device' |
8 PATHOGEN = 'pathogen' | 9 PATHOGEN = 'pathogen' |
9 | 10 |
10 | 11 |
11 class Product(object): | 12 class Product(Science): |
12 NAME = None | |
13 PREREQUISITES = () | |
14 ACQUISITION_CHANCE = 0.8 | 13 ACQUISITION_CHANCE = 0.8 |
15 COST = None | 14 COST = None |
16 UPGRADE_REQUIREMENT = 1 | 15 UPGRADE_REQUIREMENT = 1 |
17 STARTING_PRODUCT = False | 16 STARTING_PRODUCT = False |
18 SCIENCE_TYPE = 'product' | 17 SCIENCE_TYPE = 'product' |
19 CATEGORIES = () | 18 CATEGORIES = () |
20 | |
21 def __init__(self, points=0): | |
22 self.points = points | |
23 | |
24 def spend_point(self): | |
25 self.points += 1 | |
26 | 19 |
27 def can_spend(self, lab): | 20 def can_spend(self, lab): |
28 extra = self.UPGRADE_REQUIREMENT * self.points + 1 | 21 extra = self.UPGRADE_REQUIREMENT * self.points + 1 |
29 return lab.meet_requirements(self, extra) | 22 return lab.meet_requirements(self, extra) |
30 | 23 |