-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweapons.py
342 lines (326 loc) · 13.9 KB
/
weapons.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
# Imports~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
from swordlore import *
# Classes~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Weapon Classes~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class WeaponCustom(object):
# Work in progress
def __init__(self, name, material, wrappable):
self.name = name
self.wrappable = wrappable
self.material = material
class WeaponHandle(object):
def __init__(self, name):
self.name = name
self.wrappable = True
self.material = 'standard'
def lore(self):
variation = self.name
lore = ''
wrapping = fabric()
encrusting = gem()
if boose([True]):
lore += choose([
'Its %s is ' %variation + boose([
'made of ' + material() + ' '
]) + 'encrusted with ' + encrusting,
'Its ' + encrusting + ' encrusted %s is ' %variation + choose([
'worn',
'smooth'
]) + ' from ' + choose([
'battle',
'use',
'combat'
])
])
else:
addition = choose([
'Its %s is ' %variation + boose([
'made of ' + material() + ' '
]) + boose([
boose([
'tightly '
]) + choose([
'wrapped',
'wound'
]) +' in ' + boose([
'worn',
'tattered',
'bloodstained',
'frayed'
]) + ' ' + wrapping
]),
'Its %s is ' %variation + choose([
'worn',
'smooth'
]) + ' from ' + choose([
'battle',
'use',
'combat'
])
])
if addition != 'Its %s is ' %variation:
lore += addition
lore = lore.replace('ts %s is and i' %variation, '')
return lore + '. '
class WeaponMain(object):
def __init__(self, name):
self.name = name
self.wrappable = False
self.material = 'standard'
def lore(self):
# Work in progress
# Makes the description for the main part of the weapon e.g. blade
variation = self.name
gocation = choose([
'the ' + choose([
'depths',
'flames',
'hearth',
'fires'
]) + ' of Hell', 'fire', 'flame',
choose([
'white',
'red'
]) + ' hot ' + choose([
'flames',
'fire'
]),
'darkness',
'the ' + forge(choose(['sword', ])), 'beneath ' + mountain()
])
# add material in here ^
time = choose([
'during the ' + age(),
'during the year ' + str(randint(1, 1500)),
'under ' + precep(moonphase()) + ' moon'
])
def commission():
# this makes the starting description for a sword commissioned
# currently in use in both the glass and metal swords
tlore = choose([
choose([
'The %s was ' %(variation),
'The %s is one of %d %ss ' %(variation, randint(2, 11), variation)
]),
choose([
'Commissioned',
'One of %d %ss commissioned' %(randint(2, 11), variation)
]) + ' by ' + choose([
royalty(),
council()
]) + ', it was ',
'The %s is a decorative %s gifted from %s to %s %s, it was '
%(variation, variation, royalty(), royalty(), boose(['as apeace offering']))
])
return tlore
def wroughtmain(gocation, time):
tlore = ''
if gocation[:7] != 'beneath':
gocation = 'in ' + gocation
else:
gocation = choose(['beneath', 'under', 'below']) + ' ' + gocation[7:]
body_metal = metal()
gild_metal = metal()
tlore += commission()
tlore += choose(['forged', 'wrought', 'cast', 'conceived'])
if gocation in ['in fire', 'in flame', 'in darkness', 'in the shadows']:
tlore += ' ' + gocation
tlore += ' from ' + body_metal + boose([
' and gilded with ' + gild_metal
])
tlore += ' by ' + professional('blacksmith', dobject='%s')
if gocation not in ['in fire', 'in flame', 'in darkness']:
tlore += ' ' + choose([gocation, time]) + '. '
else:
tlore += '. '
return tlore
def craftmain(time):
tlore = 'The %s was '%variation
tlore += choose(['painstakingly ', 'meticulously ', ''])
tlore += choose(['carved', 'crafted'])
tlore += ' from ' + boose(['one ' + boose(['solid']) + 'piece of '])
tlore += choose([biomaterial('large')])
tlore += boose([' by ' + professional('craftsman')])
tlore += boose([' ' + time])
tlore += '. '
return tlore
def glassmain(gocation, time):
tlore = ''
if gocation[:7] != 'beneath':
gocation = 'in ' + gocation
else:
gocation = choose(['beneath', 'under', 'below']) + ' ' + gocation[7:]
tlore += commission()
tlore += 'made from ' + glass()
tlore += boose([' by ' + professional('glassmith') + ' ' + boose([gocation, time])])
tlore += '. '
tlore += boose([
choose([
'A single ' + color() + ' ' + choose([
'rose',
'flower',
'feather'
]),
capitalize(precep(boose(['single ']) + bird() + ' feather')),
capitalize(precep(choose([
'salamander',
'frog',
'toad',
'newt',
'eft',
'olm',
'worm',
amphibian(),
spider(),
worm()
])))
]) + ' is ' + boose(['perfectly ']) + choose([
'encased',
'preserved'
]) + ' within the glass. '
])
return tlore
#temporary line change implementation later
known = True
if boose([True]):
# The code below adds swords with repaired cracks
if known:
lore = choose([
'A crack in the %s ' %variation + choose([
'has been filled with ' + metal(),
'was ' + choose(['filled', 'repaired']) + ' by ' + professional('blacksmith', dobject='sword')
]),
'Originally destroyed ' + choose([
'during',
'in'
]) + ' the ' + choose([
age(),
war()
]) + ', the %s was repaired by %s' %(variation, professional('blacksmith', dobject='sword')) + boose([
choose([
' in',
' during'
]) + ' the ' + choose([
age(),
war()
])
])
])
else:
lore = 'A crack in the %s has been filled with ' + metal()
lore += '. '
else:
lore = capitalize(enscript(variation))
lore = lore.replace(' ', ' ')
return choose([wroughtmain(gocation, time), glassmain(gocation, time), craftmain(time), lore])
class WeaponString(object):
def __init__(self, name):
self.name = name
self.wrappable = False
self.material = 'string'
def lore(self):
return 'the %s is made of %s. ' %(self.name,stringthing())
class Weapon(object):
def __init__(self, archetype, parts):
self.archetype = archetype
self.parts = parts
# These lore functions are not constant
# They depend on the current state
# (i.e. the result of these lore functions depends on the order in which they are called)
def partlore(self):
# Describes the lore of each individual part
return ''.join(map(lambda x: choose([x.lore(),'']), self.parts))
def historylore(self):
if boose([True]):
return choose([
'Wielded by ',
'In the hands of ',
'Held by '
]) + hero() + ', it ' + choose(['once ']) + choose([
'slew',
'defeated',
'killed',
'vanquished',
'struck down'
]) + ' ' + choose([
horde(),
beast()
]) + '. '
else:
return 'It was ' + choose([
'wielded by ',
'held by '
]) + hero()+',' + choose([
' in ',
' during '
]) + battle() + ' ' + boose([
' where it ' + choose([
'slew',
'killed'
]) + ' ' + choose([
hero(),
royalty()
])
]) + '. '
def strangelore(self):
lore = ''
def smell():
# describes the smell of the sword
# http://grammar.yourdictionary.com/style-and-usage/descriptive-words-for-scents.html#VrGLY7AqDbAPBGlv.99
smell = ['metal', blood(), 'sulfur', 'brimstone', 'smoke', 'bile', 'sweat', 'the sea', 'loam', fruit()]
smells = choose(smell, randint(1,2))
smell_descriptor = ['acrid', 'airy', 'clean', 'crisp', 'dirty', 'earthy', 'faint', 'fetid', 'fishy', 'fresh','floral', 'flowery', 'loamy', 'musty', 'nauseating', 'perfumed', 'pungent', 'putrid', 'rancid', 'redolent', 'repulsive', 'rotten', 'sharp', 'sour', 'stale', 'stinking', 'sweet']
return 'smells ' + boose([
'strongly ',
'faintly '
]) + choose([
'of ' + read_list(smells),
choose(smell_descriptor)
])
def detection():
# swords that react to a certain situation
signal = ['when ' + plural(
choose(['orc', 'goblin', 'troll', 'giant', 'cyclops', cavespawn()])) + ' are ' + choose(
['near', 'nearby']), 'in the presence of ' + boose(['dark', 'black']) + ' magic',
'when emersed in ' + choose(['magma', 'lava', 'fire', 'water']),
'when it touches ' + blood(), 'in ' + choose(['the dark', 'low light', 'bright light'])]
response = ['glows', 'glows ' + color(), 'turns ' + color(),
'becomes ' + choose(['cold', 'cool', 'warm', 'hot']), 'vibrates', 'pulses', 'shakes',
'>>> A hidden ' + script() + ' enscription becomes visible']
return choose(response) + ' ' + choose(signal)
def haunted():
# swords that are haunted by ghosts
haunts = choose(['is haunted by the ' + ghost(),
'>>>' + professional('wizard') + ', bound the ' + ghost(
) + ', to this ' + self.archetype])
return haunts
def maddening():
# swords that have lead their owners to ill fate
madness = 'has driven ' + boose(['all of ']) + 'its owners to '+choose(['madness', 'insanity', 'suicide'])
def useless():
# currently houses anything that I can't fit into any of the other generators above.
# I don't think is large enough to warrant its own generator.
# Generally this is minor stuff hence the term useless.
# Some of this stuff will be moved out later as I flesh out parts of this function.
temp = 'is ' + boose(['strangely', 'suprisingly', 'oddly']) + ' ' + choose(
['cold', 'cool', 'warm', 'hot']) + ' to the touch'
weight = 'is ' + choose(['strangely', 'suprisingly', 'oddly']) + ' ' + choose(['heavy', 'light'])
creeps = 'feels as if ' + choose(
['it can read your thoughts', 'it has a mind of its own', 'it is watching you'])
speaks = 'feels as if ' + choose(['speaks', 'whispers']) + ' to you' + boose(
[' in a' + choose(['n ancient ', ' forgotten ', 'n archaic ']) + choose(['tongue', 'language'])])
vibrates = choose(['vibrates', 'pulses', 'hums']) + choose(
[' gently', ' with ' + choose(['mysterious', 'ancient']) + ' ' + choose(['energy', 'power'])])
return choose([temp, weight, creeps, speaks, vibrates])
lore += 'It ' + choose([smell(), detection(), haunted(), useless()]) + '.'
lore = lore.replace('It >>>', '')
return lore
def lore(self):
tlore = gramcheck(self.partlore() + self.historylore() + self.strangelore())
if self.archetype == 'light saber':
return tlore.replace('wizard','jedi').replace('magic','the force')
return tlore
if __name__ == "__main__":
seed(19 )
weap = Weapon('bow',[WeaponString('bowstring'),WeaponHandle('riser')])
print weap.lore()