-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththings.py
More file actions
116 lines (94 loc) · 3.07 KB
/
things.py
File metadata and controls
116 lines (94 loc) · 3.07 KB
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
from __future__ import annotations
from words import Description, EventMessages
from core import Action, Modifier
from life import Wounds
from dataclasses import dataclass, field
@dataclass
class Object:
description: Description
volume: int = 5
visible: bool = False
picked_actions: List[Action] = field(default_factory=list)
ground_actions: List[Action] = field(default_factory=list)
modifier: Modifier = field(default_factory=Modifier)
pick_verb, drop_verb = 'prendi', 'lascia'
@property
def drop_action(self):
return Action(
f'{self.drop_verb} {self.description.close}'.capitalize(),
EventMessages(
subject=f'posi a terra {self.description.close}',
close=f'{{subject}} posa a terra {self.description.nclose}',
far=f'{{subject}} posa a terra qualcosa'),
lambda player: player.inventory.drop(self, player))
def __hash__(self): return id(self)
def __eq__(self, other): return self is other
def __str__(self): return str(self.description)
@dataclass
class Dress(Object):
type: str = 'shirt'
pick_verb, drop_verb = 'indossa', 'togliti'
def __hash__(self): return id(self)
def __eq__(self, other): return self is other
@dataclass
class HealWound(Object):
wound: Wound = Wounds.TaglioBraccia
@property
def picked_actions(self):
return [Action(
f'Cura {self.wound.name} con {self.description.oneof}',
EventMessages(
subject=f'Curi {self.wound.name}',
close=f'{{subject}} cura {self.wound.name} con {self.description.oneof}'
),
lambda char: self.wound.unaffect(char) or char.inventory.remove(self),
condition=lambda char: self.wound in char.wounds
)]
@picked_actions.setter
def picked_actions(self, value): return
def __hash__(self): return id(self)
def __eq__(self, other): return self is other
@dataclass
class Food(Object):
nutrition: int = 20
@property
def picked_actions(self):
return [Action(
f'Mangia {self.description}',
EventMessages(
subject=f'mangi {self.description}',
close=f'{{subject}} mangia {self.description}',
far=f'{{subject}} mangia qualcosa'
),
lambda char: setattr(char, 'hunger', char.hunger - self.nutrition) or \
char.inventory.remove(self)
)]
@picked_actions.setter
def picked_actions(self, value): return
def __hash__(self): return id(self)
def __eq__(self, other): return self is other
@dataclass
class WaterContainer(Object):
water: int = 20
volume: int = 10
@property
def picked_actions(self):
return [Action(
f'Bevi {self.description}',
EventMessages(
subject=f'bevi {self.description}',
close=f'{{subject}} beve {self.description}',
far=f'{{subject}} beve qualcosa'
),
lambda char: setattr(char, 'thirst', char.thirst - self.water) or \
setattr(self, 'water', 0) or \
char.inventory.contained.remove(self)
)]
def __hash__(self): return id(self)
def __eq__(self, other): return self is other
@dataclass
class Weapon(Object):
attacks: List[attack] = field(default_factory=list)
defenses: List[defense] = field(default_factory=list)
def __hash__(self): return id(self)
def __eq__(self, other): return self is other