annotate gamelib/missions.py @ 137:fb8037bc22f1

More flexible (and less boilerplatey) mission stuff.
author Jeremy Thurgood <firxen@gmail.com>
date Thu, 10 May 2012 20:56:40 +0200
parents be79e113d494
children 14917385a0fd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
2 # vim:fileencoding=utf-8 ai ts=4 sts=4 et sw=4
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
3
85
182fce9f70b6 Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 80
diff changeset
4 from random import randint
36
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
5
123
7cd716328a44 Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents: 96
diff changeset
6 from gamelib.constants import SUCCESS, FAILURE, GAME_WIN, NEW_MILESTONE, 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
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
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
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
16 def __init__(self, outcome, msg, money=0, rep=0):
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
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
21 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
22
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 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
24 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
25 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
26 state.reputation += self.reputation
c0966997e0c5 Use a results object instead of tuple (will hopefully make changign stuff easier later)
Neil Muller <drnlmuller@gmail.com>
parents: 10
diff changeset
27 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
28 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
29 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
30
c0966997e0c5 Use a results object instead of tuple (will hopefully make changign stuff easier later)
Neil Muller <drnlmuller@gmail.com>
parents: 10
diff changeset
31
5
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
32 class Mission(object):
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
33 """Base class for the mission objects.
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
34 Missions have a name, short description (for list displays) and
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
35 long description (which may contain clues about approaches)"""
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
36
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
37 NAME = "Generic Mission"
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
38 SHORT_DESCRIPTION = None
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
39 LONG_DESCRIPTION = None
96
50f8476aa929 Some milestones.
Jeremy Thurgood <firxen@gmail.com>
parents: 95
diff changeset
40
33
12c33aac7684 Gate certain missions by reputation.
Jeremy Thurgood <firxen@gmail.com>
parents: 32
diff changeset
41 MINIMUM_REPUTATION = None
96
50f8476aa929 Some milestones.
Jeremy Thurgood <firxen@gmail.com>
parents: 95
diff changeset
42 MINIMUM_MILESTONE = "neighbourhood"
124
685301e35f88 Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents: 123
diff changeset
43 MINIONS_REQUIRED = 1
5
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
44
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
45 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
46 GENERIC_SUCCESS = "Victory is sweet."
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
47 NO_EQUIP_FAILURE = (
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
48 "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
49 " foolish. And ultimately unsuccessful.")
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
50
22
296ce36fa7d9 Serialize and unserialize game state and missions
Neil Muller <drnlmuller@gmail.com>
parents: 19
diff changeset
51 def __init__(self, init_data=None):
91
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
52 self.data = {}
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
53
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
54 if init_data is not None:
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
55 # Load stored state.
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
56 self._load_data(init_data)
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
57 else:
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
58 # New instance.
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
59 self._new_data()
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
60
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
61 def _new_data(self):
22
296ce36fa7d9 Serialize and unserialize game state and missions
Neil Muller <drnlmuller@gmail.com>
parents: 19
diff changeset
62 pass
296ce36fa7d9 Serialize and unserialize game state and missions
Neil Muller <drnlmuller@gmail.com>
parents: 19
diff changeset
63
91
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
64 def _load_data(self, init_data):
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
65 # Note: this does not deep-copy.
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
66 self.data = init_data.copy()
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
67
22
296ce36fa7d9 Serialize and unserialize game state and missions
Neil Muller <drnlmuller@gmail.com>
parents: 19
diff changeset
68 def save_data(self):
91
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
69 # Note: this does not deep-copy.
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
70 return self.data.copy()
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
71
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
72 def get_data(self, key):
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
73 return self.data.get(key, None)
22
296ce36fa7d9 Serialize and unserialize game state and missions
Neil Muller <drnlmuller@gmail.com>
parents: 19
diff changeset
74
94
245ef50de84d Sanity-check research, schematic and mission classes. (Ironic, no?)
Jeremy Thurgood <firxen@gmail.com>
parents: 92
diff changeset
75 @classmethod
245ef50de84d Sanity-check research, schematic and mission classes. (Ironic, no?)
Jeremy Thurgood <firxen@gmail.com>
parents: 92
diff changeset
76 def sanity_check(cls):
245ef50de84d Sanity-check research, schematic and mission classes. (Ironic, no?)
Jeremy Thurgood <firxen@gmail.com>
parents: 92
diff changeset
77 pass
245ef50de84d Sanity-check research, schematic and mission classes. (Ironic, no?)
Jeremy Thurgood <firxen@gmail.com>
parents: 92
diff changeset
78
41
e285b1e31a08 Add can_attempt method for future flexibility
Neil Muller <drnlmuller@gmail.com>
parents: 36
diff changeset
79 def can_attempt(self, state):
e285b1e31a08 Add can_attempt method for future flexibility
Neil Muller <drnlmuller@gmail.com>
parents: 36
diff changeset
80 """Can we currently attempt the mission"""
96
50f8476aa929 Some milestones.
Jeremy Thurgood <firxen@gmail.com>
parents: 95
diff changeset
81 if (M_VALS[self.MINIMUM_MILESTONE] > M_VALS[state.milestone]):
50f8476aa929 Some milestones.
Jeremy Thurgood <firxen@gmail.com>
parents: 95
diff changeset
82 # Our base of operations is too small
50f8476aa929 Some milestones.
Jeremy Thurgood <firxen@gmail.com>
parents: 95
diff changeset
83 return False
91
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
84 if self.get_data('completed'):
41
e285b1e31a08 Add can_attempt method for future flexibility
Neil Muller <drnlmuller@gmail.com>
parents: 36
diff changeset
85 return False
e285b1e31a08 Add can_attempt method for future flexibility
Neil Muller <drnlmuller@gmail.com>
parents: 36
diff changeset
86 if (self.MINIMUM_REPUTATION is not None and
91
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
87 self.MINIMUM_REPUTATION > state.reputation):
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
88 # Don't have the reputation required
41
e285b1e31a08 Add can_attempt method for future flexibility
Neil Muller <drnlmuller@gmail.com>
parents: 36
diff changeset
89 return False
124
685301e35f88 Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents: 123
diff changeset
90 if self.MINIONS_REQUIRED > state.minions:
685301e35f88 Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents: 123
diff changeset
91 # Need more minions!
685301e35f88 Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents: 123
diff changeset
92 return False
41
e285b1e31a08 Add can_attempt method for future flexibility
Neil Muller <drnlmuller@gmail.com>
parents: 36
diff changeset
93 return True
e285b1e31a08 Add can_attempt method for future flexibility
Neil Muller <drnlmuller@gmail.com>
parents: 36
diff changeset
94
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
95 def fail(self, msg=None, money=0, rep=0):
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
96 if msg is None:
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
97 msg = self.GENERIC_FAILURE
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
98 raise Result(FAILURE, msg, money=money, rep=rep)
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
99
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
100 def succeed(self, msg=None, money=0, rep=0):
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
101 if msg is None:
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
102 msg = self.GENERIC_SUCCESS
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
103 raise Result(SUCCESS, msg, money=money, rep=rep)
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
104
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
105 def categorise_equipment(self, equipment):
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
106 # Categorise equipment for easier decision-making.
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
107 categorised = {}
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
108 for item in equipment:
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
109 for category in item.CATEGORIES:
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
110 categorised.setdefault(category, []).append(item)
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
111 return categorised
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
112
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
113 def attempt_mission(self, equipment, state):
5
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
114 """Attempt the mission with the given equipment list.
36
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
115 Returns a result object with the results of the mission."""
5
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
116
41
e285b1e31a08 Add can_attempt method for future flexibility
Neil Muller <drnlmuller@gmail.com>
parents: 36
diff changeset
117 # Handle error case
91
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
118 if self.get_data('completed'):
41
e285b1e31a08 Add can_attempt method for future flexibility
Neil Muller <drnlmuller@gmail.com>
parents: 36
diff changeset
119 raise RuntimeError('Cannot attempt a completed mission')
e285b1e31a08 Add can_attempt method for future flexibility
Neil Muller <drnlmuller@gmail.com>
parents: 36
diff changeset
120
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
121 try:
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
122 self.attempt(equipment, state)
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
123 except Result, e:
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
124 return e
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(self, equipment, state):
36
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
127 # No equipment is usually a special case.
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
128 if not equipment:
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
129 return self.attempt_no_equipment(state)
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
130
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
131 # Try with some equipment.
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
132 self.attempt_with(self.categorise_equipment(equipment), state)
36
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
133
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
134 # No result, so generic failure.
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
135 self.fail()
36
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
136
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
137 def attempt_no_equipment(self, state):
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
138 self.fail(self.NO_EQUIP_FAILURE)
36
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
139
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
140 def attempt_with(self, categorised, state):
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
141 self.fail("You can't succceed at this mission.")
5
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
142
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
143
19
12085dfd9e69 Add rescue mission for the out of money case
Neil Muller <drnlmuller@gmail.com>
parents: 18
diff changeset
144 class PlaygroundBully(Mission):
12085dfd9e69 Add rescue mission for the out of money case
Neil Muller <drnlmuller@gmail.com>
parents: 18
diff changeset
145
12085dfd9e69 Add rescue mission for the out of money case
Neil Muller <drnlmuller@gmail.com>
parents: 18
diff changeset
146 NAME = "Rob kids in the playground"
36
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
147 SHORT_DESCRIPTION = "Steal from those significantly weaker than yourself."
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
148 LONG_DESCRIPTION = (
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
149 "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
150 " 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
151
96
50f8476aa929 Some milestones.
Jeremy Thurgood <firxen@gmail.com>
parents: 95
diff changeset
152 MINIMUM_MILESTONE = "basement"
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
153 GENERIC_SUCCESS = (
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
154 "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
155 " 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
156 " with a surprising amount of small change.")
96
50f8476aa929 Some milestones.
Jeremy Thurgood <firxen@gmail.com>
parents: 95
diff changeset
157
32
00aff02bc6fc Product categories.
Jeremy Thurgood <firxen@gmail.com>
parents: 25
diff changeset
158 def attempt(self, equipment, state):
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
159 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
160
12085dfd9e69 Add rescue mission for the out of money case
Neil Muller <drnlmuller@gmail.com>
parents: 18
diff changeset
161
5
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
162 class RansomChina(Mission):
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
163
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
164 NAME = "Hold China to ransom"
36
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
165 SHORT_DESCRIPTION = "Surely a path to riches and fame."
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
166 LONG_DESCRIPTION = (
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
167 "Holding China to ransom. The rewards for successfully threatening"
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
168 " 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
169 " significant. Without some serious firepower, the chances of success"
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
170 " are small.")
96
50f8476aa929 Some milestones.
Jeremy Thurgood <firxen@gmail.com>
parents: 95
diff changeset
171
33
12c33aac7684 Gate certain missions by reputation.
Jeremy Thurgood <firxen@gmail.com>
parents: 32
diff changeset
172 MINIMUM_REPUTATION = 100
96
50f8476aa929 Some milestones.
Jeremy Thurgood <firxen@gmail.com>
parents: 95
diff changeset
173 MINIMUM_MILESTONE = "city"
5
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
174
91
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
175 def _new_data(self):
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
176 self.data['prior_attempts'] = []
5
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
177
36
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
178 def attempt_no_equipment(self, state):
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
179 self.fail(
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
180 "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
181 " 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
182 " 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
183 " 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
184 " 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
185 rep=-10)
36
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
186
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
187 def attempt_with(self, categorised, state):
85
182fce9f70b6 Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 80
diff changeset
188 dooms = categorised.get(cat.DOOMSDAY_DEVICE, [])
36
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
189
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
190 if not dooms:
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
191 self.fail(
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
192 "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
193 " 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
194 rep=-1)
36
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
195
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
196 if len(dooms) > 1:
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
197 self.fail(
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
198 "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
199 " to cause widepsread distruction and mayhem, and"
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
200 " 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
201 " 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
202
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
203 [doom] = dooms
91
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
204 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
205 self.fail(
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
206 "'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
207 " You cannot threaten us with that again.'")
36
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
208
91
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
209 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
210 self.succeed(
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
211 "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
212 " government pays the ransom.",
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
213 money=randint(800000, 1200000), rep=10)
5
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
214
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
215
35
2754c453b39b Topple a government.
Jeremy Thurgood <firxen@gmail.com>
parents: 34
diff changeset
216 class ToppleThirdWorldGovernment(Mission):
2754c453b39b Topple a government.
Jeremy Thurgood <firxen@gmail.com>
parents: 34
diff changeset
217
2754c453b39b Topple a government.
Jeremy Thurgood <firxen@gmail.com>
parents: 34
diff changeset
218 NAME = "Topple a third-world government"
36
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
219 SHORT_DESCRIPTION = "We could use a more amenable dictator there."
35
2754c453b39b Topple a government.
Jeremy Thurgood <firxen@gmail.com>
parents: 34
diff changeset
220 LONG_DESCRIPTION = (
2754c453b39b Topple a government.
Jeremy Thurgood <firxen@gmail.com>
parents: 34
diff changeset
221 "It's a small and fairly useless country, but it's still an actual"
2754c453b39b Topple a government.
Jeremy Thurgood <firxen@gmail.com>
parents: 34
diff changeset
222 " government that can be toppled. A good test bed for some of the"
2754c453b39b Topple a government.
Jeremy Thurgood <firxen@gmail.com>
parents: 34
diff changeset
223 " larger toys in the armory.")
96
50f8476aa929 Some milestones.
Jeremy Thurgood <firxen@gmail.com>
parents: 95
diff changeset
224
35
2754c453b39b Topple a government.
Jeremy Thurgood <firxen@gmail.com>
parents: 34
diff changeset
225 MINIMUM_REPUTATION = 50
2754c453b39b Topple a government.
Jeremy Thurgood <firxen@gmail.com>
parents: 34
diff changeset
226
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
227 GENERIC_FAILURE = (
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
228 "Nobody seems to quite understand what it is you're threatening them"
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
229 " with. Eventually you have to give up and go home.")
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
230
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
231 NO_EQUIP_FAILURE = (
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
232 "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
233 " 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
234
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
235 def attempt_with(self, categorised, state):
85
182fce9f70b6 Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 80
diff changeset
236 if any(c in categorised for c in (cat.VEHICLE, cat.HAND_WEAPON)):
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
237 self.succeed(
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
238 "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
239 " 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
240 " 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
241 money=randint(5000, 15000), rep=randint(3, 7))
35
2754c453b39b Topple a government.
Jeremy Thurgood <firxen@gmail.com>
parents: 34
diff changeset
242
2754c453b39b Topple a government.
Jeremy Thurgood <firxen@gmail.com>
parents: 34
diff changeset
243
5
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
244 class RobBank(Mission):
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
245
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
246 NAME = "Rob the local bank"
36
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
247 SHORT_DESCRIPTION = "A trivial challenge, but easy money."
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
248 LONG_DESCRIPTION = (
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
249 "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
250 " 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
251
96
50f8476aa929 Some milestones.
Jeremy Thurgood <firxen@gmail.com>
parents: 95
diff changeset
252 MINIMUM_MILESTONE = "basement"
50f8476aa929 Some milestones.
Jeremy Thurgood <firxen@gmail.com>
parents: 95
diff changeset
253
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
254 GENERIC_FAILURE = (
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
255 "The operation was a complete fiasco. Maybe you should try something a"
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
256 " little less eclectic next time.")
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
257 NO_EQUIP_FAILURE = (
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
258 "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
259 " everyone is too stunned to impede your escape.")
36
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
260
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
261 def attempt_with(self, categorised, state):
85
182fce9f70b6 Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 80
diff changeset
262 loot = randint(500, 1500)
5
dd9046d0680c Sketch in mission objects
Neil Muller <drnlmuller@gmail.com>
parents:
diff changeset
263
85
182fce9f70b6 Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 80
diff changeset
264 if cat.VEHICLE in categorised:
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
265 self.fail(
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
266 "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
267 " 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
268 " 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
269 " 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
270
85
182fce9f70b6 Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 80
diff changeset
271 if cat.HAND_WEAPON in categorised:
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
272 self.succeed(
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
273 "The threat of your weapons is enough to inspire an impressive"
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
274 " level of cooperation. You make off with the loot.",
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
275 money=loot)
36
efc4f90cfd63 Mission refactoring and research fix.
Jeremy Thurgood <firxen@gmail.com>
parents: 35
diff changeset
276
85
182fce9f70b6 Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 80
diff changeset
277 if cat.PATHOGEN in categorised:
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
278 if randint(5, 15) < state.reputation:
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
279 self.fail(
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
280 "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
281 " 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
282 " 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
283 " something so trivial.")
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
284 self.succeed(
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
285 "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
286 " that is power.",
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
287 money=loot, rep=1)
10
9f8def7d70d0 Rework mission objects to include reputation
Neil Muller <drnlmuller@gmail.com>
parents: 5
diff changeset
288
9f8def7d70d0 Rework mission objects to include reputation
Neil Muller <drnlmuller@gmail.com>
parents: 5
diff changeset
289
9f8def7d70d0 Rework mission objects to include reputation
Neil Muller <drnlmuller@gmail.com>
parents: 5
diff changeset
290 class DestroyMountRushmore(Mission):
9f8def7d70d0 Rework mission objects to include reputation
Neil Muller <drnlmuller@gmail.com>
parents: 5
diff changeset
291
9f8def7d70d0 Rework mission objects to include reputation
Neil Muller <drnlmuller@gmail.com>
parents: 5
diff changeset
292 NAME = "Destroy Mount Rushmore"
9f8def7d70d0 Rework mission objects to include reputation
Neil Muller <drnlmuller@gmail.com>
parents: 5
diff changeset
293 SHORT_DESCRIPTION = "Monuments to other people? Intolerable"
92
56b0a1c4de35 Fix typo
Neil Muller <drnlmuller@gmail.com>
parents: 91
diff changeset
294 LONG_DESCRIPTION = (
56b0a1c4de35 Fix typo
Neil Muller <drnlmuller@gmail.com>
parents: 91
diff changeset
295 "While potentially expensive, destroying a major monument is a"
56b0a1c4de35 Fix typo
Neil Muller <drnlmuller@gmail.com>
parents: 91
diff changeset
296 " good way to secure your reputation.")
33
12c33aac7684 Gate certain missions by reputation.
Jeremy Thurgood <firxen@gmail.com>
parents: 32
diff changeset
297 MINIMUM_REPUTATION = 20
10
9f8def7d70d0 Rework mission objects to include reputation
Neil Muller <drnlmuller@gmail.com>
parents: 5
diff changeset
298
9f8def7d70d0 Rework mission objects to include reputation
Neil Muller <drnlmuller@gmail.com>
parents: 5
diff changeset
299 def attempt(self, equipment, state):
91
c57b5b46d3e0 Better mission data management.
Jeremy Thurgood <firxen@gmail.com>
parents: 86
diff changeset
300 self.data['completed'] = True
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
301 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
302
182fce9f70b6 Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 80
diff changeset
303
182fce9f70b6 Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 80
diff changeset
304 class DistributePamphlets(Mission):
182fce9f70b6 Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 80
diff changeset
305
182fce9f70b6 Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 80
diff changeset
306 NAME = "Distribute pamphlets"
182fce9f70b6 Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 80
diff changeset
307 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
308 LONG_DESCRIPTION = (
182fce9f70b6 Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 80
diff changeset
309 "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
310 " 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
311
96
50f8476aa929 Some milestones.
Jeremy Thurgood <firxen@gmail.com>
parents: 95
diff changeset
312 MINIMUM_MILESTONE = "basement"
50f8476aa929 Some milestones.
Jeremy Thurgood <firxen@gmail.com>
parents: 95
diff changeset
313
85
182fce9f70b6 Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 80
diff changeset
314 SUCCESS_MESSAGE = (
182fce9f70b6 Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 80
diff changeset
315 "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
316 " pamphlets. %s")
182fce9f70b6 Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 80
diff changeset
317
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
318 def _succ(self, message, rep):
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
319 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
320
85
182fce9f70b6 Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 80
diff changeset
321 def attempt_no_equipment(self, state):
182fce9f70b6 Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 80
diff changeset
322 rep = randint(-2, 5)
182fce9f70b6 Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 80
diff changeset
323
182fce9f70b6 Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 80
diff changeset
324 if rep < 0:
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
325 self._succ(
85
182fce9f70b6 Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 80
diff changeset
326 "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
327 " 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
328 if rep == 0:
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
329 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
330
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
331 self._succ(
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
332 "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
333
182fce9f70b6 Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 80
diff changeset
334 def attempt_with(self, categorised, state):
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
335 if cat.MIND_CONTROL in categorised:
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
336 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
337 randint(5, 10))
85
182fce9f70b6 Propaganda! Also, a fix to blueprint breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents: 80
diff changeset
338
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
339 return self.attempt_no_equipment(state)
95
0f437e0584f7 Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents: 94
diff changeset
340
0f437e0584f7 Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents: 94
diff changeset
341
0f437e0584f7 Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents: 94
diff changeset
342 class TakeOverTheWorld(Mission):
0f437e0584f7 Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents: 94
diff changeset
343
0f437e0584f7 Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents: 94
diff changeset
344 NAME = "Take over the world!"
0f437e0584f7 Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents: 94
diff changeset
345 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
346 LONG_DESCRIPTION = (
0f437e0584f7 Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents: 94
diff changeset
347 "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
348 " 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
349 " everyone.")
96
50f8476aa929 Some milestones.
Jeremy Thurgood <firxen@gmail.com>
parents: 95
diff changeset
350
95
0f437e0584f7 Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents: 94
diff changeset
351 MINIMUM_REPUTATION = 200
96
50f8476aa929 Some milestones.
Jeremy Thurgood <firxen@gmail.com>
parents: 95
diff changeset
352 MINIMUM_MILESTONE = "city"
95
0f437e0584f7 Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents: 94
diff changeset
353
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
354 NO_EQUIP_FAILURE = (
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
355 "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
356
0f437e0584f7 Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents: 94
diff changeset
357 def attempt_with(self, categorised, state):
0f437e0584f7 Add mission for taking over the world.
Simon Cross <hodgestar@gmail.com>
parents: 94
diff changeset
358 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
359 self.fail(
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
360 "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
361 " 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
362 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
363
7cd716328a44 Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents: 96
diff changeset
364
7cd716328a44 Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents: 96
diff changeset
365 class TakeOverTheNeighbourhood(Mission):
7cd716328a44 Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents: 96
diff changeset
366
7cd716328a44 Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents: 96
diff changeset
367 NAME = "Take over the neighbourhood!"
7cd716328a44 Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents: 96
diff changeset
368 SHORT_DESCRIPTION = "First step toward greatness."
7cd716328a44 Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents: 96
diff changeset
369 LONG_DESCRIPTION = (
7cd716328a44 Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents: 96
diff changeset
370 "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
371 " 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
372 " 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
373 " neighbourhood... that's quite feasible.")
7cd716328a44 Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents: 96
diff changeset
374
7cd716328a44 Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents: 96
diff changeset
375 MINIMUM_REPUTATION = 20
7cd716328a44 Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents: 96
diff changeset
376 MINIMUM_MILESTONE = "basement"
7cd716328a44 Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents: 96
diff changeset
377
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
378 NO_EQUIP_FAILURE = (
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
379 "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
380 " it over bare-handed.")
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
381 GENERIC_FAILURE = (
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
382 "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
383 " order.")
123
7cd716328a44 Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents: 96
diff changeset
384
7cd716328a44 Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents: 96
diff changeset
385 def attempt_with(self, categorised, state):
7cd716328a44 Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents: 96
diff changeset
386 if all(c in categorised for c in (cat.MIND_CONTROL, cat.HAND_WEAPON)):
129
be79e113d494 Fix typo
Neil Muller <drnlmuller@gmail.com>
parents: 124
diff changeset
387 self.data['completed'] = True
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
388 raise Result(NEW_MILESTONE, "Guns and persuasion, that's"
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
389 " all you need. It's early days still, but you're"
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
390 " finally out of that pokey basement and have some"
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
391 " elbow room to work with. Next step: the city!",
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
392 money=randint(1000, 2000), rep=randint(5, 15))
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
393
123
7cd716328a44 Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents: 96
diff changeset
394 if cat.HAND_WEAPON in categorised:
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
395 self.succeed(
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
396 "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
397 " 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
398
123
7cd716328a44 Take over the neighbourgood!
Jeremy Thurgood <firxen@gmail.com>
parents: 96
diff changeset
399 if cat.MIND_CONTROL in categorised:
137
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
400 self.succeed(
fb8037bc22f1 More flexible (and less boilerplatey) mission stuff.
Jeremy Thurgood <firxen@gmail.com>
parents: 129
diff changeset
401 "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
402 " some force to back them up.", rep=randint(2, 4))