Mercurial > sypikslang
annotate gamelib/schematics.py @ 145:53277724645b
Science button juggling.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Fri, 11 May 2012 14:58:00 +0200 |
parents | 8e64bbd561bd |
children | 2587f8c34f84 |
rev | line source |
---|---|
54 | 1 # -*- test-case-name: gamelib.tests.test_schematics -*- |
2 | |
3
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
3 from gamelib import research |
45
1e8f7e694f0c
Refactor missions and sciences a bit to reduce duplication.
Jeremy Thurgood <firxen@gmail.com>
parents:
34
diff
changeset
|
4 from gamelib.game_base import Science |
3
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
5 |
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
6 |
85
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
7 class SchematicCategorySet(object): |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
8 def __init__(self, *categories): |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
9 for cat in categories: |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
10 setattr(self, cat, cat.lower().replace('_', ' ')) |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
11 |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
12 cat = SchematicCategorySet( |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
13 'HAND_WEAPON', |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
14 'VEHICLE', |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
15 'DOOMSDAY_DEVICE', |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
16 'PATHOGEN', |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
17 'MIND_CONTROL', |
116 | 18 'BEAST', |
19 'AQUATIC', | |
132 | 20 'SPY', |
21 'AI', | |
85
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
22 ) |
32 | 23 |
24 | |
49 | 25 class Schematic(Science): |
54 | 26 # For all Schematics |
27 SCIENCE_TYPE = 'schematic' | |
28 | |
29 # Acquisition | |
30 STARTING_PRODUCT = False | |
6
826b44731323
Start of basic lab implementation.
Jeremy Thurgood <firxen@gmail.com>
parents:
3
diff
changeset
|
31 ACQUISITION_CHANCE = 0.8 |
54 | 32 CATEGORIES = () |
33 | |
34 # Costs | |
17
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
35 UPGRADE_REQUIREMENT = 1 |
54 | 36 COST = None |
37 | |
38 # Power and reliability | |
39 PROTOTYPE_RELIABILITY = 0.4 | |
40 PRODUCTION_RELIABILITY = 0.8 | |
41 BASE_POWER = None | |
42 POWER_INCREMENT = None | |
3
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
43 |
145
53277724645b
Science button juggling.
Jeremy Thurgood <firxen@gmail.com>
parents:
132
diff
changeset
|
44 # FIXME: Icons for equipment. |
53277724645b
Science button juggling.
Jeremy Thurgood <firxen@gmail.com>
parents:
132
diff
changeset
|
45 IMAGE_NAME = "physics" |
53277724645b
Science button juggling.
Jeremy Thurgood <firxen@gmail.com>
parents:
132
diff
changeset
|
46 |
58
52913ba12988
Check for multiple points in can_spend
Neil Muller <drnlmuller@gmail.com>
parents:
54
diff
changeset
|
47 def can_spend(self, lab, spend): |
52913ba12988
Check for multiple points in can_spend
Neil Muller <drnlmuller@gmail.com>
parents:
54
diff
changeset
|
48 extra = self.UPGRADE_REQUIREMENT * self.points + spend |
17
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
49 return lab.meet_requirements(self, extra) |
3
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
50 |
34 | 51 def is_a(self, category): |
52 return category in self.CATEGORIES | |
53 | |
54 | 54 def reliability(self): |
55 if self.points: | |
56 exp = 1 + 0.5 * (self.points - 1) | |
57 return 1.0 - ((1.0 - self.PRODUCTION_RELIABILITY) ** exp) | |
58 return self.PROTOTYPE_RELIABILITY | |
59 | |
60 def power(self): | |
61 power = self.BASE_POWER | |
62 if None not in (power, self.POWER_INCREMENT): | |
63 power += self.POWER_INCREMENT * self.points | |
64 return power | |
65 | |
94
245ef50de84d
Sanity-check research, schematic and mission classes. (Ironic, no?)
Jeremy Thurgood <firxen@gmail.com>
parents:
91
diff
changeset
|
66 @classmethod |
245ef50de84d
Sanity-check research, schematic and mission classes. (Ironic, no?)
Jeremy Thurgood <firxen@gmail.com>
parents:
91
diff
changeset
|
67 def sanity_check(cls): |
245ef50de84d
Sanity-check research, schematic and mission classes. (Ironic, no?)
Jeremy Thurgood <firxen@gmail.com>
parents:
91
diff
changeset
|
68 for science, points in cls.PREREQUISITES: |
245ef50de84d
Sanity-check research, schematic and mission classes. (Ironic, no?)
Jeremy Thurgood <firxen@gmail.com>
parents:
91
diff
changeset
|
69 assert issubclass(science, Science) |
245ef50de84d
Sanity-check research, schematic and mission classes. (Ironic, no?)
Jeremy Thurgood <firxen@gmail.com>
parents:
91
diff
changeset
|
70 assert isinstance(points, int) |
245ef50de84d
Sanity-check research, schematic and mission classes. (Ironic, no?)
Jeremy Thurgood <firxen@gmail.com>
parents:
91
diff
changeset
|
71 assert isinstance(cls.CATEGORIES, tuple) |
245ef50de84d
Sanity-check research, schematic and mission classes. (Ironic, no?)
Jeremy Thurgood <firxen@gmail.com>
parents:
91
diff
changeset
|
72 |
3
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
73 |
49 | 74 class MachineGun(Schematic): |
85
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
75 NAME = "machine gun" |
15 | 76 COST = 100 |
85
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
77 CATEGORIES = (cat.HAND_WEAPON,) |
17
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
78 STARTING_PRODUCT = True |
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
79 |
20 | 80 def __init__(self, points=0): |
17
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
81 self.points = 1 |
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
82 |
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
83 def spend_point(self): |
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
84 raise NotImplementedError() |
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
85 |
58
52913ba12988
Check for multiple points in can_spend
Neil Muller <drnlmuller@gmail.com>
parents:
54
diff
changeset
|
86 def can_spend(self, lab, spend): |
17
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
87 return False |
3
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
88 |
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
89 |
49 | 90 class LightningGun(Schematic): |
85
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
91 NAME = "lightning gun" |
32 | 92 COST = 300 |
85
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
93 CATEGORIES = (cat.HAND_WEAPON,) |
3
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
94 PREREQUISITES = ( |
115 | 95 (research.Electrickery, 1), |
3
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
96 ) |
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
97 |
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
98 |
49 | 99 class TeslaTank(Schematic): |
85
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
100 NAME = "tesla tank" |
32 | 101 COST = 1000 |
85
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
102 CATEGORIES = (cat.VEHICLE,) |
17
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
103 PREREQUISITES = ( |
115 | 104 (research.Electrickery, 3), |
17
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
105 ) |
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
106 |
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
107 |
49 | 108 class DoomsdayVirus(Schematic): |
85
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
109 NAME = "doomsday virus" |
32 | 110 COST = 100000 |
85
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
111 CATEGORIES = (cat.DOOMSDAY_DEVICE, cat.PATHOGEN) |
3
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
112 PREREQUISITES = ( |
14 | 113 (research.Biogenetics, 5), |
3
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
114 ) |
85
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
115 |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
116 |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
117 class PropagandaMachine(Schematic): |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
118 NAME = "propaganda machine" |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
119 COST = 1000 |
91
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
85
diff
changeset
|
120 CATEGORIES = (cat.MIND_CONTROL,) |
85
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
121 PREREQUISITES = ( |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
122 (research.Psychology, 2), |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
123 ) |
116 | 124 |
125 | |
126 class GiantSquid(Schematic): | |
127 NAME = "giant squid" | |
128 COST = 50000 | |
129 CATEGORIES = (cat.BEAST, cat.AQUATIC) | |
130 PREREQUISITES = ( | |
131 (research.MarineBiology, 20), | |
132 (research.Biogenetics, 15), | |
133 ) | |
134 | |
135 | |
136 class SharksWithFrickinLasers(Schematic): | |
137 NAME = "sharks with frickin' lasers" | |
138 COST = 20000 | |
139 CATEGORIES = (cat.BEAST, cat.AQUATIC) | |
140 PREREQUISITES = ( | |
141 (research.MarineBiology, 10), | |
142 (research.Lasers, 7), | |
143 ) | |
132 | 144 |
145 | |
146 class OrbitalLaserPlatform(Schematic): | |
147 NAME = "An Orbital Laser Platform" | |
148 COST = 10000000 | |
149 CATEGORIES = (cat.DOOMSDAY_DEVICE,) | |
150 PREREQUISITES = ( | |
151 (research.Lasers, 5), | |
152 (research.Space, 2), | |
153 ) | |
154 | |
155 | |
156 class GiantRobot(Schematic): | |
157 NAME = "A very large robot" | |
158 COST = 1000000 | |
159 CATEGORIES = (cat.DOOMSDAY_DEVICE,) | |
160 PREREQUISITES = ( | |
161 (research.Robotics, 5), | |
162 (research.ArtificialIntelligence, 2), | |
163 ) | |
164 | |
165 | |
166 class SpySattelite(Schematic): | |
167 NAME = "A small spy sattelite" | |
168 COST = 10000 | |
169 CATEGORIES = (cat.SPY,) | |
170 PREREQUISITES = ( | |
171 (research.Space, 1), | |
172 ) | |
173 | |
174 | |
175 class ComputerAI(Schematic): | |
176 NAME = "AI Assistant" | |
177 COST = 10000 | |
178 CATEGORIES = (cat.AI,) | |
179 PREREQUISITES = ( | |
180 (research.ArtificialIntelligence, 1), | |
181 ) | |
182 | |
183 | |
184 class LaserGun(Schematic): | |
185 NAME = "Laser Gun" | |
186 COST = 300 | |
187 CATEGORIES = (cat.HAND_WEAPON,) | |
188 PREREQUISITES = ( | |
189 (research.Lasers, 1), | |
190 ) |