-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandomLoot.py
199 lines (163 loc) · 4.33 KB
/
randomLoot.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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
import random
from pprint import pprint
from time import sleep
# colored terminal text
# https://pypi.org/project/termcolor/
from termcolor import colored, cprint
# progress bar
from tqdm import tqdm
totalValue = 0
# Luck increases chance of better item rarity
# default is 0
luck = 0 # +5/10/15/20/25
#speed default is 1
speed = 1 # +.5/.75/1.0/1.25/1.5
openChestTime = (3.5 - speed) # default time to open chest is 2.5 seconds
receivedItems = []
items = {
"guns" : [
"Pistol",
"Silenced Pistol",
"Revolver",
"SMG",
"Pump Shotgun",
"Double Barrel Shotgun",
"Tactical Shotgun",
"Hunting Rifle",
"Assault Rifle",
"Sniper Rifle",
"Light Machine Gun",
"Gattling Gun",
"RPG",
"Guided Rockets",
"Rail Gun"
],
"items" : [
"Frag Grenades",
"Cluster Grenades",
"Molotov Cocktails",
"Claymore Mines",
"Smoke Grenade",
"Door Alarm Trap",
"Gold",
"Ammo: Pistol",
"Ammo: Rifle",
"Ammo: Shotgun",
"Ammo: Rockets",
"Ammo: Energy"
],
"health" : [
"Small Medkit",
"Large Medkit",
"Adrenaline Shot",
"Pain Pills"
],
"cards" : [
"Luck Boost",
"Speed Boost",
"XP Boost",
"Heightened Awareness",
"Quiet Movement"
# card rarity +5/10/15/20/25%
]
}
# GET RANDOM RARITY BY % CHANCE
commonChance = 45 # 45%
uncommonChance = 75 # 30%
rareChance = 90 # 15%
epicChance = 99 # 9%
legendaryChance = 100 # 1%
rarity = "none"
def getRandomRarity():
number = random.randint(1,100) + luck
#print("Rarity number: ", number)
if number <= commonChance:
print("Common")
return "common"
elif number > commonChance and number <= uncommonChance:
cprint("Uncommon", "green")
return "uncommon"
elif number > uncommonChance and number <= rareChance:
cprint("Rare", "blue")
return "rare"
elif number > rareChance and number <= epicChance:
cprint ("Epic", "magenta")
return "epic"
else:
cprint("Legendary", "yellow")
return "legendary"
# GET RANDOM CATEGORY TYPE BY %
gunChance = 36
itemChance = 32
healthChance = 30
cardChance = 2
category = "none"
def getRandomType():
#global category
number = random.randint(1,101)
#print(number)
if number <= gunChance:
getRandomRarity()
#print("gun")
#category = "guns"
return "guns"
elif number > gunChance and number <= gunChance + itemChance:
#print("item")
#category = "items"
return "items"
elif number > gunChance + itemChance and number <= gunChance + itemChance + healthChance:
#print("health")
#category = "health"
return "health"
else:
#print("card")
getRandomRarity()
#category = "cards"
return "cards"
#GET RANDOM ITEM OF GIVEN TYPE
randItem = "none"
def getRandomItem(category):
#global randItem
length = len(items.get(category))
randItem = items.get(category)[random.randint(0, length - 1)]
#receivedItems.append(randItem) # add to list
# Remove received item from list so you can't get 2
# of the same thing in one chest
items.get(category).remove(randItem)
return randItem
# OPEN CHEST AND GET X ITEMS
def openChest(amount):
count = 0
print("Opening Chest...")
for i in tqdm(range(100), desc = "opening..."):
# The following sleep time should be affected by speed stat
sleep(.01 * openChestTime)
print()
print("You got", amount, "items!")
print()
sleep(.5)
for x in range(0, amount):
sleep(.25)
count += 1
print(str(count) + ":")
category = getRandomType()
print("(" + category + ")")
randItem = getRandomItem(category)
print(randItem)
print()
###########################
def choose():
choice = input("Open a chest? (y/n) :").lower().strip()
if choice == "y":
openChest(random.randint(3,5))
choose()
elif choice == "n":
print("Goodbye!")
quit
else:
print("Invalid choice. Try again.")
choose()
choose()
###########################
# SPEED DEBUG
#print("(Speed is", str(speed) + ". Time to open chest: ", str(openChestTime), "seconds.)")