-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchest.py
43 lines (36 loc) · 1.14 KB
/
chest.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
from items import Items
from colorama import init, Fore, Back, Style
from stringhandler import Stringhandler
import random
class Chest(object):
def __init__(self,player):
name = "item"
self.opened = False
self.player = player
self.level = player.level
self.item = Items()
self.handler = Stringhandler()
self.hasLoot = True
if self.level > 5:
self.Loot = self.item.randomWeapon(self.level)
else:
rnd = random.randint(0,10)
if rnd < 3:
self.hasLoot = False
self.Loot = ""
else:
self.Loot = self.item.randomWeapon(self.level)
def getLoot(self):
return self.Loot
def is_opened(self):
return self.opened
def open(self,player):
self.opened = True
player.lvlUp()
if self.hasLoot:
return self.handler.strChest("open",self.getLoot().name)+"\n\n"+self.player.addItem(self.getLoot())
else:
string = self.handler.strChest("empty",self.getLoot())
return string
def has_loot(self):
return self.hasLoot