forked from Maecena/Py.FarmGame
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer.py
More file actions
66 lines (52 loc) · 1.68 KB
/
player.py
File metadata and controls
66 lines (52 loc) · 1.68 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
import random
inv = {
"bark" : 5
}
class player(object):
def __init__(self, exp, money, inventory):
self.exp = exp
self.money = money
self.inv = inventory
def player_stats(self):
print("Your money is at " + str(self.money) + " silver,")
print("you have " + str(self.exp) + " experience and")
print("your inventory contains: ")
pc.print_inv()
#the money functions add or subtract money
def balance_down(self, total):
if self.money >= total:
self.money = self.money - total
else:
print ("Sorry you don't have enough money")
return False
def balance_up(self, total):
self.money = self.money + total
#prints the whole inv key and value
def print_inv(self):
for key in self.inv:
print (str(key) + " - " + str(self.inv[key]))
def add_inv(self, item):
if item in self.inv:
self.inv[item] = self.inv[item] + 1
else:
inv[item] = 1
def remove_inv(self, item, num=1):
if item in self.inv:
if self.inv[item] > 0:
self.inv[item] = self.inv[item] - 1
if self.inv[item] == 0:
del self.inv[item]
else:
print ("You can't! It's listed but something's broken.")
else:
print ("You can't! You don't have any.")
#prints just one value from the inv
def inv_quantity(self, key):
if key in self.inv:
return self.inv[key]
def check_inv(self, item):
if item in self.inv:
return True
else:
return False
pc = player(0, 15, inv)