mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
- Fixed PerSetTracking python script to handle new mtgdata format.
This commit is contained in:
@@ -6,13 +6,13 @@ pathToMtgData = "mtg-data.txt"
|
|||||||
import os,sys,fnmatch
|
import os,sys,fnmatch
|
||||||
|
|
||||||
if not os.path.exists(pathToMtgData) :
|
if not os.path.exists(pathToMtgData) :
|
||||||
print("This script requires the text version of Arch's mtg-data to be present.You can download it from slightlymagic.net's forum and either place the text version next to this script or edit this script and provide the path to the file at the top.")
|
print("This script requires the text version of Arch's mtg-data to be present.You can download it from slightlymagic.net's forum and either place the text version next to this script or edit this script and provide the path to the file at the top.")
|
||||||
print("Press Enter to exit")
|
print("Press Enter to exit")
|
||||||
raw_input("")
|
raw_input("")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if not os.path.isdir(sys.path[0] + os.sep + 'PerSetTrackingResults') :
|
if not os.path.isdir(sys.path[0] + os.sep + 'PerSetTrackingResults') :
|
||||||
os.mkdir(sys.path[0] + os.sep + 'PerSetTrackingResults')
|
os.mkdir(sys.path[0] + os.sep + 'PerSetTrackingResults')
|
||||||
|
|
||||||
forgeFolderFiles = []
|
forgeFolderFiles = []
|
||||||
forgeCards = []
|
forgeCards = []
|
||||||
@@ -31,23 +31,27 @@ prevline = ""
|
|||||||
#Parse mtg-data
|
#Parse mtg-data
|
||||||
print("Parsing mtg-data")
|
print("Parsing mtg-data")
|
||||||
with open(pathToMtgData) as mtgdata :
|
with open(pathToMtgData) as mtgdata :
|
||||||
for line in mtgdata :
|
for line in mtgdata :
|
||||||
if not hasFetchedSets :
|
if not hasFetchedSets :
|
||||||
if line != "\n" :
|
if line != "\n" :
|
||||||
setCodes.append(line[0:3])
|
code = line.split(' ')[0]
|
||||||
else :
|
setCodes.append(code)
|
||||||
hasFetchedSets = True
|
else :
|
||||||
if hasFetchedSets :
|
hasFetchedSets = True
|
||||||
if not hasFetchedCardName :
|
|
||||||
tmpName = line
|
|
||||||
tmpName = tmpName.rstrip()
|
|
||||||
tmpName = tmpName.replace("AE", "Ae")
|
|
||||||
hasFetchedCardName = True
|
|
||||||
if line == "\n" :
|
|
||||||
mtgDataCards[tmpName] = prevline.rstrip()
|
|
||||||
hasFetchedCardName = False
|
|
||||||
|
|
||||||
prevline = line
|
if hasFetchedSets :
|
||||||
|
if not hasFetchedCardName :
|
||||||
|
tmpName = line.rstrip().replace("AE", "Ae")
|
||||||
|
hasFetchedCardName = True
|
||||||
|
if line == "\n" :
|
||||||
|
sets = prevline.split(", ")
|
||||||
|
for i in range(len(sets)):
|
||||||
|
sets[i] = sets[i].split(' ')[0]
|
||||||
|
#print sets
|
||||||
|
mtgDataCards[tmpName] = sets
|
||||||
|
hasFetchedCardName = False
|
||||||
|
|
||||||
|
prevline = line
|
||||||
|
|
||||||
#Parse Forge
|
#Parse Forge
|
||||||
print("Parsing Forge")
|
print("Parsing Forge")
|
||||||
@@ -67,43 +71,44 @@ currentImplemented = []
|
|||||||
total = 0
|
total = 0
|
||||||
percentage = 0
|
percentage = 0
|
||||||
for currentSet in setCodes :
|
for currentSet in setCodes :
|
||||||
if currentSet == 'UNH' or currentSet == 'UGL' : continue #skip Unhinged and Unglued since they are only counting basic lands anyway
|
if currentSet == 'UNH' or currentSet == 'UGL' : continue #skip Unhinged and Unglued since they are only counting basic lands anyway
|
||||||
#if currentSet == 'VG1' or currentSet == 'VG2' or currentSet == 'VG3' : continue
|
#if currentSet == 'VG1' or currentSet == 'VG2' or currentSet == 'VG3' : continue
|
||||||
#if currentSet == 'VG4' or currentSet == 'VGO' or currentSet == 'VG ' : continue
|
#if currentSet == 'VG4' or currentSet == 'VGO' or currentSet == 'VG ' : continue
|
||||||
#if currentSet == 'FVD' or currentSet == 'FVE' or currentSet == 'FVR' : continue
|
#if currentSet == 'FVD' or currentSet == 'FVE' or currentSet == 'FVR' : continue
|
||||||
#if currentSet == 'SDC' or currentSet == 'AST' or currentSet == 'DKM' : continue
|
#if currentSet == 'SDC' or currentSet == 'AST' or currentSet == 'DKM' : continue
|
||||||
#if currentSet == 'BTD' or currentSet == 'ARC' or currentSet == 'COM' : continue
|
#if currentSet == 'BTD' or currentSet == 'ARC' or currentSet == 'COM' : continue
|
||||||
#if currentSet == 'CHR' or currentSet == 'MED' or currentSet == 'H09' : continue
|
#if currentSet == 'CHR' or currentSet == 'MED' or currentSet == 'H09' : continue
|
||||||
#if currentSet == 'ME2' or currentSet == 'ME3' or currentSet == 'ME4' : continue
|
#if currentSet == 'ME2' or currentSet == 'ME3' or currentSet == 'ME4' : continue
|
||||||
#if currentSet == 'ATH' or currentSet == 'HOP' or currentSet == 'BRB' : continue
|
#if currentSet == 'ATH' or currentSet == 'HOP' or currentSet == 'BRB' : continue
|
||||||
#if currentSet == 'EVG' or currentSet == 'GVL' or currentSet == 'JVC' : continue
|
#if currentSet == 'EVG' or currentSet == 'GVL' or currentSet == 'JVC' : continue
|
||||||
for card in mtgDataCards.keys() :
|
for key in mtgDataCards.keys() :
|
||||||
if mtgDataCards[card].count(currentSet) > 0 :
|
setList = mtgDataCards[key]
|
||||||
if card in forgeCards :
|
if currentSet in setList:
|
||||||
currentImplemented.append(card)
|
if key in forgeCards :
|
||||||
else :
|
currentImplemented.append(key)
|
||||||
currentMissing.append(card)
|
else :
|
||||||
total = len(currentMissing)+len(currentImplemented)
|
currentMissing.append(key)
|
||||||
percentage = 0
|
total = len(currentMissing)+len(currentImplemented)
|
||||||
if total > 0 :
|
percentage = 0
|
||||||
percentage = (float(len(currentImplemented))/float(total))*100
|
if total > 0 :
|
||||||
currentMissing.sort()
|
percentage = (float(len(currentImplemented))/float(total))*100
|
||||||
currentImplemented.sort()
|
currentMissing.sort()
|
||||||
|
currentImplemented.sort()
|
||||||
|
|
||||||
with open(sys.path[0] + os.sep + "PerSetTrackingResults" + os.sep + "set_" + currentSet.strip() + ".txt", "w") as output :
|
with open(sys.path[0] + os.sep + "PerSetTrackingResults" + os.sep + "set_" + currentSet.strip() + ".txt", "w") as output :
|
||||||
output.write("Implemented (" + str(len(currentImplemented)) + "):\n")
|
output.write("Implemented (" + str(len(currentImplemented)) + "):\n")
|
||||||
for everyImplemented in currentImplemented :
|
for everyImplemented in currentImplemented :
|
||||||
output.write(everyImplemented + '\n')
|
output.write(everyImplemented + '\n')
|
||||||
output.write("\n")
|
output.write("\n")
|
||||||
output.write("Missing (" + str(len(currentMissing)) + "):\n")
|
output.write("Missing (" + str(len(currentMissing)) + "):\n")
|
||||||
for everyMissing in currentMissing :
|
for everyMissing in currentMissing :
|
||||||
output.write(everyMissing + '\n')
|
output.write(everyMissing + '\n')
|
||||||
output.write("\n")
|
output.write("\n")
|
||||||
output.write("Total: " + str(total) + "\n")
|
output.write("Total: " + str(total) + "\n")
|
||||||
output.write("Percentage implemented: " + str(round(percentage,2)) + "%\n")
|
output.write("Percentage implemented: " + str(round(percentage,2)) + "%\n")
|
||||||
totalData[currentSet] = (len(currentImplemented),len(currentMissing),total,percentage)
|
totalData[currentSet] = (len(currentImplemented),len(currentMissing),total,percentage)
|
||||||
del currentMissing[:]
|
del currentMissing[:]
|
||||||
del currentImplemented[:]
|
del currentImplemented[:]
|
||||||
|
|
||||||
#sort sets by percentage completed
|
#sort sets by percentage completed
|
||||||
totalDataList = sorted(totalData.items(), key=lambda (key,entry): entry[3], reverse=True)
|
totalDataList = sorted(totalData.items(), key=lambda (key,entry): entry[3], reverse=True)
|
||||||
@@ -113,14 +118,14 @@ totalMissing = 0
|
|||||||
totalImplemented = 0
|
totalImplemented = 0
|
||||||
fullTotal = 0
|
fullTotal = 0
|
||||||
with open(sys.path[0] + os.sep + "PerSetTrackingResults" + os.sep + "CompleteStats.txt", "w") as statsfile:
|
with open(sys.path[0] + os.sep + "PerSetTrackingResults" + os.sep + "CompleteStats.txt", "w") as statsfile:
|
||||||
statsfile.write("Set: Implemented (Missing) / Total = Percentage Implemented\n")
|
statsfile.write("Set: Implemented (Missing) / Total = Percentage Implemented\n")
|
||||||
for k,dataKey in totalDataList :
|
for k,dataKey in totalDataList :
|
||||||
totalImplemented += dataKey[0]
|
totalImplemented += dataKey[0]
|
||||||
totalMissing += dataKey[1]
|
totalMissing += dataKey[1]
|
||||||
fullTotal += dataKey[2]
|
fullTotal += dataKey[2]
|
||||||
statsfile.write(k + ": " + str(dataKey[0]) + " (" + str(dataKey[1]) + ") / " + str(dataKey[2]) + " = " + str(round(dataKey[3], 2)) + "%\n")
|
statsfile.write(k + ": " + str(dataKey[0]) + " (" + str(dataKey[1]) + ") / " + str(dataKey[2]) + " = " + str(round(dataKey[3], 2)) + "%\n")
|
||||||
totalPercentage = totalImplemented / fullTotal
|
totalPercentage = totalImplemented / fullTotal
|
||||||
statsfile.write("\n")
|
statsfile.write("\n")
|
||||||
statsfile.write("Total over all sets: " + str(totalImplemented) + " (" + str(totalMissing) + ") / " + str(fullTotal))
|
statsfile.write("Total over all sets: " + str(totalImplemented) + " (" + str(totalMissing) + ") / " + str(fullTotal))
|
||||||
|
|
||||||
print "Done!"
|
print "Done!"
|
||||||
Reference in New Issue
Block a user