-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatinfo.py
394 lines (332 loc) · 10.1 KB
/
statinfo.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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
from textwrap import dedent as dd
names = (
'Intelligence',
'Will',
'Strength',
'Endurance',
'Dexterity',
'Agility',
'Speed',
'Eyesight',
'Hearing',
'Smell/Taste',
'Touch',
'Height',
'Weight',
'Physique'
)
groups = (
('Intelligence', 'Will'),
('Strength',
'Endurance',
'Dexterity',
'Agility',
'Speed',
'Eyesight',
'Hearing',
'Smell/Taste',
'Touch'),
('Height', 'Weight'),
('Physique',)
)
# TODO: Figure out how to determine chosen race and give stat info
# http://cloud-3.steamusercontent.com/ugc/320124788920141475/83A5568F35B91FC2BD926876D7757487797911CF/
extra_info = {
'Intelligence': dd(
'''
Intelligence primarily affects how quickly you train skills.
The following skills are governed by this stat:
Agriculture,
Building,
Herblore,
Physician,
Ritual,
Trapping,
Weatherlore
'''
),
'Will': dd(
'''
Will affects your ability to stay awake when exhausted and your abiliity
to force yourself to eat raw meat and fish (and then throwing up).
The following skills are governed by this stat:
Agriculture,
Fishing,
Physician,
Ritual,
Stealth
'''
),
'Strength': dd(
'''
Strength does NOT affect your carrying capacity.
The following skills are governed by this stat:
Club*,
Building,
Timbercraft,
Climbing,
Swimming,
Shield,
Sword,
Axe,
Flail,
Spear,
Bow,
Unarmed
* Club skill level accounts for 2x your Strength level.
((2*Strength + Dexterity)/3 * skill points)
'''
),
'Endurance': dd(
'''
Endurance affects your Encumberance penalty (and thus Mobility) via
reduced Fatigue gain and increased recovery speed. Fatigue acts as
flat reduction to skill levels. It also affects your pain tolerance,
or resistance to being hit and losing consciousness.
The following skills are governed by this stat:
Agriculture,
Swimming
'''
),
'Dexterity': dd(
'''
Dexterity affects the likelyhood of fumbling when in combat.
The following skills are governed by this stat:
Agriculture,
Carpentry,
Fishing,
Hideworking*,
Timbercraft,
Trapping,
Climbing,
Skiing,
Knife,
Sword,
Shield,
Flail,
Bow,
Crossbow
* Hideworking skill level accounts for 2x your Dexterity level.
'''
),
'Agility': dd(
'''
Agility is one of the few stats that governs your Dodge skill,
*supposedly* with a higher than average multiplier as well.
It also helps when standing up in the heat of combat.
The following skills are governed by this stat:
Dodge,
Timbercraft,
Climbing,
Skiing*,
Swimming,
Stealth,
Shield,
Unarmed,
Knife,
Sword,
Axe,
Spear*,
Club,
Flail
* Skiing and Spear skill levels account for 2x your Agility level.
'''
),
'Speed': dd(
'''
Speed affects your base Mobility value (5x Speed). This means
walking, running, paddling a raft/punt, swimming hiding and crawling.
*Supposedly* Speed also affects how long it takes to rest.
The following skills are governed by this stat:
Dodge,
Unarmed
'''
),
'Eyesight': dd(
'''
Eyesight affects how far you can see on the maps, and how close you have to be
to spot the outline of a beast or man in the distance on the wilderness map.
The following skills are governed by this stat:
Weatherlore,
Tracking*,
Dodge,
Shield,
Bow,
Crossbow
* Tracking skill level accounts for 2x your Eyesight level.
'''
),
'Hearing': dd(
'''
Hearing affects your ability to locate your prey on a partly obscured map, as well as
warn you of danger outside your line of sight. A deaf character will -potentially-
be in danger of being eaten alive by squirrels while sleeping outdoors. Or by wolves.
The following skills are governed by this stat:
Ritual,
Tracking
'''
),
'Smell/Taste': dd(
'''
Smell/Taste affects your ability to differentiate between cow milk and bull milk. :^)
The following skills are governed by this stat:
Cookery*,
Herblore,
Weatherlore,
Hideworking,
Tracking
* Cookery skill level accounts for 2x your Smell/Taste level.
'''
),
'Touch': dd(
'''
The following skills are governed by this stat:
Building,
Carpentry,
Cookery,
Fishing,
Herblore,
Hideworking,
Physician*,
Trapping,
Weatherlore,
Climbing,
Stealth,
Knife,
Flail,
Crossbow
* Physician skill level accounts for 2x your Touch level.
'''
),
'Height': dd(
'''
Indirectly affects your Weight.
'''
),
'Weight': dd(
'''
Weight is a combination of height and physique (or was at least).
Worn armor and clothes cause an Encumberance penalty when their total
weight exceeds 10% of your weight. *Supposedly* your weight limit
is calculated as such:
weight_limit = character_weight * 1.5
'''
),
'Physique': dd(
'''
Physique has since been removed from the game but still seems to exist in
memory. It is unknown if this mechanic is still in the game since its
removal from the stats screen during character creation.
Physique used to affect your weight limit and ability to pick up
items, i.e. a large physique would allow you to pick up large items with ease
while a small one would mean trouble picking up a punt. Physique may have
also affected how well you dealt with starvation. Speed and stealth were
also supposedly affected by having a small physique.
'''
),
}
class _stat:
def __init__(self, name, buffername=None):
self.name = name
self.buffername = (buffername or self.name.upper()) + '_STAT_BUFFER'
self.extra_info = extra_info.get(self.name, None)
def format(self, value):
return Stats.format(self.name, value)
def __repr__(self):
return f'<_stat {self.name} ({self.buffername}), extra_info={bool(self.extra_info)}>'
class Stats:
intelligence = _stat('Intelligence')
will = _stat('Will')
strength = _stat('Strength')
endurance = _stat('Endurance')
dexterity = _stat('Dexterity')
agility = _stat('Agility')
speed = _stat('Speed')
eyesight = _stat('Eyesight')
hearing = _stat('Hearing')
smelltaste = _stat('Smell/Taste', buffername='SMELLTASTE')
touch = _stat('Touch')
height = _stat('Height')
weight = _stat('Weight')
physique = _stat('Physique')
rerolls = _stat('Rerolls')
_fmt = '{stat:<13} {val:>2} [{size:<18}]'
_hfmt = '{stat:<13} {val:>2}" ({fval}\'{ival}")'
_wfmt = '{stat:<13} {val:>2} lbs ({kval} kg)'
_pfmt = '{stat:<13} Type {val} [ {size} ]'
_rfmt = '{stat:<13} {val}'
@classmethod
def get(cls, name, *, group=None):
if group is None:
group = cls.all_stats
try:
return next(filter(lambda s: s.name == name, group()))
except StopIteration:
pass
@classmethod
def get_name(cls, buffname, *, group=None):
if group is None:
group = cls.all_stats
try:
return next(filter(lambda s: s.buffername == buffname, group()))
except StopIteration:
pass
@classmethod
def all_stats(cls):
"""
Return a tuple of all stats with memory locations.
"""
return (
cls.intelligence, cls.will, cls.strength, cls.endurance,
cls.dexterity, cls.agility, cls.speed, cls.eyesight,
cls.hearing, cls.smelltaste, cls.touch, cls.height,
cls.weight, cls.physique, cls.rerolls)
@classmethod
def all_real_stats(cls):
"""
Return a tuple of all stats, not including rerolls.
"""
return (
cls.intelligence, cls.will, cls.strength, cls.endurance,
cls.dexterity, cls.agility, cls.speed, cls.eyesight,
cls.hearing, cls.smelltaste, cls.touch, cls.height,
cls.weight, cls.physique)
@classmethod
def all_normal_stats(cls):
"""
Return a tuple of all stats that can have values of 1 to 18.
"""
return (
cls.intelligence, cls.will, cls.strength, cls.endurance,
cls.dexterity, cls.agility, cls.speed, cls.eyesight,
cls.hearing, cls.smelltaste, cls.touch)
@classmethod
def format(cls, stat, value):
try:
return getattr(cls, '_format_%s' % stat.lower())(value)
except AttributeError:
return cls._fmt.format(
stat=stat + ':', val=value, size='='*value)
@classmethod
def _format_height(cls, value):
f, i = divmod(value, 12)
return cls._hfmt.format(
stat=cls.height.name + ':', val=value, fval=f, ival=i)
@classmethod
def _format_weight(cls, value):
k = round(value * 0.4535, 1)
return cls._wfmt.format(
stat=cls.weight.name + ':', val=value, kval=k)
@classmethod
def _format_physique(cls, value):
things = list('-----')
try:
things[value-1] = '@'
except IndexError:
pass
size = ' '.join(things)
return cls._pfmt.format(
stat=cls.physique.name + ':', val=value, size=size)
@classmethod
def _format_rerolls(cls, value):
return cls._rfmt.format(stat=cls.rerolls.name + ':', val=value)