-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathloot.py
58 lines (47 loc) · 1.58 KB
/
loot.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
import random
from aqt.utils import showText
from .items import get_item_by_code, get_all_items_json
class Loot():
def __init__(self, loots=None):
self.loots = loots
if self.loots is None:
self.loots = []
for item in get_all_items_json():
loot_config = item["loot"]
self.loots.append({
"code": item["code"],
"weight": loot_config["weight"],
"min": loot_config["min"],
"max": loot_config["max"]
})
self.index_loots = [[i] for i in range(len(self.loots))]
def getLoot(self):
total = 0
for loot in self.loots:
total += loot["weight"]
draw = random.randint(0, total)
dropList = []
for index in range(len(self.index_loots)):
loot = self.loots[index]
if draw <= loot["weight"]:
amount = 1
if "min" in loot and "max" in loot:
amount = random.randint(loot["min"], loot["max"])
item = get_item_by_code(loot["code"])
if item:
dropList.append({
"item": item,
"amount": amount
})
else:
draw -= loot["weight"]
return dropList
class StartLoot(Loot):
def __init__(self):
super().__init__()
class DailyLoot(Loot):
def __init__(self):
super().__init__()
class CardStudyLoot(Loot):
def __init__(self):
super().__init__()