-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresultsDatabase.py
42 lines (34 loc) · 1.27 KB
/
resultsDatabase.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
resultsDb = {}
def recordResults(defenseKey, attackKey, simResults, db = resultsDb):
if(db is None):
print("Warning, empty results database used. Reverting to default.")
db = resultsDb
if(not defenseKey in db):
db[defenseKey] = {}
if(not attackKey in db[defenseKey]):
db[defenseKey][attackKey] = [int(simResults[1]), int(simResults[0]), int(simResults[2]), int(simResults[3])]
else:
db[defenseKey][attackKey][0] += int(simResults[1])
db[defenseKey][attackKey][1] += int(simResults[0])
db[defenseKey][attackKey][2] += int(simResults[2])
db[defenseKey][attackKey][3] += int(simResults[3])
def deckKey(deckType, deckId, ordered = False):
prefix = ""
if(ordered):
prefix = prefix + "o"
if(deckType == "mission"):
prefix = prefix + "m"
elif(deckType == "raid"):
prefix = prefix + "r"
elif(deckType == "quest"):
prefix = prefix + "q"
if(prefix != ""):
prefix = prefix + "_"
return prefix + str(deckId)
def getVersusKeys(versus, ordered = False):
defenseKeys = []
for versusType in versus:
targets = versus[versusType]
for target in targets:
defenseKeys.append(deckKey(versusType, target))
return defenseKeys