-
Notifications
You must be signed in to change notification settings - Fork 0
/
components.py
789 lines (607 loc) · 23 KB
/
components.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
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
""" Contains all the Basic components of the game. """
import libtcodpy as libtcod
import gvar
import math
import pprint
from utils import calcBonuses
class Object:
""" Generic Object, which can have multiple components and become the player, a mob, stairs, loot, etc. """
def __init__(self, currentDungeon, currentLevel, x, y, char, id=None, name='', color=libtcod.white, blocks=False, exp=0, always_visible=False, fighter=None, ai=None, item=None, equipment=None, inventory=[], use_function=None, args=None):
import random, string
self.currentDungeon = currentDungeon
self.currentLevel = currentLevel
self.x = x
self.y = y
self.char = char
if id is None:
self.id = 'o-' + ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(8))
else:
self.id = id
self.color = color
self.name = name
self.blocks = blocks # boolean - if others can pass through
self.always_visible = always_visible # boolean - if this object should be drawn regardless of FOV, when explored
self.exp = exp # int - exp given to the player once explored, killed, etc.
self.inventory = inventory # list - inventory of the player, the mob, a corpse or a treasure chest, etc.
self.args = args #: Arguments passed to the use function
self.use_function = use_function
# Fighter Component
# Has all values and methods used for combat
self.fighter = fighter
if self.fighter:
self.fighter.owner = self
# MobAI Component
# Handles NPC actions
self.ai = ai
if self.ai:
self.ai.owner = self
# Item Component
# Handles Pick up and Use Functions of Items
# Note that Equipment stats and others are in the Equipment Component, not here
self.item = item
if self.item:
self.item.owner = self
# Equipment Component
# An Equipment item, which can have Weapon, Armor or Ranged Components
self.equipment = equipment
if self.equipment:
self.item = Item()
self.item.owner = self
self.equipment.owner = self
def currentmap(self):
from utils import is_player
return self.currentDungeon.maps[self.currentLevel]
def relocate(self, dungeon=None, level=None, x=None, y=None):
if dungeon is not None:
self.currentDungeon = dungeon
if level is not None:
self.currentLevel = level
if x is not None:
self.x = x
if y is not None:
self.y = y
def move(self, dx, dy):
""" | Move current position relatively by the given amount
| **dx -- int** | relative horizontal distance
| **dy -- int** | relative vertical distance
"""
if not self.currentmap().is_blocked(self.x + dx, self.y + dy):
self.x += dx #:Add the horizontal delta Value
self.y += dy
if self.currentmap().map[self.x][self.y].step_function is not None:
self.currentmap().map[self.x][self.y].step_function(self)
def move_to(self, spot):
""" | Move current position absolutely to the given spot
| **spot** -- tuple | absolute x and y positions
"""
from utils import is_player
if not self.currentmap().is_blocked(spot[0], spot[1]):
self.x = spot[0]
self.y = spot[1]
if self.currentmap().map[self.x][self.y].step_function is not None:
self.currentmap().map[self.x][self.y].step_function(self)
def jump(self, direction):
""" | Jump to the given direction
| checking for blocked spots and
| stopping if block is found
| **direction** -- tuple | relative x and y directions
"""
from utils import d10, is_player
# Roll DEX + Athletics
roll = d10(self.fighter.dexterity + self.fighter.skills["Athletics"], 'Jump', player=is_player(self))
# Normalize directions
for d in directions:
if d > 0:
d = 1
elif d < 0:
d = -1
#Check for blocking Objects/Tiles
max_distance = 0
if roll[0] != 'botch':
for d in range(1, roll[0]):
max_distance = d
if self.currentmap().is_blocked(self.x + direction[0] * (d+1), self.y + direction[1] * (d+1)):
break
self.move_to((self.x + direction[0]*max_distance, self.y + direction[1]*max_distance))
else:
#@TODO Botch Behaviour
print "botch"
return self.fighter.movement_speed()
def distance_to(self, other):
""" Returns the distance to another object """
from utils import get_distance
return get_distance((self.x, self.y), (other.x, other.y))
def get_equipped_in_slot(self, slot):
""" return the equipment in a slot, or None if it's empty """
for obj in self.inventory:
if obj.equipment and obj.equipment.slot == slot and obj.equipment.is_equipped:
return obj.equipment
return None
def get_all_equipped(self):
""" | return all items'that are equipped to the given entity
| @TODO Enable for mobs
"""
equipped = []
for item in self.inventory:
if item.equipment and item.equipment.is_equipped:
equipped.append(item.equipment)
return equipped
def closest_mob(max_range):
""" find closest enemy, up to a maximum range, and in the player's FOV """
closest_enemy = None
closest_dist = max_range + 1
for obj in self.currentDungeon.maps[self.currentLevel].objects:
if obj.fighter and not obj == gvar.game.player and libtcod.map_is_in_fov(gvar.fov_map, obj.x, obj.y):
dist = gvar.game.player.distance_to(obj)
if dist < closest_dist:
closest_enemy = obj
closest_dist = dist
return closest_enemy
def use(self):
""" Call the use_function, if it is defined. """
if self.use_function is not None:
if self.args is not None:
self.use_function(self.args)
else:
self.use_function()
def send_to_back(self):
""" Make this object be drawn first, so all others appear above it if they're in the same tile """
self.currentmap().objects.remove(self)
self.currentmap().objects.insert(0, self)
def send_to_front(self):
""" Make this object be drawn last, so it appears above everything else on its tile """
self.currentmap().objects.remove(self)
self.currentmap().objects.append(self)
def draw(self):
""" Draw this object onto the Map, if it's in FOV or always_visible """
from utils import fov_distance_coef, is_visible
if (is_visible((self.x, self.y))) or (self.always_visible and self.currentmap().map[self.x][self.y].explored) or gvar.admin.light_all:
libtcod.console_put_char_ex(gvar.con, self.x, self.y, self.char, self.color * fov_distance_coef((self.x, self.y)), libtcod.BKGND_SET)
def clear(self):
""" Clear this object from the Map, so it won't be visible """
libtcod.console_put_char(gvar.con, self.x, self.y, ' ', libtcod.BKGND_NONE)
class Fighter:
""" Combat related Stats and Methods """
def __init__(self, hl=[0,0,0,1], essence=0, strength=1, dexterity=1, stamina=1, perception=1, intelligence=1, wits=1, exp=0, skills={}, death_function=None, bonus={}):
self.death_function = death_function
self.max_hl = hl
self.hl = list(hl)
self.essence = essence
self.skills = skills
self.base_strength = strength
self.base_dexterity = dexterity
self.base_stamina = stamina
self.base_perception = perception
self.base_intelligence = intelligence
self.base_wits = wits
self.bonus = bonus
if len(self.skills) != 25:
for skill in ['Archery',
'Martial-Arts',
'Melee',
'Thrown',
'War',
'Athletics',
'Awareness',
'Dodge',
'Larceny',
'Stealth',
'Integrity',
'Performance',
'Presence',
'Resistance',
'Survival',
'Bureaucracy',
'Linguistics',
'Ride',
'Sail',
'Socialize',
'Craft',
'Investigation',
'Lore',
'Medicine',
'Occult']:
if skill not in self.skills:
self.skills[skill] = 0
@property
def strength(self):
return (self.base_strength + calcBonuses('strength', self))
@property
def stamina(self):
return self.base_stamina + calcBonuses('stamina', self)
@property
def dexterity(self):
return self.base_dexterity + calcBonuses('dexterity', self)
@property
def perception(self):
return self.base_perception + calcBonuses('perception', self)
@property
def intelligence(self):
return self.base_intelligence + calcBonuses('intelligence', self)
@property
def wits(self):
return self.base_wits + calcBonuses('wits', self)
def get_attributes(self, type="all"):
""" Returns a list attribute scores in the order: STR DEX STA PER INT WIT """
attributes = list()
if type == 'all' or type == 'physical':
attributes.append(self.strength)
attributes.append(self.dexterity)
attributes.append(self.stamina)
if type == 'all' or type == 'mental':
attributes.append(self.perception)
attributes.append(self.intelligence)
attributes.append(self.wits)
return attributes
def dodgeDV(self):
""" Returns (Essence + DEX + Dodge) / 2 """
return ((self.essence + self.dexterity + self.skills['Dodge'])/2) #+ calcBonuses('dodgeDV', self)
def bashing_soak(self):
""" | Iterates through armor slots
| sums up the bashing soak properties,
| adds stamina and then returns it
"""
armor_slots = ['head', 'chest', 'arms', 'legs', 'feet', 'hands']
soak = self.stamina
for slot in armor_slots:
item = self.owner.get_equipped_in_slot(slot)
if item is not None:
soak += item.armor.bashing_soak
return soak
def lethal_soak(self):
""" | Iterates through armor slots
| sums up the lethal soak properties,
| adds stamina and then returns it
"""
armor_slots = ['head', 'chest', 'arms', 'legs', 'feet', 'hands']
if self.essence > 0:
soak = int(math.floor(self.stamina/2))
else:
soak = 0
for slot in armor_slots:
item = self.owner.get_equipped_in_slot(slot)
if item is not None:
soak += item.armor.lethal_soak
return soak
def hardness(self):
""" | Iterates through armor slots
| sums up the hardness properties,
| and then returns it
"""
armor_slots = ['head', 'chest', 'arms', 'legs', 'feet', 'hands']
hardness = 0
for slot in armor_slots:
item = self.owner.get_equipped_in_slot(slot)
if item is not None:
hardness += item.armor.hardness
return hardness
def fov(self):
""" | Returns a maximum viewing distance,
| calculated from Perception + (Awareness*2) + Bonuses
| with a minimum of 3
"""
return max(3, int(self.perception + self.skills['Awareness']*2 + calcBonuses('awareness', self)))
def foh(self):
""" | Returns a maximum hearing distance,
| calculated from Perception + (Awareness*3) + Bonuses
| with a minimum of 3
"""
return max(3, int(self.perception + self.skills['Awareness']*3 + calcBonuses('awareness', self)))
def onslaughtPenalty(self):
""" | Returns the onslaught Penalty as an integer
| calculated from adjacent enemies - 1
"""
from utils import is_player
penalty = -1
for spot in self.owner.currentmap().adjacent(self.owner.x, self.owner.y):
for obj in self.owner.currentmap().objects:
if obj.fighter and not is_player(obj) and obj.x == spot[0] and obj.y == spot[1]:
penalty += 1
return penalty
def take_damage(self, damage):
""" | Apply the given amount of damage
| and invoke the death_function, if necessary
"""
from utils import is_player
for level in [0, 1, 2, 3]: # go through all Health Levels
if damage > 0 and self.hl[level] > 0:
d = damage - self.hl[level]
if d >= 0:
self.hl[level] = 0
damage = d
else:
self.hl[level] -= damage
damage = 0
if level == 3 and self.hl[level] <= 0:
if self.death_function is not None:
self.death_function(self.owner) # Apply Death Function if possible
if is_player(self.owner):
gvar.screen_impact = [libtcod.darker_red, 1]
def attack(self, target, ranged=False):
""" | Performs an attack against the target.
| Melee or ranged indicated by ranged boolean
"""
from utils import d10, is_player
from render import message
activeWeapon = self.owner.get_equipped_in_slot('hand')
if (activeWeapon is None): # get equipped weapon from slot 'hand'
activeWeapon = Equipment(slot='hand', weapon=Weapon()) # Insert dummy weapon if no weapon is equipped
# @TODO Two-Handed Weapons
weapon = activeWeapon.ranged if ranged else activeWeapon.weapon # determine weapon/ranged component to use
hitroll = d10(self.dexterity + self.skills[weapon.skill], 'Hit', player=is_player(self.owner))
if hitroll[0] != 'botch':
hitroll[0] -= self.health_penalty()
hitroll[0] = max(hitroll[0], 0)
else:
pass # @TODO Botch Behaviour
# Check for hit, if successes > enemy's dodge DV ( -onslaughtPenalty for player)
threshold = target.dodgeDV()
threshold -= target.onslaughtPenalty() if is_player(target.owner) else 0
if hitroll[0] != 'botch' and hitroll[0] > threshold: # target hit, roll damage
if ranged:
dmgroll = d10(weapon.damage, 'Damage', botchable=False, player=is_player(self.owner))
else:
dmgroll = d10(self.strength + weapon.damage, 'Damage', botchable=False, player=is_player(self.owner))
damage = dmgroll[0] + (hitroll[0] - threshold) # add remaining successes from hitroll
if damage > target.hardness(): # check if damage is bigger than hardness
if weapon.damage_type == 'bashing': # apply soak
damage -= target.bashing_soak()
elif weapon.damage_type == 'lethal':
damage -= target.lethal_soak()
if damage > 0: # apply damage
message(self.owner.name.capitalize() + ' hits ' + target.owner.name + ' for ' + str(damage) + ' hit points.')
target.take_damage(damage)
else:
message(self.owner.name.capitalize() + ' hits ' + target.owner.name + ' but the strike bounces off his armor!')
else:
message(self.owner.name.capitalize() + ' attacks ' + target.owner.name + ' but misses.')
return weapon.speed
def ranged_attack():
""" | Perform a ranged attack.
| Checks for a ranged weapon in hand and then calls *input.target_tile* to determine a target.
"""
from input import target_tile
from render import message
from utils import is_player
mobToHit = None
if self.owner.get_equipped_in_slot('hand').ranged is not None:
if is_player(self.owner):
target = target_tile()
if target == 'cancelled':
return 'cancelled'
else:
target = 'closest'
if target == 'closest':
mobToHit = closest_mob(self.perception + self.skills['Awareness']*2)
else:
for hit in self.currentmap().objects:
if target.x == hit.x and target.y == hit.y and hit.fighter is not None:
mobToHit = hit
if mobToHit is None:
# @TODO No enemy found, drop arrow
if is_player(self.owner):
message('There is no enemy here!', libtcod.orange)
else:
self.attack(mobToHit.fighter, ranged=True)
return self.owner.get_equipped_in_slot('hand').ranged.speed
else:
if is_player(self.owner):
message('You do not have a ranged weapon equipped!', libtcod.orange)
return 'cancelled'
def heal(self, amount):
""" | Heal by the given amount,
| iterating through the health levels,
| without going over the maximum
"""
for level in [3, 2, 1, 0]:
if amount > 0 and self.hl[level] < self.max_hl[level]:
d = amount - (self.max_hl[level] - self.hl[level])
if d >= 0:
self.hl[level] = self.max_hl[level]
amount = d
else:
self.hl[level] += amount
amount = 0
def health_penalty(self):
""" Returns the current health penalty """
for level in [3, 2, 1, 0]:
if self.hl[level] <= 0:
if level == 2:
return 4
elif level == 1:
return 2
elif level == 0:
return 1
return 0
def join_battle(self):
""" | Decreases the overall tick level.
| Puts owner into global Tick counter
| with join battle roll as Priority
"""
from utils import d10, is_player, decrease_tick_level
decrease_tick_level()
# Roll Wits + Awareness as Join Battle
roll = d10(self.wits + self.skills["Awareness"], 'Join Battle', botchable=False, player=is_player(self.owner))
if not gvar.game.ticks.contains(self.owner):
gvar.game.ticks.put(self.owner, roll[0])
def movement_speed(self):
""" | Returns the movement speed
| calculated through 5 - Athletics/2
"""
#TODO Better calculation
return max(1, 5 - math.floor(self.skills["Athletics"]/2))
class MobAI:
""" | AI for NPCs
| Can have different statuses for different behaviour
| StatusDelta is the remaining turns till the status wears off
"""
def __init__(self, status=None, statusDelta=0):
self.status = status
self.statusDelta = statusDelta
def applyStatus(self, status, rounds):
""" Apply a new status """
self.status = status
self.statusDelta = rounds
def take_turn(self):
""" | Normal Turn Routine
| Mobs take turns if the player can hear it #TODO Change to Mob's FOH
| If they're close enough, they attack
"""
from render import message
from utils import a_star_search, applyBonus, revertBonus
mob = self.owner
status = self.status
delta = self.statusDelta
speed = 1 # Base speed of 1 tick, to prevent infinite mob action loops
if libtcod.map_is_in_fov(gvar.foh_map, mob.x, mob.y):
# Normal Behaviour
if not status:
if mob.distance_to(gvar.game.player) >= 2: # Move towards the player, if she's too far away
destination = a_star_search(gvar.game.player.currentmap(), (mob.x, mob.y),(gvar.game.player.x, gvar.game.player.y)) # Perform A*-Search
if destination == [(mob.x, mob.y), (mob.x, mob.y)]: # idle for the next 3 turns, if no path to player is found
self.status = 'idle' #@TODO Should have prevented A*-Overload, doesn't seem to work
self.statusDelta = 3
mob.move_to(destination[-2])
speed = self.owner.fighter.movement_speed()
elif sum(gvar.game.player.fighter.hl) > 0: # Player is close enough, perform an attack
speed = mob.fighter.attack(gvar.game.player.fighter)
# Confusion - Moves to random directions, also -4 dodgeDV penalty
elif status == 'confusion':
applyBonus('dodgeDV', -4, self.owner.fighter)
if delta > 0:
self.owner.move(libtcod.random_get_int(0, -1, 1), libtcod.random_get_int(0, -1, 1))
self.statusDelta -= 1
else:
revertBonus('dodgeDV', -4, self.owner.fighter)
self.status = None
message('The smoke around the ' + self.owner.name + ' disappears.', libtcod.violet)
if self.owner.fighter is not None:
speed = self.owner.fighter.movement_speed()
# Idle - Don't do anything, Speed 3
elif status == 'idle':
if delta > 0:
self.statusDelta -= 1
else:
self.status = None
speed = 3
return speed
class Item:
""" | An item that can be picked up and used.
| args is a List of Args that are passed to the use_function
"""
def __init__(self, use_function=None, args=[], count=1):
self.use_function = use_function
self.args = args
self.count = count
def pick_up(self):
""" | Add the item to the player's inventory
| @TODO Inventory System for Enemies and other NPCs
"""
from render import message
if len(gvar.game.player.inventory) >= 26: # Inventory Full, Alphabetical Limit
# @TODO Multi-Page Menus & Encumbrance System
message('Your inventory is full, cannot pick up ' + self.owner.name + '.', libtcod.red)
else:
for item in gvar.game.player.inventory: # Loop through items already in inventory
if item.name == self.owner.name: # and stack them
item.item.count += 1
gvar.game.player.currentmap().objects.remove(self.owner) # Remove the item from the map
message('You picked up a ' + self.owner.name + '!', libtcod.green)
return
gvar.game.player.inventory.append(self.owner)
gvar.game.player.currentmap().objects.remove(self.owner)
message('You picked up a ' + self.owner.name + '!', libtcod.green)
def use(self):
""" | call the use_function, if its defined
| if there are args, add them to the call
"""
from render import message
if self.use_function is None and self.owner.equipment is None: # No valid action found
message('The ' + self.owner.name + ' cannot be used.')
elif self.use_function is None and self.owner.equipment is not None:# It's an Equipment, equip it
self.owner.equipment.toggle_equip()
else:
if len(self.args) == 0:
if self.use_function() != 'cancelled': # It can be used, call use_function
if self.count>=2: # Decrease Stack count, or remove the item
self.count -= 1
else:
gvar.game.player.inventory.remove(self.owner) # @TODO Inventory for Mobs
else:
if self.use_function(self.args[0], self.args[1]) != 'cancelled':
if self.count>=2:
self.count -= 1
else:
gvar.game.player.inventory.remove(self.owner)
def drop(self):
""" | Drop the Item
| Add it to the Global Objects List
| and set it's coordinates to the dropper's
"""
from render import message
if self.owner.equipment:
self.owner.equipment.dequip()
gvar.game.player.currentmap().objects.append(self.owner)
gvar.game.player.inventory.remove(self.owner)
self.owner.currentDungeon = gvar.game.player.currentmap().owner
self.owner.currentLevel = gvar.game.player.currentmap().owner.maps.index(gvar.game.player.currentmap())-1
self.owner.x = gvar.game.player.x
self.owner.y = gvar.game.player.y
message('You dropped a ' + self.owner.name + '.', libtcod.yellow)
class Equipment:
""" | A component representing equippable objects
| armors, weapons, rings, clothes, etc.
"""
def __init__(self, slot, is_equipped=False, bonus={}, weapon=None, ranged=None, armor=None):
self.slot = slot # string, armor slot, possibilities: ['head', 'chest', 'arms', 'legs', 'feet', 'hands']
self.is_equipped = is_equipped # boolean, equip status
self.bonus = bonus # dict, format: {attribute/skill: value} for
self.weapon = weapon # Weapon() component
self.ranged = ranged # Ranged() component
self.armor = armor # Armor() component
def toggle_equip(self):
""" Equips or Dequips the Equipment """
if self.is_equipped:
self.dequip()
else:
self.equip()
def equip(self):
""" | Equips the Equipment
| Dequipping other items in this slot
"""
from render import message
currentEquipped = gvar.game.player.get_equipped_in_slot(self.slot)
if currentEquipped is not None:
currentEquipped.dequip()
self.is_equipped = True
message('Equipped the ' + self.owner.name, libtcod.yellow)
def dequip(self):
""" Dequips the Equipment"""
from render import message
if not self.is_equipped: return
self.is_equipped = False
message('Put off the ' + self.owner.name, libtcod.yellow)
class Weapon:
""" Component for Weapon stats to be included in Equipment """
def __init__(self, accuracy=0, damage=0, damage_type='lethal', skill='Martial-Arts', speed=5):
self.accuracy = accuracy
self.damage = damage
self.damage_type = damage_type
self.skill = skill
self.speed = speed
class Ranged:
""" Component for Ranged Weapon stats to be included in Equipment """
def __init__(self, accuracy=0, damage=0, damage_type='lethal', skill='Archery', speed=5):
self.accuracy = accuracy
self.damage = damage
self.damage_type = damage_type
self.skill = skill
self.speed = speed
class Armor:
""" Component for Armor stats to be included in Equipment """
def __init__(self, bashing_soak=0, lethal_soak=0, fatigue=0, penalty=0, hardness=0):
self.bashing_soak = bashing_soak
self. lethal_soak = lethal_soak
self.fatigue = fatigue
self.penalty = penalty
self.hardness = hardness