def main(): buildlist = [] #loopthrough the files for k in range (1): seedJSON = StatValues.requestSeedData(1) for i in range(len(seedJSON["matches"])): match = seedJSON["matches"][i] matchframes = match["timeline"]["frames"] #loop through each participant for j in range (1,10): team = 0 if j < 6: team == 1 else: team == 2 #sums of individual stats singleGamelistAD = statSum(matchframes, "FlatPhysicalDamageMod", team) singleGamelistHP = statSum(matchframes, "FlatHPPoolMod", team) singleGamelistAP = statSum(matchframes, "FlatMagicDamageMod", team) singleGamelistARM = statSum(matchframes, "FlatArmorMod", team) singleGamelistCRIT = statSum(matchframes, "FlatCritChanceMod", team) singleGamelistMR = statSum(matchframes, "FlatSpellBlockMod", team) singleGamelistAS = statSum(matchframes, "PercentAttackSpeedMod", team) #loop through the timeline sums for t in range (len(singleGamelistAD)): #aggregates stats into "effective stats" champid = match["participants"][j]["championId"] AD = singleGamelistAD[t] + singleGamelistAD[t] * singleGamelistAS[t] + singleGamelistAD[t] * singleGamelistCRIT[t] AP = singleGamelistAP[t] ARM = singleGamelistARM[t] + singleGamelistHP[t] MR = singleGamelistMR[t] + singleGamelistHP[t] #creates the hash for that "situation" hashsit = hash(AD, AP, ARM, MR, champid) #build object, which has build and situation in it as well as winrate build = SituationalBuild.SituationalBuild(hashsit, finalbuildorder(match, j)) buildlist.append(build) if match["participants"][j]["stats"]["winner"] == True: build.addWin() else: build.addloss() #list now is sorted by situation and by winrate ''' for i in range (len(buildlist)): print(buildlist[i].getbuildseq() + " " + str(buildlist[i].getwinrate()) + " " + str(buildlist[i].getsituation())) ''' #processes the builds situationbuild = situationalbuildlist(buildlist) for k in range (len(situationbuild)): sorted(situationbuild[k], key = getKey) condensebuilds(situationbuild) #database stuff conn = sqlite3.connect('main.db') conn.execute('''CREATE TABLE DATA2 (Hash INT r0 TEXT, r1 TEXT, r2 TEXT, r3 TEXT, r4 TEXT, r5 TEXT, r6 TEXT, r7 TEXT, r8 TEXT, r9 TEXT, r10 TEXT, r11 TEXT, r12 TEXT, r13 TEXT, r14 TEXT, r15 TEXT, r16 TEXT, r17 TEXT, r18 TEXT, r19 TEXT, r20 TEXT, r21 TEXT, r22 TEXT, r23 TEXT, r24 TEXT, r25 TEXT, r26 TEXT, r27 TEXT, r28 TEXT, r29 TEXT, r30 TEXT, r31 TEXT, r32 TEXT, r33 TEXT, r34 TEXT, r35 TEXT, r36 TEXT, r37 TEXT, r38 TEXT, r39 TEXT, r40 TEXT, r41 TEXT, r42 TEXT, r43 TEXT, r44 TEXT, r45 TEXT, r46 TEXT, r47 TEXT, r48 TEXT, r49 TEXT, r50 TEXT);''') #basically writes something like a 2d table, one dimension the hash and the other builds sorted by winrate for i in range (len(situationbuild)): for j in range (len(situationbuild[i])): if j > 50: break if j < 1: continue conn.execute("INSERT INTO DATA2 (Hash, " +"r" + str(j) + ") \ VALUES (" + str(int(situationbuild[i][j].getsituation()/5000)) + ", " + str(situationbuild[i][j].getbuildseq()) + " )"); conn.commit() conn.close()
def main(): buildlist = [] #loopthrough the files for k in range(1): seedJSON = StatValues.requestSeedData(1) for i in range(len(seedJSON["matches"])): match = seedJSON["matches"][i] matchframes = match["timeline"]["frames"] #loop through each participant for j in range(1, 10): team = 0 if j < 6: team == 1 else: team == 2 #sums of individual stats singleGamelistAD = statSum(matchframes, "FlatPhysicalDamageMod", team) singleGamelistHP = statSum(matchframes, "FlatHPPoolMod", team) singleGamelistAP = statSum(matchframes, "FlatMagicDamageMod", team) singleGamelistARM = statSum(matchframes, "FlatArmorMod", team) singleGamelistCRIT = statSum(matchframes, "FlatCritChanceMod", team) singleGamelistMR = statSum(matchframes, "FlatSpellBlockMod", team) singleGamelistAS = statSum(matchframes, "PercentAttackSpeedMod", team) #loop through the timeline sums for t in range(len(singleGamelistAD)): #aggregates stats into "effective stats" champid = match["participants"][j]["championId"] AD = singleGamelistAD[ t] + singleGamelistAD[t] * singleGamelistAS[ t] + singleGamelistAD[t] * singleGamelistCRIT[t] AP = singleGamelistAP[t] ARM = singleGamelistARM[t] + singleGamelistHP[t] MR = singleGamelistMR[t] + singleGamelistHP[t] #creates the hash for that "situation" hashsit = hash(AD, AP, ARM, MR, champid) #build object, which has build and situation in it as well as winrate build = SituationalBuild.SituationalBuild( hashsit, finalbuildorder(match, j)) buildlist.append(build) if match["participants"][j]["stats"]["winner"] == True: build.addWin() else: build.addloss() #list now is sorted by situation and by winrate ''' for i in range (len(buildlist)): print(buildlist[i].getbuildseq() + " " + str(buildlist[i].getwinrate()) + " " + str(buildlist[i].getsituation())) ''' #processes the builds situationbuild = situationalbuildlist(buildlist) for k in range(len(situationbuild)): sorted(situationbuild[k], key=getKey) condensebuilds(situationbuild) #database stuff conn = sqlite3.connect('main.db') conn.execute('''CREATE TABLE DATA2 (Hash INT r0 TEXT, r1 TEXT, r2 TEXT, r3 TEXT, r4 TEXT, r5 TEXT, r6 TEXT, r7 TEXT, r8 TEXT, r9 TEXT, r10 TEXT, r11 TEXT, r12 TEXT, r13 TEXT, r14 TEXT, r15 TEXT, r16 TEXT, r17 TEXT, r18 TEXT, r19 TEXT, r20 TEXT, r21 TEXT, r22 TEXT, r23 TEXT, r24 TEXT, r25 TEXT, r26 TEXT, r27 TEXT, r28 TEXT, r29 TEXT, r30 TEXT, r31 TEXT, r32 TEXT, r33 TEXT, r34 TEXT, r35 TEXT, r36 TEXT, r37 TEXT, r38 TEXT, r39 TEXT, r40 TEXT, r41 TEXT, r42 TEXT, r43 TEXT, r44 TEXT, r45 TEXT, r46 TEXT, r47 TEXT, r48 TEXT, r49 TEXT, r50 TEXT);''') #basically writes something like a 2d table, one dimension the hash and the other builds sorted by winrate for i in range(len(situationbuild)): for j in range(len(situationbuild[i])): if j > 50: break if j < 1: continue conn.execute("INSERT INTO DATA2 (Hash, " + "r" + str(j) + ") \ VALUES (" + str(int(situationbuild[i][j].getsituation() / 5000)) + ", " + str(situationbuild[i][j].getbuildseq()) + " )") conn.commit() conn.close()