comparison gamelib/missions.py @ 85:182fce9f70b6

Propaganda! Also, a fix to blueprint breakthroughs.
author Jeremy Thurgood <firxen@gmail.com>
date Wed, 09 May 2012 20:02:28 +0200
parents a40a76012bd7
children 13550947a330
comparison
equal deleted inserted replaced
84:9d0ad8aeb598 85:182fce9f70b6
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 # vim:fileencoding=utf-8 ai ts=4 sts=4 et sw=4 2 # vim:fileencoding=utf-8 ai ts=4 sts=4 et sw=4
3 3
4 from random import random 4 from random import randint
5 5
6 from gamelib.constants import SUCCESS, FAILURE 6 from gamelib.constants import SUCCESS, FAILURE
7 from gamelib.schematics import HAND_WEAPON, VEHICLE, PATHOGEN, DOOMSDAY_DEVICE 7 from gamelib.schematics import cat
8 8
9 9
10 class Result(object): 10 class Result(object):
11 """Results of a mission""" 11 """Results of a mission"""
12 12
98 LONG_DESCRIPTION = ( 98 LONG_DESCRIPTION = (
99 "It's not menancing, or lucrative, but when the bills are due, no one" 99 "It's not menancing, or lucrative, but when the bills are due, no one"
100 " cares how you earn the money.") 100 " cares how you earn the money.")
101 101
102 def attempt(self, equipment, state): 102 def attempt(self, equipment, state):
103 haul = 90 + int(random() * 20) 103 haul = randint(90, 110)
104 return Result(SUCCESS, haul, -1, ( 104 return Result(SUCCESS, haul, -1, (
105 "You devote your resources to robbing kids in a playpark." 105 "You devote your resources to robbing kids in a playpark."
106 " It's not the finest moment in your reign of terror, but at" 106 " It's not the finest moment in your reign of terror, but at"
107 " least you walked away with a surprising amount of small" 107 " least you walked away with a surprising amount of small"
108 " change.")) 108 " change."))
135 " them ransom with... well... nothing. Nothing at all. This" 135 " them ransom with... well... nothing. Nothing at all. This"
136 " one will probably make a good anecdote at diplomatic" 136 " one will probably make a good anecdote at diplomatic"
137 " cocktail parties. But not for you. No, not for you at all.")) 137 " cocktail parties. But not for you. No, not for you at all."))
138 138
139 def attempt_with(self, categorised, state): 139 def attempt_with(self, categorised, state):
140 dooms = categorised.get(DOOMSDAY_DEVICE, []) 140 dooms = categorised.get(cat.DOOMSDAY_DEVICE, [])
141 141
142 if not dooms: 142 if not dooms:
143 return Result(FAILURE, 0, -1, ( 143 return Result(FAILURE, 0, -1, (
144 "You completely fail to inspire the requisite level of" 144 "You completely fail to inspire the requisite level of"
145 " terror. Maybe a more impressive threat will fare" 145 " terror. Maybe a more impressive threat will fare"
179 "The border post may be poorly guarded, but you need to" 179 "The border post may be poorly guarded, but you need to"
180 " bring *some* kind of weaponry along. Your troops sulk" 180 " bring *some* kind of weaponry along. Your troops sulk"
181 " on the way home.")) 181 " on the way home."))
182 182
183 def attempt_with(self, categorised, state): 183 def attempt_with(self, categorised, state):
184 if any(c in categorised for c in (VEHICLE, HAND_WEAPON)): 184 if any(c in categorised for c in (cat.VEHICLE, cat.HAND_WEAPON)):
185 return Result(SUCCESS, 5000 + int(random() * 10000), 5, ( 185 return Result(SUCCESS, randint(5000, 15000), randint(3, 7), (
186 "The corruption and oppression continue, but at least" 186 "The corruption and oppression continue, but at least"
187 " the proceeds are making their way into *your*" 187 " the proceeds are making their way into *your*"
188 " pockets. And you don't even have to dirty your own" 188 " pockets. And you don't even have to dirty your own"
189 " jackboots.")) 189 " jackboots."))
190 190
191 if DOOMSDAY_DEVICE in categorised: 191 if cat.DOOMSDAY_DEVICE in categorised:
192 return Result(FAILURE, 0, 0, ( 192 return Result(FAILURE, 0, 0, (
193 "Nobody seems to quite understand what it is you're" 193 "Nobody seems to quite understand what it is you're"
194 " threatening them with. Eventually you have to give up" 194 " threatening them with. Eventually you have to give up"
195 " and go home.")) 195 " and go home."))
196 196
208 "Your attempt to rob the bank barehanded is unsuccessful." 208 "Your attempt to rob the bank barehanded is unsuccessful."
209 " Fortunately, everyone is too stunned to impede your" 209 " Fortunately, everyone is too stunned to impede your"
210 " escape.")) 210 " escape."))
211 211
212 def attempt_with(self, categorised, state): 212 def attempt_with(self, categorised, state):
213 loot = 500 + int(random() * 1000) 213 loot = randint(500, 1500)
214 214
215 if VEHICLE in categorised: 215 if cat.VEHICLE in categorised:
216 return Result(FAILURE, 0, 0, ( 216 return Result(FAILURE, 0, 0, (
217 "Your vehicles are impressively doom-laden, but not really" 217 "Your vehicles are impressively doom-laden, but not really"
218 " suitable for city traffic. You intimidate the traffic" 218 " suitable for city traffic. You intimidate the traffic"
219 " wardens into letting you off without a fine, but by the" 219 " wardens into letting you off without a fine, but by the"
220 " time you get to the bank it's already closed.")) 220 " time you get to the bank it's already closed."))
221 221
222 if HAND_WEAPON in categorised: 222 if cat.HAND_WEAPON in categorised:
223 return Result(SUCCESS, loot, 0, ( 223 return Result(SUCCESS, loot, 0, (
224 "The threat of your weapons is enough to inspire an" 224 "The threat of your weapons is enough to inspire an"
225 " impressive level of cooperation. You make off with the" 225 " impressive level of cooperation. You make off with the"
226 " loot.")) 226 " loot."))
227 227
228 if PATHOGEN in categorised: 228 if cat.PATHOGEN in categorised:
229 if state.reputation < 10: 229 if state.reputation < 10:
230 return Result(FAILURE, 0, 0, ( 230 return Result(FAILURE, 0, 0, (
231 "The clerk doesn't realise the threat of" 231 "The clerk doesn't realise the threat of"
232 " the vial you hold, and, although watching him" 232 " the vial you hold, and, although watching him"
233 " die in agony would be statisfying, you decide" 233 " die in agony would be statisfying, you decide"
249 249
250 def attempt(self, equipment, state): 250 def attempt(self, equipment, state):
251 self.completed = True 251 self.completed = True
252 return Result(SUCCESS, 0, 50, ( 252 return Result(SUCCESS, 0, 50, (
253 "Mount Rushmore is remarkably easy to destroy.")) 253 "Mount Rushmore is remarkably easy to destroy."))
254
255
256 class DistributePamphlets(Mission):
257
258 NAME = "Distribute pamphlets"
259 SHORT_DESCRIPTION = "The populace need to be told the truth!"
260 LONG_DESCRIPTION = (
261 "A focused pamphlet distribution campaign will combat the lies being"
262 " spread about you. Replacing them with better lies, of course.")
263
264 SUCCESS_MESSAGE = (
265 "A small army of urchins delivers thousands of cheaply printed"
266 " pamphlets. %s")
267
268 def attempt_no_equipment(self, state):
269 rep = randint(-2, 5)
270
271 if rep < 0:
272 result = (
273 "Sadly, the populace was so annoyed by the flood of flyers"
274 " that nobody took any notice of the content.")
275 elif rep == 0:
276 result = "Nobody seems to have noticed."
277 else:
278 result = "The public seemed mildly receptive to your propaganda."
279
280 return Result(SUCCESS, 0, rep, self.SUCCESS_MESSAGE % (result,))
281
282 def attempt_with(self, categorised, state):
283 rep = randint(5, 10)
284
285 if cat.MIND_CONTROL in categorised:
286 result = (
287 "Your creative use of science has paid off nicely.")
288 return Result(SUCCESS, 0, rep, self.SUCCESS_MESSAGE % (result,))
289 else:
290 return self.attempt_no_equipment(state)