annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
1 from gamelib import research
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
2
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
3
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
4 class Product(object):
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
5 NAME = None
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
6 PREREQUISITES = ()
6
826b44731323 Start of basic lab implementation.
Jeremy Thurgood <firxen@gmail.com>
parents: 3
diff changeset
7 ACQUISITION_CHANCE = 0.8
15
8865ba0c9c38 Add cost to products
Neil Muller <drnlmuller@gmail.com>
parents: 14
diff changeset
8 COST = 0
17
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
9 UPGRADE_REQUIREMENT = 1
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
10 STARTING_PRODUCT = False
3
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
11
17
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
12 def __init__(self, points=0):
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
13 self.points = points
3
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
14
17
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
15 def spend_point(self):
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
16 self.points += 1
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
17
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
18 def can_spend(self, lab):
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
19 extra = self.UPGRADE_REQUIREMENT * self.points + 1
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
20 return lab.meet_requirements(self, extra)
3
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
21
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
22
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
23 class MachineGun(Product):
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
24 NAME = "Machine gun"
15
8865ba0c9c38 Add cost to products
Neil Muller <drnlmuller@gmail.com>
parents: 14
diff changeset
25 COST = 100
17
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
26 STARTING_PRODUCT = True
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
27
20
718d1ec382f7 Deserialise lab data.
Jeremy Thurgood <firxen@gmail.com>
parents: 17
diff changeset
28 def __init__(self, points=0):
17
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
29 self.points = 1
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
30
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
31 def spend_point(self):
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
32 raise NotImplementedError()
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
33
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
34 def can_spend(self, lab):
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
35 return False
3
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
36
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
37
17
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
38 class LightningGun(Product):
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
39 NAME = "Lightning gun"
3
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
40 PREREQUISITES = (
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
41 (research.Tesla, 1),
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
42 )
15
8865ba0c9c38 Add cost to products
Neil Muller <drnlmuller@gmail.com>
parents: 14
diff changeset
43 COST = 300
3
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
44
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
45
17
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
46 class TeslaTank(Product):
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
47 NAME = "Tesla tank"
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
48 PREREQUISITES = (
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
49 (research.Tesla, 3),
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
50 )
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
51
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
52
3
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
53 class DoomsdayVirus(Product):
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
54 NAME = "Doomsday virus"
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
55 PREREQUISITES = (
14
9d61abb3cfaf Better subclass handling.
Jeremy Thurgood <firxen@gmail.com>
parents: 6
diff changeset
56 (research.Biogenetics, 5),
3
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
57 )
15
8865ba0c9c38 Add cost to products
Neil Muller <drnlmuller@gmail.com>
parents: 14
diff changeset
58 COST = 1000