comparison gamelib/schematics.py @ 49:373c57ab4140

Product -> Schematic.
author Jeremy Thurgood <firxen@gmail.com>
date Mon, 07 May 2012 21:24:23 +0200
parents gamelib/products.py@1e8f7e694f0c
children 168cfac9a445
comparison
equal deleted inserted replaced
48:a2980cc9a060 49:373c57ab4140
1 from gamelib import research
2 from gamelib.game_base import Science
3
4
5 # Kinds of schematic.
6 HAND_WEAPON = 'hand weapon'
7 VEHICLE = 'vehicle'
8 DOOMSDAY_DEVICE = 'doomsday device'
9 PATHOGEN = 'pathogen'
10
11
12 class Schematic(Science):
13 ACQUISITION_CHANCE = 0.8
14 COST = None
15 UPGRADE_REQUIREMENT = 1
16 STARTING_PRODUCT = False
17 SCIENCE_TYPE = 'schematic'
18 CATEGORIES = ()
19
20 def can_spend(self, lab):
21 extra = self.UPGRADE_REQUIREMENT * self.points + 1
22 return lab.meet_requirements(self, extra)
23
24 def is_a(self, category):
25 return category in self.CATEGORIES
26
27
28 class MachineGun(Schematic):
29 NAME = "Machine gun"
30 COST = 100
31 CATEGORIES = (HAND_WEAPON,)
32 STARTING_PRODUCT = True
33
34 def __init__(self, points=0):
35 self.points = 1
36
37 def spend_point(self):
38 raise NotImplementedError()
39
40 def can_spend(self, lab):
41 return False
42
43
44 class LightningGun(Schematic):
45 NAME = "Lightning gun"
46 COST = 300
47 CATEGORIES = (HAND_WEAPON,)
48 PREREQUISITES = (
49 (research.Tesla, 1),
50 )
51
52
53 class TeslaTank(Schematic):
54 NAME = "Tesla tank"
55 COST = 1000
56 CATEGORIES = (VEHICLE,)
57 PREREQUISITES = (
58 (research.Tesla, 3),
59 )
60
61
62 class DoomsdayVirus(Schematic):
63 NAME = "Doomsday virus"
64 COST = 100000
65 CATEGORIES = (DOOMSDAY_DEVICE, PATHOGEN)
66 PREREQUISITES = (
67 (research.Biogenetics, 5),
68 )