-
Notifications
You must be signed in to change notification settings - Fork 0
/
MakeUnit.py
119 lines (112 loc) · 5.88 KB
/
MakeUnit.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
# Python Module #
import sqlite3
from itertools import combinations
# MakeUnit for above ver.4.2 21/08/05
def generate_deck(difull, hlall, hlpr, hlfa, hlan, zST, zDM, zDT, zCB, zSL, zDC, IDB_name):
conn1 = sqlite3.connect(IDB_name)
cur1 = conn1.cursor()
slso = [[231, 222, 213, "prvo"], [234, 225, 216, "prda"], [237, 228, 219, "prvi"],
[331, 322, 313, "favo"], [334, 325, 316, "fada"], [337, 328, 319, "favi"],
[431, 422, 413, "anvo"], [434, 425, 416, "anvo"], [437, 428, 419, "anvo"]]
ttonly = [str(i[0]) for i in cur1.execute('select idnumber from centerdb where centerid between 121 and 129')]
def set_leader(inputed_list, mode):
leaderlist, leader = list(), list()
for idnumber in inputed_list:
try: leaderlist.append(difull[str(idnumber[0])])
except: continue
if len(leaderlist) != 0:
leaderlist.sort(reverse=True)
if mode == 0 or (mode == 1 and zST == 4):
leader.append(leaderlist[0])
elif mode == 1 and zST != 4:
for idoldata in leaderlist:
if len(leader) != 0: break
if idoldata[2] == zST: leader.append(idoldata)
if len(leader) == 0:
leader.append(leaderlist[0])
return leader
def select_leader(i):
ll1 = cur1.execute(f'select idnumber from centerdb where centerid = {slso[i][0]}').fetchall()
l1 = set_leader(ll1, 0) # 90 + 15
ll2 = cur1.execute(f'select idnumber from centerdb where centerid = {slso[i][1]}').fetchall()
l2 = set_leader(ll2, 0) # 95
ll3 = cur1.execute(f'select idnumber from centerdb where centerid = {slso[i][2]}').fetchall()
l3 = set_leader(ll3, 0) # 90
if zDC == 1:
l = l1 + l2 + l3
elif zDC == 0:
if zST == 4: l = l2 + l1 + l3
else: l = l1 + l2 + l3
if len(l) == 0:
ll4 = cur1.execute(f'''select idnumber from centerdb natural inner join idoldb_sub
where {slso[i][3]} between 1 and 89 order by maxtotal desc''').fetchall()
l = set_leader(ll4, 0)
else: l = [l[0]]
return l
def select_leader_v3t(id1, id2):
ll1 = cur1.execute(f'select idnumber from centerdb where centerid = {id1}').fetchall()
l1 = set_leader(ll1, 0) # 105
ll2 = cur1.execute(f'select idnumber from centerdb where centerid = {id2}').fetchall()
l2 = set_leader(ll2, 0) # 105 + 10
if zDC == 1:
l = l1 + l2
elif zDC == 0:
if len(l2) != 0: l = l2
else: l = l1
return l
def make_cunit(inputed_data, extract_list):
clist = list()
for leader in inputed_data:
hleader = leader[0:2]
combilist = list()
for hidol in extract_list:
if hidol == hleader: continue
if not len(combilist) >= zCB: combilist.append(hidol)
combi = list(combinations(combilist, 4))
for hunit in combi:
cunit = tuple([leader]+[difull.get(hunit[i][1]) for i in range(4)])
typelist = set([int(cunit[i][2]) for i in range(5)])
if leader[1] in ttonly and len(typelist) < 3: continue
clist.append(cunit)
return clist
if zSL == 0:
# Select Leader Idol - Default Auto Mode, Results by zST, zDM
# Generate Combi by zCB (by make_cunit) // Select by zST, zDM, zDT
stlist, ttlist = [], []
if zDM in [0, 1, 4] or (zDM == 2 and (zST == 1 or zST == 4)):
if zDT == 0 or zDT == 1: stlist = stlist + make_cunit(select_leader(0), hlpr)
if zDT == 0 or zDT == 2: stlist = stlist + make_cunit(select_leader(1), hlpr)
if zDT == 0 or zDT == 3: stlist = stlist + make_cunit(select_leader(2), hlpr)
if zDM in [0, 1, 5] or (zDM == 2 and (zST == 2 or zST == 4)):
if zDT == 0 or zDT == 1: stlist = stlist + make_cunit(select_leader(3), hlfa)
if zDT == 0 or zDT == 2: stlist = stlist + make_cunit(select_leader(4), hlfa)
if zDT == 0 or zDT == 3: stlist = stlist + make_cunit(select_leader(5), hlfa)
if zDM in [0, 1, 6] or (zDM == 2 and (zST == 3 or zST == 4)):
if zDT == 0 or zDT == 1: stlist = stlist + make_cunit(select_leader(6), hlan)
if zDT == 0 or zDT == 2: stlist = stlist + make_cunit(select_leader(7), hlan)
if zDT == 0 or zDT == 3: stlist = stlist + make_cunit(select_leader(8), hlan)
if zDM in [0, 1, 3]:
if zDT == 0 or zDT == 1: ttlist = ttlist + make_cunit(select_leader_v3t(121, 122), hlall)
if zDT == 0 or zDT == 2: ttlist = ttlist + make_cunit(select_leader_v3t(124, 125), hlall)
if zDT == 0 or zDT == 3: ttlist = ttlist + make_cunit(select_leader_v3t(127, 128), hlall)
if zDM != 0: return [stlist + ttlist]
elif zDM == 0: return [stlist, ttlist]
elif zSL != 0:
# Select Leader Idol - Manual Select Mode
# make_cunit manual mode
tclist = []
leader = zSL
if leader[1] in ttonly:
tclist = tclist + make_cunit([leader], hlall)
else:
if leader[2] == 1: tclist = tclist + make_cunit([leader], hlpr)
elif leader[2] == 2: tclist = tclist + make_cunit([leader], hlfa)
elif leader[2] == 3: tclist = tclist + make_cunit([leader], hlan)
elif leader[2] == 4:
if zST == 1: extract_list = [hlpr]
elif zST == 2: extract_list = [hlfa]
elif zST == 3: extract_list = [hlan]
elif zST == 4: extract_list = [hlpr, hlfa, hlan, hlall]
for i in extract_list:
tclist = tclist + make_cunit([leader], i)
return [tclist]