-
Notifications
You must be signed in to change notification settings - Fork 0
/
User.py
133 lines (115 loc) · 4.67 KB
/
User.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
import Banner
import Dicts
from numpy import random
class User(object):
def __init__(self):
self.dist = 0
self.permanentbanner = Banner.PermanentBanner()
self.upbanner = Banner.UpBanner()
self.gacha_history = {
'permanent': [],
'up': []
}
# def clear_gacha_history(self):
# self.gacha_history['permanent'] = []
# self.gacha_history['up'] = []
def get_up_gacha_history(self):
return self.gacha_history['up']
def get_permanent_history(self):
return self.gacha_history['permanent']
def one_is_character_else_weapon(self) -> bool:
temp = random.choice([0, 1])
return temp == 1
def one_is_up_else_normal(self) -> bool:
temp = random.choice([0, 1])
return temp == 1
def get_new_dist(self):
self.dist = random.rand()
def onepull(self, mode):
self.get_new_dist()
mode = int(mode)
if mode == 1:
self.permanentpull()
elif mode == 2 or mode == 3:
self.uppull(mode - 2)
else:
pass
def permanentpull(self):
rank = self.return_rank(self.permanentbanner.gold_prob, self.permanentbanner.purple_prob)
if rank == 'b' and self.permanentbanner.not_purple_cnt >= 9:
rank = 'p'
certain_item = self.get_new_permanent_item(rank)
self.gacha_history['permanent'].append([certain_item, self.permanentbanner.pity_cnt + 1])
self.change_permanent_stats(rank)
def change_permanent_stats(self, current_rank):
if current_rank == 'g':
self.permanentbanner.pity_cnt = 0
self.permanentbanner.not_purple_cnt += 1
elif current_rank == 'p':
self.permanentbanner.pity_cnt += 1
self.permanentbanner.not_purple_cnt = 0
else:
self.permanentbanner.pity_cnt += 1
self.permanentbanner.not_purple_cnt += 1
self.permanentbanner.update_prob()
def get_new_permanent_item(self, rank):
if rank == 'b':
return str(random.choice(Dicts.permanent_pool_items['R']))
else:
flag = self.one_is_character_else_weapon()
if rank == 'g':
if flag:
return str(random.choice(Dicts.permanent_pool_items['CSSR']))
else:
return str(random.choice(Dicts.permanent_pool_items['WSSR']))
else:
if flag:
return str(random.choice(Dicts.permanent_pool_items['CSR']))
else:
return str(random.choice(Dicts.permanent_pool_items['WSR']))
def return_rank(self, gold_prob, purple_prob):
if self.dist <= gold_prob:
return 'g'
elif self.dist <= purple_prob + gold_prob:
return 'p'
else:
return 'b'
def change_upbanner_stats(self, current_rank, isUp: bool):
if current_rank == 'g':
self.upbanner.pity_cnt = 0
self.upbanner.guarantee = False if isUp else True
self.upbanner.not_purple_cnt += 1
elif current_rank == 'p':
self.upbanner.pity_cnt += 1
self.upbanner.not_purple_cnt = 0
else:
self.upbanner.pity_cnt += 1
self.upbanner.not_purple_cnt += 1
self.upbanner.update_prob()
def get_new_up_item(self, rank, index):
if rank == 'g':
flag = self.one_is_up_else_normal()
if self.upbanner.guarantee:
flag = True
if flag:
return Dicts.upcharacters[0][index]
else:
return str(random.choice(Dicts.permanent_pool_items['CSSR']))
elif rank == 'p':
flag = self.one_is_up_else_normal()
if flag:
return str(random.choice(Dicts.upcharacters[1]))
else:
return str(random.choice(Dicts.permanent_pool_items['WSR'] + Dicts.permanent_pool_items['CSR']))
else:
return str(random.choice(Dicts.permanent_pool_items['R']))
def uppull(self, index):
rank = self.return_rank(self.upbanner.gold_prob, self.upbanner.purple_prob)
if rank == 'b' and self.upbanner.not_purple_cnt >= 9:
rank = 'p'
certain_item = self.get_new_up_item(rank, index)
self.gacha_history['up'].append([certain_item, self.upbanner.pity_cnt + 1])
self.change_upbanner_stats(rank, certain_item == Dicts.upcharacters[0][index])
def tenpull(self, mode):
for i in range(10):
self.onepull(mode)