Skip to content

Commit

Permalink
Added new command "extract" to extract the json data from a single re…
Browse files Browse the repository at this point in the history
…play to a json file
  • Loading branch information
Yoshi_E authored and Yoshi_E committed Dec 2, 2017
1 parent 705b477 commit 4f42a2b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# WorldofWarshipsScripts
A collection of useful, or not so useful scripts and tools

This releases can be found here: https://github.com/Yoshi-EE/WorldofWarshipsScripts/releases
This releases can be found here: https://github.com/Yoshi-EE/WorldofWarshipsScripts/releases

More changes coming soon.
20 changes: 18 additions & 2 deletions WowsReplayTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
epilog="")

parser.add_argument('-path', nargs=1, help='Path to replay Folder, default = current_path', default=os.path.dirname(os.path.realpath(__file__))+"/")
parser.add_argument('-extract', nargs=1, help='Path to replay file, default = current_path', default="")
parser.add_argument('--wait', help='Waits before closing window, default = False', action='store_const', const=True, default=False)
parser.add_argument('-app_id', nargs=1, help='Wargaming API ID (developers.wargaming.net), default is given', default="23c72eadf6267847fc48a35d03bdb2ef")
parser.add_argument('-output', nargs=1, help='Path to cvs files, default = binary_path', default=os.path.dirname(os.path.realpath(__file__))+"/")
parser.add_argument('-output', nargs=1, help='universal output path, default = binary_path', default=os.path.dirname(os.path.realpath(__file__))+"/")
parser.add_argument('-prefix', nargs=1, help='Prefix for cvs files, default = None', default="")
parser.add_argument('--Random', help='Tracks Random Games, default = False', action='store_const', const=True, default=False)
parser.add_argument('--Coop', help='Tracks Coop Games, default = False', action='store_const', const=True, default=False)
Expand Down Expand Up @@ -67,7 +68,7 @@
#If In script:
if("Python" in shipDB_path):
shipDB_path = os.path.dirname(os.path.realpath(__file__))+"/"

print("Replay path: "+default_path)
print("CVS path: "+cvs_output)
print("ShipDB path: "+shipDB_path)
Expand Down Expand Up @@ -167,8 +168,23 @@ def calcAvrg(A,B):
return (("%.2f" % (float(A) / B)).replace(".",","))
else:
return 0



def extractReplay(path):
jsonData = loadReplay(path)
with open(cvs_output+os.path.basename(path)+".json", "w") as outfile:
json.dump(jsonData, outfile)
print("Extracted replay to: "+cvs_output+os.path.basename(path)+".json")


if(args['extract'] != ""):
extractReplay(''.join(args['extract']))
sys.exit()
#Program stats here :)



askForDatabase() #Ensures you have the information about the ships
replayFiles = getFiles(default_path) #Gets a List with all replay file paths
shipDatabase = loadShipDatbase() #Loads Database from file
Expand Down

0 comments on commit 4f42a2b

Please sign in to comment.