annotate 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
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
24
23720d0fd9a0 Make SCIENCE_TYPE explicit.
Jeremy Thurgood <firxen@gmail.com>
parents: 20
diff changeset
11 SCIENCE_TYPE = 'product'
3
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
12
17
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
13 def __init__(self, points=0):
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
14 self.points = points
3
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
15
17
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
16 def spend_point(self):
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
17 self.points += 1
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
18
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
19 def can_spend(self, lab):
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
20 extra = self.UPGRADE_REQUIREMENT * self.points + 1
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
21 return lab.meet_requirements(self, extra)
3
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
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
24 class MachineGun(Product):
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
25 NAME = "Machine gun"
15
8865ba0c9c38 Add cost to products
Neil Muller <drnlmuller@gmail.com>
parents: 14
diff changeset
26 COST = 100
17
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
27 STARTING_PRODUCT = True
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
28
20
718d1ec382f7 Deserialise lab data.
Jeremy Thurgood <firxen@gmail.com>
parents: 17
diff changeset
29 def __init__(self, points=0):
17
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
30 self.points = 1
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
31
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
32 def spend_point(self):
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
33 raise NotImplementedError()
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
34
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
35 def can_spend(self, lab):
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
36 return False
3
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
37
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
38
17
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
39 class LightningGun(Product):
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
40 NAME = "Lightning gun"
3
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
41 PREREQUISITES = (
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
42 (research.Tesla, 1),
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
43 )
15
8865ba0c9c38 Add cost to products
Neil Muller <drnlmuller@gmail.com>
parents: 14
diff changeset
44 COST = 300
3
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
45
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
46
17
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
47 class TeslaTank(Product):
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
48 NAME = "Tesla tank"
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
49 PREREQUISITES = (
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
50 (research.Tesla, 3),
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
10d3db1f1e08 Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 15
diff changeset
53
3
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
54 class DoomsdayVirus(Product):
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
55 NAME = "Doomsday virus"
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
56 PREREQUISITES = (
14
9d61abb3cfaf Better subclass handling.
Jeremy Thurgood <firxen@gmail.com>
parents: 6
diff changeset
57 (research.Biogenetics, 5),
3
6ab4f1ab9eab Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
58 )
15
8865ba0c9c38 Add cost to products
Neil Muller <drnlmuller@gmail.com>
parents: 14
diff changeset
59 COST = 1000