Mercurial > sypikslang
annotate gamelib/missions.py @ 180:8868ac7ece8b
Tweak steal research mission
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 12 May 2012 12:28:39 +0200 |
parents | 71db080a1fbf |
children | 07e81cd0cdd6 |
rev | line source |
---|---|
5 | 1 # -*- coding: utf-8 -*- |
2 # vim:fileencoding=utf-8 ai ts=4 sts=4 et sw=4 | |
3 | |
177
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
4 from random import randint, random, choice |
36
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
5 |
138
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
137
diff
changeset
|
6 from gamelib.constants import SUCCESS, FAILURE, GAME_WIN, M_VALS |
85
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
7 from gamelib.schematics import cat |
18
0849ab5304cf
Add more mission result codes
Neil Muller <drnlmuller@gmail.com>
parents:
13
diff
changeset
|
8 |
5 | 9 |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
10 class Result(Exception): |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
11 """Results of a mission. |
13
c0966997e0c5
Use a results object instead of tuple (will hopefully make changign stuff easier later)
Neil Muller <drnlmuller@gmail.com>
parents:
10
diff
changeset
|
12 |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
13 This is an exception so we can throw it from inside helper methods. |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
14 """ |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
15 |
138
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
137
diff
changeset
|
16 def __init__(self, outcome, msg, money=0, rep=0, **special): |
13
c0966997e0c5
Use a results object instead of tuple (will hopefully make changign stuff easier later)
Neil Muller <drnlmuller@gmail.com>
parents:
10
diff
changeset
|
17 self.outcome = outcome |
c0966997e0c5
Use a results object instead of tuple (will hopefully make changign stuff easier later)
Neil Muller <drnlmuller@gmail.com>
parents:
10
diff
changeset
|
18 self.money = money |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
19 self.reputation = rep |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
20 self.text = msg |
138
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
137
diff
changeset
|
21 self.special = special |
13
c0966997e0c5
Use a results object instead of tuple (will hopefully make changign stuff easier later)
Neil Muller <drnlmuller@gmail.com>
parents:
10
diff
changeset
|
22 self.applied = False |
c0966997e0c5
Use a results object instead of tuple (will hopefully make changign stuff easier later)
Neil Muller <drnlmuller@gmail.com>
parents:
10
diff
changeset
|
23 |
138
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
137
diff
changeset
|
24 @property |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
137
diff
changeset
|
25 def loot(self): |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
137
diff
changeset
|
26 loot = {} |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
137
diff
changeset
|
27 if self.money != 0: |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
137
diff
changeset
|
28 loot['money'] = self.money |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
137
diff
changeset
|
29 if self.reputation != 0: |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
137
diff
changeset
|
30 loot['rep'] = self.reputation |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
137
diff
changeset
|
31 loot.update(self.special) |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
137
diff
changeset
|
32 loot.pop('new_milestone', None) # This one's special. |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
137
diff
changeset
|
33 return loot |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
137
diff
changeset
|
34 |
13
c0966997e0c5
Use a results object instead of tuple (will hopefully make changign stuff easier later)
Neil Muller <drnlmuller@gmail.com>
parents:
10
diff
changeset
|
35 def apply(self, state): |
c0966997e0c5
Use a results object instead of tuple (will hopefully make changign stuff easier later)
Neil Muller <drnlmuller@gmail.com>
parents:
10
diff
changeset
|
36 if not self.applied: |
c0966997e0c5
Use a results object instead of tuple (will hopefully make changign stuff easier later)
Neil Muller <drnlmuller@gmail.com>
parents:
10
diff
changeset
|
37 state.money += self.money |
c0966997e0c5
Use a results object instead of tuple (will hopefully make changign stuff easier later)
Neil Muller <drnlmuller@gmail.com>
parents:
10
diff
changeset
|
38 state.reputation += self.reputation |
164
7beac783139b
Fix calling of apply_mission_special to avoid gamestate.milestone ending up as a dict.
Simon Cross <hodgestar@gmail.com>
parents:
159
diff
changeset
|
39 state.apply_mission_special(**self.special) |
13
c0966997e0c5
Use a results object instead of tuple (will hopefully make changign stuff easier later)
Neil Muller <drnlmuller@gmail.com>
parents:
10
diff
changeset
|
40 self.applied = True |
c0966997e0c5
Use a results object instead of tuple (will hopefully make changign stuff easier later)
Neil Muller <drnlmuller@gmail.com>
parents:
10
diff
changeset
|
41 else: |
c0966997e0c5
Use a results object instead of tuple (will hopefully make changign stuff easier later)
Neil Muller <drnlmuller@gmail.com>
parents:
10
diff
changeset
|
42 raise RuntimeError('attempted to apply result twice') |
c0966997e0c5
Use a results object instead of tuple (will hopefully make changign stuff easier later)
Neil Muller <drnlmuller@gmail.com>
parents:
10
diff
changeset
|
43 |
c0966997e0c5
Use a results object instead of tuple (will hopefully make changign stuff easier later)
Neil Muller <drnlmuller@gmail.com>
parents:
10
diff
changeset
|
44 |
5 | 45 class Mission(object): |
46 """Base class for the mission objects. | |
47 Missions have a name, short description (for list displays) and | |
48 long description (which may contain clues about approaches)""" | |
49 | |
50 NAME = "Generic Mission" | |
51 SHORT_DESCRIPTION = None | |
52 LONG_DESCRIPTION = None | |
96 | 53 |
33
12c33aac7684
Gate certain missions by reputation.
Jeremy Thurgood <firxen@gmail.com>
parents:
32
diff
changeset
|
54 MINIMUM_REPUTATION = None |
96 | 55 MINIMUM_MILESTONE = "neighbourhood" |
124
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
123
diff
changeset
|
56 MINIONS_REQUIRED = 1 |
5 | 57 |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
58 GENERIC_FAILURE = "You fail to inspire sufficient fear." |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
59 GENERIC_SUCCESS = "Victory is sweet." |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
60 NO_EQUIP_FAILURE = ( |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
61 "Really? You're going in completely unequipped? How brave. And " |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
62 " foolish. And ultimately unsuccessful.") |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
63 |
22
296ce36fa7d9
Serialize and unserialize game state and missions
Neil Muller <drnlmuller@gmail.com>
parents:
19
diff
changeset
|
64 def __init__(self, init_data=None): |
91
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
65 self.data = {} |
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
66 |
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
67 if init_data is not None: |
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
68 # Load stored state. |
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
69 self._load_data(init_data) |
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
70 else: |
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
71 # New instance. |
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
72 self._new_data() |
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
73 |
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
74 def _new_data(self): |
22
296ce36fa7d9
Serialize and unserialize game state and missions
Neil Muller <drnlmuller@gmail.com>
parents:
19
diff
changeset
|
75 pass |
296ce36fa7d9
Serialize and unserialize game state and missions
Neil Muller <drnlmuller@gmail.com>
parents:
19
diff
changeset
|
76 |
91
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
77 def _load_data(self, init_data): |
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
78 # Note: this does not deep-copy. |
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
79 self.data = init_data.copy() |
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
80 |
22
296ce36fa7d9
Serialize and unserialize game state and missions
Neil Muller <drnlmuller@gmail.com>
parents:
19
diff
changeset
|
81 def save_data(self): |
91
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
82 # Note: this does not deep-copy. |
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
83 return self.data.copy() |
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
84 |
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
85 def get_data(self, key): |
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
86 return self.data.get(key, None) |
22
296ce36fa7d9
Serialize and unserialize game state and missions
Neil Muller <drnlmuller@gmail.com>
parents:
19
diff
changeset
|
87 |
94
245ef50de84d
Sanity-check research, schematic and mission classes. (Ironic, no?)
Jeremy Thurgood <firxen@gmail.com>
parents:
92
diff
changeset
|
88 @classmethod |
245ef50de84d
Sanity-check research, schematic and mission classes. (Ironic, no?)
Jeremy Thurgood <firxen@gmail.com>
parents:
92
diff
changeset
|
89 def sanity_check(cls): |
245ef50de84d
Sanity-check research, schematic and mission classes. (Ironic, no?)
Jeremy Thurgood <firxen@gmail.com>
parents:
92
diff
changeset
|
90 pass |
245ef50de84d
Sanity-check research, schematic and mission classes. (Ironic, no?)
Jeremy Thurgood <firxen@gmail.com>
parents:
92
diff
changeset
|
91 |
41
e285b1e31a08
Add can_attempt method for future flexibility
Neil Muller <drnlmuller@gmail.com>
parents:
36
diff
changeset
|
92 def can_attempt(self, state): |
e285b1e31a08
Add can_attempt method for future flexibility
Neil Muller <drnlmuller@gmail.com>
parents:
36
diff
changeset
|
93 """Can we currently attempt the mission""" |
96 | 94 if (M_VALS[self.MINIMUM_MILESTONE] > M_VALS[state.milestone]): |
95 # Our base of operations is too small | |
96 return False | |
91
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
97 if self.get_data('completed'): |
41
e285b1e31a08
Add can_attempt method for future flexibility
Neil Muller <drnlmuller@gmail.com>
parents:
36
diff
changeset
|
98 return False |
e285b1e31a08
Add can_attempt method for future flexibility
Neil Muller <drnlmuller@gmail.com>
parents:
36
diff
changeset
|
99 if (self.MINIMUM_REPUTATION is not None and |
91
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
100 self.MINIMUM_REPUTATION > state.reputation): |
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
101 # Don't have the reputation required |
41
e285b1e31a08
Add can_attempt method for future flexibility
Neil Muller <drnlmuller@gmail.com>
parents:
36
diff
changeset
|
102 return False |
124
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
123
diff
changeset
|
103 if self.MINIONS_REQUIRED > state.minions: |
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
123
diff
changeset
|
104 # Need more minions! |
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
123
diff
changeset
|
105 return False |
41
e285b1e31a08
Add can_attempt method for future flexibility
Neil Muller <drnlmuller@gmail.com>
parents:
36
diff
changeset
|
106 return True |
e285b1e31a08
Add can_attempt method for future flexibility
Neil Muller <drnlmuller@gmail.com>
parents:
36
diff
changeset
|
107 |
138
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
137
diff
changeset
|
108 def fail(self, msg=None, money=0, rep=0, **special): |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
109 if msg is None: |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
110 msg = self.GENERIC_FAILURE |
138
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
137
diff
changeset
|
111 raise Result(FAILURE, msg, money=money, rep=rep, **special) |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
112 |
138
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
137
diff
changeset
|
113 def succeed(self, msg=None, money=0, rep=0, **special): |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
114 if msg is None: |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
115 msg = self.GENERIC_SUCCESS |
138
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
137
diff
changeset
|
116 raise Result(SUCCESS, msg, money=money, rep=rep, **special) |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
117 |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
118 def categorise_equipment(self, equipment): |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
119 # Categorise equipment for easier decision-making. |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
120 categorised = {} |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
121 for item in equipment: |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
122 for category in item.CATEGORIES: |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
123 categorised.setdefault(category, []).append(item) |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
124 return categorised |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
125 |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
126 def attempt_mission(self, equipment, state): |
5 | 127 """Attempt the mission with the given equipment list. |
36
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
128 Returns a result object with the results of the mission.""" |
5 | 129 |
41
e285b1e31a08
Add can_attempt method for future flexibility
Neil Muller <drnlmuller@gmail.com>
parents:
36
diff
changeset
|
130 # Handle error case |
91
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
131 if self.get_data('completed'): |
41
e285b1e31a08
Add can_attempt method for future flexibility
Neil Muller <drnlmuller@gmail.com>
parents:
36
diff
changeset
|
132 raise RuntimeError('Cannot attempt a completed mission') |
e285b1e31a08
Add can_attempt method for future flexibility
Neil Muller <drnlmuller@gmail.com>
parents:
36
diff
changeset
|
133 |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
134 try: |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
135 self.attempt(equipment, state) |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
136 except Result, e: |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
137 return e |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
138 |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
139 def attempt(self, equipment, state): |
36
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
140 # No equipment is usually a special case. |
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
141 if not equipment: |
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
142 return self.attempt_no_equipment(state) |
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
143 |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
144 # Try with some equipment. |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
145 self.attempt_with(self.categorise_equipment(equipment), state) |
36
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
146 |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
147 # No result, so generic failure. |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
148 self.fail() |
36
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
149 |
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
150 def attempt_no_equipment(self, state): |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
151 self.fail(self.NO_EQUIP_FAILURE) |
36
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
152 |
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
153 def attempt_with(self, categorised, state): |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
154 self.fail("You can't succceed at this mission.") |
5 | 155 |
159
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
156 def combat_power(self, categorised, cats=None): |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
157 if cats is None: |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
158 cats = [cat.HAND_WEAPON, cat.VEHICLE, cat.COUNTERMEASURE, |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
159 cat.INTELLIGENCE] |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
160 |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
161 combat_equipment = set() |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
162 for category in cats: |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
163 combat_equipment.update(categorised.get(category, [])) |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
164 |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
165 power = 0 |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
166 for equipment in combat_equipment: |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
167 power += equipment.power() |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
168 return power |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
169 |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
170 def check_failure(self, categorised): |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
171 equipment = set() |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
172 for items in categorised.values(): |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
173 equipment.update(items) |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
174 for item in equipment: |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
175 if item.reliability() < random(): |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
176 return item.FAILURE_TEXT |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
177 return None |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
178 |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
179 def use_equipment(self, categorised, msg="Disaster strikes! %s", **loot): |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
180 failure = self.check_failure(categorised) |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
181 if failure is not None: |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
182 self.fail(msg % (failure,), **loot) |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
183 |
5 | 184 |
19
12085dfd9e69
Add rescue mission for the out of money case
Neil Muller <drnlmuller@gmail.com>
parents:
18
diff
changeset
|
185 class PlaygroundBully(Mission): |
12085dfd9e69
Add rescue mission for the out of money case
Neil Muller <drnlmuller@gmail.com>
parents:
18
diff
changeset
|
186 |
12085dfd9e69
Add rescue mission for the out of money case
Neil Muller <drnlmuller@gmail.com>
parents:
18
diff
changeset
|
187 NAME = "Rob kids in the playground" |
36
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
188 SHORT_DESCRIPTION = "Steal from those significantly weaker than yourself." |
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
189 LONG_DESCRIPTION = ( |
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
190 "It's not menancing, or lucrative, but when the bills are due, no one" |
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
191 " cares how you earn the money.") |
19
12085dfd9e69
Add rescue mission for the out of money case
Neil Muller <drnlmuller@gmail.com>
parents:
18
diff
changeset
|
192 |
96 | 193 MINIMUM_MILESTONE = "basement" |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
194 GENERIC_SUCCESS = ( |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
195 "You devote your resources to robbing kids in a playpark. It's not the" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
196 " finest moment in your reign of terror, but at least you walked away" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
197 " with a surprising amount of small change.") |
96 | 198 |
32 | 199 def attempt(self, equipment, state): |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
200 self.succeed(money=randint(90, 110), rep=-1) |
19
12085dfd9e69
Add rescue mission for the out of money case
Neil Muller <drnlmuller@gmail.com>
parents:
18
diff
changeset
|
201 |
12085dfd9e69
Add rescue mission for the out of money case
Neil Muller <drnlmuller@gmail.com>
parents:
18
diff
changeset
|
202 |
5 | 203 class RansomChina(Mission): |
204 | |
205 NAME = "Hold China to ransom" | |
36
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
206 SHORT_DESCRIPTION = "Surely a path to riches and fame." |
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
207 LONG_DESCRIPTION = ( |
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
208 "Holding China to ransom. The rewards for successfully threatening" |
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
209 " the largest country in the world are great, but the risks are" |
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
210 " significant. Without some serious firepower, the chances of success" |
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
211 " are small.") |
96 | 212 |
33
12c33aac7684
Gate certain missions by reputation.
Jeremy Thurgood <firxen@gmail.com>
parents:
32
diff
changeset
|
213 MINIMUM_REPUTATION = 100 |
96 | 214 MINIMUM_MILESTONE = "city" |
5 | 215 |
91
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
216 def _new_data(self): |
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
217 self.data['prior_attempts'] = [] |
5 | 218 |
36
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
219 def attempt_no_equipment(self, state): |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
220 self.fail( |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
221 "It takes three different interpreters before the Chinese" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
222 " government finally understand that you're trying to hold" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
223 " them ransom with... well... nothing. Nothing at all. This" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
224 " one will probably make a good anecdote at diplomatic" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
225 " cocktail parties. But not for you. No, not for you at all.", |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
226 rep=-10) |
36
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
227 |
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
228 def attempt_with(self, categorised, state): |
85
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
229 dooms = categorised.get(cat.DOOMSDAY_DEVICE, []) |
36
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
230 |
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
231 if not dooms: |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
232 self.fail( |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
233 "You completely fail to inspire the requisite level of" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
234 " terror. Maybe a more impressive threat will fare better.", |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
235 rep=-1) |
36
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
236 |
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
237 if len(dooms) > 1: |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
238 self.fail( |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
239 "Everyone seems confused as to how you actually plan" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
240 " to cause widepsread distruction and mayhem, and" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
241 " negotiations break down. Perhaps it's better to stick" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
242 " to one weapon of mass destruction at a time.") |
36
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
243 |
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
244 [doom] = dooms |
91
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
245 if doom.NAME in self.data['prior_attempts']: |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
246 self.fail( |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
247 "'We have devised countermeasures since last time, doctor." |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
248 " You cannot threaten us with that again.'") |
36
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
249 |
159
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
250 self.use_equipment(categorised, rep=randint(-5, -2)) |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
251 |
91
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
252 self.data['prior_attempts'].add(doom.NAME) |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
253 self.succeed( |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
254 "Trembling at you threat of certain doom, the Chinese" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
255 " government pays the ransom.", |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
256 money=randint(800000, 1200000), rep=10) |
5 | 257 |
258 | |
35 | 259 class ToppleThirdWorldGovernment(Mission): |
260 | |
261 NAME = "Topple a third-world government" | |
36
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
262 SHORT_DESCRIPTION = "We could use a more amenable dictator there." |
35 | 263 LONG_DESCRIPTION = ( |
264 "It's a small and fairly useless country, but it's still an actual" | |
265 " government that can be toppled. A good test bed for some of the" | |
266 " larger toys in the armory.") | |
96 | 267 |
35 | 268 MINIMUM_REPUTATION = 50 |
269 | |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
270 GENERIC_FAILURE = ( |
159
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
271 "Your invasion force was outclassed by the incumbent military, Not" |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
272 " surprising, since it turns out they've had a lot of practice in the" |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
273 " recent series of revolutions.") |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
274 |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
275 NO_EQUIP_FAILURE = ( |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
276 "The border post may be poorly guarded, but you need to bring *some*" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
277 " kind of weaponry along. Your troops sulk on the way home.") |
36
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
278 |
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
279 def attempt_with(self, categorised, state): |
159
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
280 self.use_equipment(categorised) |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
281 if self.combat_power(categorised) > randint(60, 120): |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
282 self.succeed( |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
283 "The corruption and oppression continue, but at least the" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
284 " proceeds are making their way into *your* pockets. And you" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
285 " don't even have to dirty your own jackboots.", |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
286 money=randint(5000, 15000), rep=randint(3, 7)) |
35 | 287 |
288 | |
5 | 289 class RobBank(Mission): |
290 | |
291 NAME = "Rob the local bank" | |
36
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
292 SHORT_DESCRIPTION = "A trivial challenge, but easy money." |
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
293 LONG_DESCRIPTION = ( |
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
294 "The security guards and local police are of minor concern. Walk in," |
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
295 " clean out the vault, walk out. Couldn't be simpler.") |
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
296 |
96 | 297 MINIMUM_MILESTONE = "basement" |
298 | |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
299 GENERIC_FAILURE = ( |
159
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
300 "The bank's security arrangements are rather more impressive than you" |
171 | 301 " were led to believe. Bring bigger guns next time.") |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
302 NO_EQUIP_FAILURE = ( |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
303 "Your attempt to rob the bank barehanded is unsuccessful. Fortunately," |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
304 " everyone is too stunned to impede your escape.") |
36
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
305 |
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
306 def attempt_with(self, categorised, state): |
85
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
307 loot = randint(500, 1500) |
5 | 308 |
159
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
309 self.use_equipment(categorised) |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
310 |
85
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
311 if cat.VEHICLE in categorised: |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
312 self.fail( |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
313 "Your vehicles are impressively doom-laden, but not really" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
314 " suitable for city traffic. You intimidate the traffic" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
315 " wardens into letting you off without a fine, but by the" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
316 " time you get to the bank it's already closed.") |
36
efc4f90cfd63
Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents:
35
diff
changeset
|
317 |
85
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
318 if cat.PATHOGEN in categorised: |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
319 if randint(5, 15) < state.reputation: |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
320 self.fail( |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
321 "The clerk doesn't realise the threat of the vial you" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
322 " hold, and although watching him die in agony would be" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
323 " statisfying, you decide it's not worth wasting this on" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
324 " something so trivial.") |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
325 self.succeed( |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
326 "Holding up a bank with only a small vial of clear liquid. Now" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
327 " that is power.", |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
328 money=loot, rep=1) |
10
9f8def7d70d0
Rework mission objects to include reputation
Neil Muller <drnlmuller@gmail.com>
parents:
5
diff
changeset
|
329 |
175 | 330 if cat.AI in categorised: |
331 self.success( | |
332 "Your cunning AI easily penetrates the bank's computing" | |
333 " systems and transfers the money to you account.", | |
334 money=loot) | |
335 | |
159
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
336 if self.combat_power(categorised) > randint(5, 20): |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
337 self.succeed( |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
338 "The threat of your weapons is enough to inspire an impressive" |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
339 " level of cooperation. You make off with the loot.", |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
340 money=loot) |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
341 |
10
9f8def7d70d0
Rework mission objects to include reputation
Neil Muller <drnlmuller@gmail.com>
parents:
5
diff
changeset
|
342 |
9f8def7d70d0
Rework mission objects to include reputation
Neil Muller <drnlmuller@gmail.com>
parents:
5
diff
changeset
|
343 class DestroyMountRushmore(Mission): |
9f8def7d70d0
Rework mission objects to include reputation
Neil Muller <drnlmuller@gmail.com>
parents:
5
diff
changeset
|
344 |
9f8def7d70d0
Rework mission objects to include reputation
Neil Muller <drnlmuller@gmail.com>
parents:
5
diff
changeset
|
345 NAME = "Destroy Mount Rushmore" |
9f8def7d70d0
Rework mission objects to include reputation
Neil Muller <drnlmuller@gmail.com>
parents:
5
diff
changeset
|
346 SHORT_DESCRIPTION = "Monuments to other people? Intolerable" |
92 | 347 LONG_DESCRIPTION = ( |
348 "While potentially expensive, destroying a major monument is a" | |
349 " good way to secure your reputation.") | |
33
12c33aac7684
Gate certain missions by reputation.
Jeremy Thurgood <firxen@gmail.com>
parents:
32
diff
changeset
|
350 MINIMUM_REPUTATION = 20 |
10
9f8def7d70d0
Rework mission objects to include reputation
Neil Muller <drnlmuller@gmail.com>
parents:
5
diff
changeset
|
351 |
9f8def7d70d0
Rework mission objects to include reputation
Neil Muller <drnlmuller@gmail.com>
parents:
5
diff
changeset
|
352 def attempt(self, equipment, state): |
91
c57b5b46d3e0
Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents:
86
diff
changeset
|
353 self.data['completed'] = True |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
354 self.succeed("Mount Rushmore is remarkably easy to destroy.", rep=50) |
85
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
355 |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
356 |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
357 class DistributePamphlets(Mission): |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
358 |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
359 NAME = "Distribute pamphlets" |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
360 SHORT_DESCRIPTION = "The populace need to be told the truth!" |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
361 LONG_DESCRIPTION = ( |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
362 "A focused pamphlet distribution campaign will combat the lies being" |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
363 " spread about you. Replacing them with better lies, of course.") |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
364 |
96 | 365 MINIMUM_MILESTONE = "basement" |
366 | |
85
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
367 SUCCESS_MESSAGE = ( |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
368 "A small army of urchins delivers thousands of cheaply printed" |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
369 " pamphlets. %s") |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
370 |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
371 def _succ(self, message, rep): |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
372 self.succeed(self.SUCCESS_MESSAGE % (message,), rep=rep) |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
373 |
85
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
374 def attempt_no_equipment(self, state): |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
375 rep = randint(-2, 5) |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
376 |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
377 if rep < 0: |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
378 self._succ( |
85
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
379 "Sadly, the populace was so annoyed by the flood of flyers" |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
380 " that nobody took any notice of the content.", rep) |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
381 if rep == 0: |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
382 self._succ("Nobody seems to have noticed.", rep) |
85
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
383 |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
384 self._succ( |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
385 "The public seemed mildly receptive to your propaganda.", rep) |
85
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
386 |
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
387 def attempt_with(self, categorised, state): |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
388 if cat.MIND_CONTROL in categorised: |
159
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
389 self.use_equipment( |
f1efd252e8b0
Equipment power in missions.
Jeremy Thurgood <firxen@gmail.com>
parents:
138
diff
changeset
|
390 {cat.MIND_CONTROL: categorised[cat.MIND_CONTROL]}) |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
391 self._succ("Your creative use of science has paid off nicely.", |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
392 randint(5, 10)) |
85
182fce9f70b6
Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
80
diff
changeset
|
393 |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
394 return self.attempt_no_equipment(state) |
95
0f437e0584f7
Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents:
94
diff
changeset
|
395 |
0f437e0584f7
Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents:
94
diff
changeset
|
396 |
0f437e0584f7
Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents:
94
diff
changeset
|
397 class TakeOverTheWorld(Mission): |
0f437e0584f7
Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents:
94
diff
changeset
|
398 |
0f437e0584f7
Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents:
94
diff
changeset
|
399 NAME = "Take over the world!" |
0f437e0584f7
Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents:
94
diff
changeset
|
400 SHORT_DESCRIPTION = "It's for their own good." |
0f437e0584f7
Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents:
94
diff
changeset
|
401 LONG_DESCRIPTION = ( |
0f437e0584f7
Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents:
94
diff
changeset
|
402 "Someone has to rule the world and if it's not you it'd just be" |
0f437e0584f7
Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents:
94
diff
changeset
|
403 " someone less well qualified -- and that would be worse for" |
0f437e0584f7
Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents:
94
diff
changeset
|
404 " everyone.") |
96 | 405 |
95
0f437e0584f7
Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents:
94
diff
changeset
|
406 MINIMUM_REPUTATION = 200 |
96 | 407 MINIMUM_MILESTONE = "city" |
95
0f437e0584f7
Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents:
94
diff
changeset
|
408 |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
409 NO_EQUIP_FAILURE = ( |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
410 "It's going to take more than your bare hands to take over the world!") |
95
0f437e0584f7
Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents:
94
diff
changeset
|
411 |
0f437e0584f7
Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents:
94
diff
changeset
|
412 def attempt_with(self, categorised, state): |
0f437e0584f7
Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents:
94
diff
changeset
|
413 if cat.MIND_CONTROL not in categorised: |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
414 self.fail( |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
415 "If you're going to take over the world, first you must" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
416 " control key elements within the populace.", rep=-5) |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
417 raise Result(GAME_WIN, "The world is yours!", rep=100) |
123
7cd716328a44
Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents:
96
diff
changeset
|
418 |
7cd716328a44
Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents:
96
diff
changeset
|
419 |
7cd716328a44
Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents:
96
diff
changeset
|
420 class TakeOverTheNeighbourhood(Mission): |
7cd716328a44
Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents:
96
diff
changeset
|
421 |
7cd716328a44
Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents:
96
diff
changeset
|
422 NAME = "Take over the neighbourhood!" |
7cd716328a44
Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents:
96
diff
changeset
|
423 SHORT_DESCRIPTION = "First step toward greatness." |
7cd716328a44
Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents:
96
diff
changeset
|
424 LONG_DESCRIPTION = ( |
7cd716328a44
Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents:
96
diff
changeset
|
425 "A basement lab is a good starting point, but it's getting a bit" |
7cd716328a44
Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents:
96
diff
changeset
|
426 " cramped in here. You need to expand, but don't quite have the" |
7cd716328a44
Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents:
96
diff
changeset
|
427 " resources to take the whole world yet. Or even the city. But the" |
7cd716328a44
Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents:
96
diff
changeset
|
428 " neighbourhood... that's quite feasible.") |
7cd716328a44
Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents:
96
diff
changeset
|
429 |
7cd716328a44
Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents:
96
diff
changeset
|
430 MINIMUM_REPUTATION = 20 |
7cd716328a44
Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents:
96
diff
changeset
|
431 MINIMUM_MILESTONE = "basement" |
7cd716328a44
Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents:
96
diff
changeset
|
432 |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
433 NO_EQUIP_FAILURE = ( |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
434 "The neighbourhood isn't very big, but you're still not going to take" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
435 " it over bare-handed.") |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
436 GENERIC_FAILURE = ( |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
437 "Well, that didn't work. Maybe a better equipment selection is in" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
438 " order.") |
123
7cd716328a44
Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents:
96
diff
changeset
|
439 |
7cd716328a44
Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents:
96
diff
changeset
|
440 def attempt_with(self, categorised, state): |
7cd716328a44
Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents:
96
diff
changeset
|
441 if all(c in categorised for c in (cat.MIND_CONTROL, cat.HAND_WEAPON)): |
129 | 442 self.data['completed'] = True |
138
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
137
diff
changeset
|
443 self.succeed( |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
137
diff
changeset
|
444 "Guns and persuasion, that's all you need. It's early days" |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
137
diff
changeset
|
445 " still, but you're finally out of that pokey basement and" |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
137
diff
changeset
|
446 " have some elbow room to work with. Next step: the city!", |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
137
diff
changeset
|
447 money=randint(1000, 2000), rep=randint(5, 15), |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
137
diff
changeset
|
448 new_milestone="neighbourhood") |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
449 |
123
7cd716328a44
Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents:
96
diff
changeset
|
450 if cat.HAND_WEAPON in categorised: |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
451 self.succeed( |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
452 "You'll need more than guns to win the people over. But until" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
453 " then, you can take their cash.", money=randint(100, 200)) |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
454 |
123
7cd716328a44
Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents:
96
diff
changeset
|
455 if cat.MIND_CONTROL in categorised: |
137
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
456 self.succeed( |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
457 "Propaganda and persuasion are good tools, but you'll need" |
fb8037bc22f1
More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
129
diff
changeset
|
458 " some force to back them up.", rep=randint(2, 4)) |
175 | 459 |
460 | |
461 class ShowThemAll(Mission): | |
462 | |
179 | 463 NAME = "And they called me mad!" |
175 | 464 SHORT_DESCRIPTION = "Time for revenge." |
465 LONG_DESCRIPTION = ( | |
466 "You've outgrown the chains of convention your teachers tried" | |
467 " to force you into. It's time to show the world what true" | |
468 " genius can accomplish. And what better way than with a small" | |
469 " slice of revenge?") | |
470 | |
471 MINIMUM_REPUTATION = 20 | |
472 MINIMUM_MILESTONE = "neighbourhood" | |
473 | |
474 NO_EQUIP_FAILURE = ( | |
475 "A security guard escorts you off campus after finding you clawing" | |
476 " at the science building with your bare hands. He doesn't say" | |
477 " anything, but you can already hear the gossip.") | |
478 | |
479 def attempt_no_equipment(self, state): | |
480 self.fail(self.NO_EQUIP_FAILURE, rep=-5) | |
481 | |
482 def attempt_with(self, categorised, state): | |
176 | 483 |
484 self.use_equipment(categorised) | |
485 | |
178 | 486 if cat.DOOMSDAY_DEVICE in categorised: |
175 | 487 self.data['completed'] = True |
488 self.succeed( | |
489 "The fools cower in terror at your display of power. Finally" | |
490 " they are forced to acknowledge your genius.", | |
491 rep=randint(10, 15)) | |
492 | |
493 if cat.BEAST in categorised: | |
179 | 494 if all(cat.AQUATIC in x.CATEGORIES for x in |
175 | 495 categorised[cat.BEAST]): |
176 | 496 self.fail( |
497 "While the beast is terrifying, the effect is" | |
498 " unfortuantely significantly lessened the need for a " | |
499 " large water tank, and the it's inability to move " | |
179 | 500 " independantly. Perhaps you need to rethink your plan?") |
176 | 501 else: |
175 | 502 self.data['completed'] = True |
503 self.succeed( | |
504 "Your monstrous creation rampages through campus in a" | |
505 " most statisfying way. They will not forgot this.", | |
506 rep=randint(5, 12)) | |
507 | |
508 if cat.HAND_WEAPON in categorised: | |
509 self.fail( | |
510 "Mere crude force is not the answer. You need some more" | |
511 " fitting demonstration of your power.") | |
176 | 512 |
513 | |
514 class SubvertNews(Mission): | |
515 NAME = "Subvert the news network" | |
516 SHORT_DESCRIPTION = "Stop the lies!" | |
517 LONG_DESCRIPTION = ( | |
518 "Worringly, people appear to be easily duped by the lies broadcast" | |
519 " about you. Time to fight fire with fire!") | |
520 | |
521 MINIMUM_REPUTATION = 15 | |
522 MINIMUM_MILESTONE = "neighbourhood" | |
523 | |
524 NO_EQUIP_FAILURE = ( | |
525 "You fail to even get into the building. Perhaps you need to" | |
526 " rethink your approach") | |
527 | |
528 def attempt_with(self, categorised, state): | |
529 | |
530 self.use_equipment(categorised) | |
531 | |
532 if cat.MIND_CONTROL in categorised: | |
533 self.succeed( | |
534 "With the proper equipment, it's a simple matter to" | |
535 " convince people of the correctness of your point" | |
536 " of view. If only everything were so simple", | |
537 rep=randint(5, 15)) | |
538 | |
178 | 539 if cat.AI in categorised: |
176 | 540 self.succeed( |
541 "Your AI has complete control of the broadcasters computer" | |
542 " system. After all, it's not censorship if you're stopping" | |
543 " them broadcasting blatant lies, now is it?", | |
544 rep=randint(5, 10)) | |
545 | |
178 | 546 if any(c in categorised for c in (cat.VEHICLE, cat.DOOMSDAY_DEVICE, |
547 cat.BEAST)): | |
176 | 548 self.succeed( |
549 "Cowering in fear, the broadcaster agrees to change the" | |
550 " tone of their stories.", rep=randint(2, 5)) | |
551 | |
178 | 552 if cat.HAND_WEAPON in categorised: |
176 | 553 self.fail( |
554 "The news station's security is surprisingly well prepared." | |
179 | 555 " Perhaps you should rethink your approach?", |
176 | 556 rep=-randint(5, 10)) |
177
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
557 |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
558 |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
559 class RaidLab(Mission): |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
560 NAME = "Raid Rival Lab" |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
561 SHORT_DESCRIPTION = "Why not let other people work for you?" |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
562 LONG_DESCRIPTION = ( |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
563 "While clearly no match for your genius, sometimes your rivals stumble" |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
564 " onto something interesting. Surely their results can be put to" |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
565 " better use helping your plans?") |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
566 |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
567 MINIMUM_MILESTONE = "neighbourhood" |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
568 |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
569 NO_EQUIP_FAILURE = ( |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
570 "Your rival may not be the sharpest tool in the shed, but even a" |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
571 " fool invests in some defenses. You'll need to be better prepared" |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
572 " in the future.") |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
573 |
180
8868ac7ece8b
Tweak steal research mission
Neil Muller <drnlmuller@gmail.com>
parents:
179
diff
changeset
|
574 def _succ(self, msg, state): |
177
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
575 reward = choice(('schematic', 'science', |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
576 'money', 'money', 'money', 'money', 'money', |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
577 'nothing', 'nothing', 'nothing')) |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
578 if reward == 'nothing': |
180
8868ac7ece8b
Tweak steal research mission
Neil Muller <drnlmuller@gmail.com>
parents:
179
diff
changeset
|
579 self.succeed("%s Unfortunately, not only are these people working" |
8868ac7ece8b
Tweak steal research mission
Neil Muller <drnlmuller@gmail.com>
parents:
179
diff
changeset
|
580 " on ideas you've already covered, they're flat broke." % msg, |
8868ac7ece8b
Tweak steal research mission
Neil Muller <drnlmuller@gmail.com>
parents:
179
diff
changeset
|
581 money=0, rep=1) |
177
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
582 elif reward == 'money': |
180
8868ac7ece8b
Tweak steal research mission
Neil Muller <drnlmuller@gmail.com>
parents:
179
diff
changeset
|
583 self.succeed("%s While their research yields nothing of interest," |
8868ac7ece8b
Tweak steal research mission
Neil Muller <drnlmuller@gmail.com>
parents:
179
diff
changeset
|
584 " you can repurpose their funding to more worthy causes." |
8868ac7ece8b
Tweak steal research mission
Neil Muller <drnlmuller@gmail.com>
parents:
179
diff
changeset
|
585 % msg, money=randint(1000, 2000), rep=1) |
177
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
586 elif reward == 'schematic': |
180
8868ac7ece8b
Tweak steal research mission
Neil Muller <drnlmuller@gmail.com>
parents:
179
diff
changeset
|
587 self.succeed("%s You find the plans for a new device. How did" |
8868ac7ece8b
Tweak steal research mission
Neil Muller <drnlmuller@gmail.com>
parents:
179
diff
changeset
|
588 " these fools stumble upon this?" % msg, |
8868ac7ece8b
Tweak steal research mission
Neil Muller <drnlmuller@gmail.com>
parents:
179
diff
changeset
|
589 money=0, rep=randint(2, 5), |
8868ac7ece8b
Tweak steal research mission
Neil Muller <drnlmuller@gmail.com>
parents:
179
diff
changeset
|
590 new_schematic=choice(state.lab.new_schematics)) |
177
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
591 # New science |
180
8868ac7ece8b
Tweak steal research mission
Neil Muller <drnlmuller@gmail.com>
parents:
179
diff
changeset
|
592 self.succeed("%s Their notes are most illuminating. You realise you" |
8868ac7ece8b
Tweak steal research mission
Neil Muller <drnlmuller@gmail.com>
parents:
179
diff
changeset
|
593 " have sadly neglected research into this field." % msg, |
8868ac7ece8b
Tweak steal research mission
Neil Muller <drnlmuller@gmail.com>
parents:
179
diff
changeset
|
594 money=0, rep=randint(2, 5), |
8868ac7ece8b
Tweak steal research mission
Neil Muller <drnlmuller@gmail.com>
parents:
179
diff
changeset
|
595 new_science=choice(state.lab.new_research)) |
177
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
596 |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
597 def attempt_with(self, categorised, state): |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
598 |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
599 self.use_equipment(categorised) |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
600 |
178 | 601 if cat.DOOMSDAY_DEVICE in categorised: |
177
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
602 self.fail( |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
603 "While overwhelming force is always a tempting choice," |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
604 " total destruction of the lab will not help you cause.") |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
605 |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
606 if cat.AI in categorised: |
180
8868ac7ece8b
Tweak steal research mission
Neil Muller <drnlmuller@gmail.com>
parents:
179
diff
changeset
|
607 self._succ("Your AI easily takes control of the lab's network.", |
177
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
608 state) |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
609 |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
610 if self.combat_power(categorised) > randint(20, 40): |
180
8868ac7ece8b
Tweak steal research mission
Neil Muller <drnlmuller@gmail.com>
parents:
179
diff
changeset
|
611 self._succ( |
177
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
612 "The resistance is stiff, but your forces prevail" |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
613 " thanks to your superior technology.", state) |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
614 else: |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
615 self.fail( |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
616 "The lab is surprisingly well defended for an operation" |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
617 " run by a total fool. You vow to return with a better" |
4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
Neil Muller <drnlmuller@gmail.com>
parents:
176
diff
changeset
|
618 " prepared force.") |