-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitem.py
More file actions
63 lines (51 loc) · 2.48 KB
/
Copy pathitem.py
File metadata and controls
63 lines (51 loc) · 2.48 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
"""Billy in the Fat Lane - A Lame Life Simulation Game
Copyright (C) 2013 Chris Parlette, Matt Parlette
This file is part of Billy in the Fat Lane.
Billy in the Fat Lane is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Billy in the Fat Lane is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Billy in the Fat Lane. If not, see http://www.gnu.org/licenses/."""
from uuid import uuid4
class Item:
def __init__(self,name = "Unnamed Item",
symbol = "!",
availability = 50,
cost = 1,
effects = {},
consumable = True,
):
self.name = name
self.id = uuid4()
#Symbol: the command for a user to reference this item
self.symbol = symbol
#Availability: The rarity of this item
#(100 is common, 1 is very rare)
self.availability = availability
#Cost: The cost to buy this item
self.cost = cost
#Effects: What will this item do?
self.effects = effects
#Usable: Can this item be consumed?
self.consumable = consumable
def __repr__(self):
return str(self.name)
def __eq__(self,other):
return self.id == other.id if hasattr(other,"id") else False
def __gt__(self,other):
return self.name > other.name if hasattr(other,"name") else False
def debug_string(self):
s = "%s\n%s\nID: %s\nAvailability: %s\nCost: %s\nConsumable: %s\nEffects:\n\t%s" % (self.name,
"-"*len(self.name),
str(self.id),
self.availability,
self.cost,
self.consumable,
"\n\t".join("%s (%.2f)" % (str(d),self.effects[d]) for d in self.effects) if len(self.effects) else "None"
)
return s