Mercurial > sypikslang
annotate gamelib/schematics.py @ 82:b0d97d51df51
Hook up simplistic equipment screen
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Wed, 09 May 2012 16:51:26 +0200 |
parents | 52913ba12988 |
children | 182fce9f70b6 |
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 |
49 | 7 # Kinds of schematic. |
32 | 8 HAND_WEAPON = 'hand weapon' |
9 VEHICLE = 'vehicle' | |
10 DOOMSDAY_DEVICE = 'doomsday device' | |
11 PATHOGEN = 'pathogen' | |
12 | |
13 | |
49 | 14 class Schematic(Science): |
54 | 15 # For all Schematics |
16 SCIENCE_TYPE = 'schematic' | |
17 | |
18 # Acquisition | |
19 STARTING_PRODUCT = False | |
6
826b44731323
Start of basic lab implementation.
Jeremy Thurgood <firxen@gmail.com>
parents:
3
diff
changeset
|
20 ACQUISITION_CHANCE = 0.8 |
54 | 21 CATEGORIES = () |
22 | |
23 # Costs | |
17
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
24 UPGRADE_REQUIREMENT = 1 |
54 | 25 COST = None |
26 | |
27 # Power and reliability | |
28 PROTOTYPE_RELIABILITY = 0.4 | |
29 PRODUCTION_RELIABILITY = 0.8 | |
30 BASE_POWER = None | |
31 POWER_INCREMENT = None | |
3
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
32 |
58
52913ba12988
Check for multiple points in can_spend
Neil Muller <drnlmuller@gmail.com>
parents:
54
diff
changeset
|
33 def can_spend(self, lab, spend): |
52913ba12988
Check for multiple points in can_spend
Neil Muller <drnlmuller@gmail.com>
parents:
54
diff
changeset
|
34 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
|
35 return lab.meet_requirements(self, extra) |
3
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
36 |
34 | 37 def is_a(self, category): |
38 return category in self.CATEGORIES | |
39 | |
54 | 40 def reliability(self): |
41 if self.points: | |
42 exp = 1 + 0.5 * (self.points - 1) | |
43 return 1.0 - ((1.0 - self.PRODUCTION_RELIABILITY) ** exp) | |
44 return self.PROTOTYPE_RELIABILITY | |
45 | |
46 def power(self): | |
47 power = self.BASE_POWER | |
48 if None not in (power, self.POWER_INCREMENT): | |
49 power += self.POWER_INCREMENT * self.points | |
50 return power | |
51 | |
3
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
52 |
49 | 53 class MachineGun(Schematic): |
3
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
54 NAME = "Machine gun" |
15 | 55 COST = 100 |
32 | 56 CATEGORIES = (HAND_WEAPON,) |
17
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
57 STARTING_PRODUCT = True |
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
58 |
20 | 59 def __init__(self, points=0): |
17
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
60 self.points = 1 |
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
61 |
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
62 def spend_point(self): |
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
63 raise NotImplementedError() |
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
64 |
58
52913ba12988
Check for multiple points in can_spend
Neil Muller <drnlmuller@gmail.com>
parents:
54
diff
changeset
|
65 def can_spend(self, lab, spend): |
17
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
66 return False |
3
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
67 |
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
68 |
49 | 69 class LightningGun(Schematic): |
17
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
70 NAME = "Lightning gun" |
32 | 71 COST = 300 |
72 CATEGORIES = (HAND_WEAPON,) | |
3
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
73 PREREQUISITES = ( |
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
74 (research.Tesla, 1), |
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
75 ) |
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
76 |
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
77 |
49 | 78 class TeslaTank(Schematic): |
17
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
79 NAME = "Tesla tank" |
32 | 80 COST = 1000 |
81 CATEGORIES = (VEHICLE,) | |
17
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
82 PREREQUISITES = ( |
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
83 (research.Tesla, 3), |
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
84 ) |
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
85 |
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
15
diff
changeset
|
86 |
49 | 87 class DoomsdayVirus(Schematic): |
3
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
88 NAME = "Doomsday virus" |
32 | 89 COST = 100000 |
90 CATEGORIES = (DOOMSDAY_DEVICE, PATHOGEN) | |
3
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
91 PREREQUISITES = ( |
14 | 92 (research.Biogenetics, 5), |
3
6ab4f1ab9eab
Very basics of research and products.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
93 ) |