Jump to content


Convert Battle Results to JSON

battle results json credits income / outcome

This topic has been archived. This means that you cannot reply to this topic.
25 replies to this topic

Phalynx #1 Posted 27 September 2012 - 04:18 PM

    First Sergeant

  • Player
  • 7557 battles
  • 1,122
  • [MTW] MTW
  • Member since:
    07-14-2011
Since 0.8.0 your battles are recorded into binary files. If your purpose is to collect this data into readable format you are able to do with this service.

You can find your battle results here (they are deleted once WoT starts again)
%APPDATA%\Wargaming.net\WorldOfTanks\battle_results\your_profile\1059458110686133.dat

You can use also this little tool convert your battle results:
http://www.vbaddict....tsConverter.exe

Syntax:
BattleResultsConverter.exe battleresult.dat
It will create a battleresult.json in same path.


Example output:
http://vbaddict.net/...9861145944.json


An alternative way would be a tool called "Automatic Dossier Uploader" which is able to track new battle results and automatically uploading them to vbaddict.net/wot for further analysis. Beside a Battlelog a detailed income/expenditure for each of your tanks is also available.



Any feedback is appreciated.

Snib #2 Posted 27 September 2012 - 04:27 PM

    First Sergeant

  • Beta Tester
  • 18888 battles
  • 4,911
  • Member since:
    07-16-2010
+1 :)

lubox #3 Posted 05 October 2012 - 08:28 AM

    Lance-corporal

  • Player
  • 31799 battles
  • 52
  • [THEOS] THEOS
  • Member since:
    11-24-2011
Hi,

is your Battle Result converter ready? I've tried to upload my .dat file, but curl upload finished with error.

I'm .NET developer and I want to create simple application, that will collect result of our clan company/cw battles to create statistics about players from our clan.
Can u give me any advice how parse Battle Result file?

I've decoded some parts allready, but any advice will be helpfull.

Thanks

LuboX[R_R]

Phalynx #4 Posted 05 October 2012 - 09:14 AM

    First Sergeant

  • Player
  • 7557 battles
  • 1,122
  • [MTW] MTW
  • Member since:
    07-14-2011
Currently a clan module for analysis is in work, as this has been already requested multiple times. This would be integrated in my Active Dossier Uploader which is uploading data to http://www.vbaddict.net/wot
The first part of the battle result is very easy to decode. These are the fieldnames:
[
{"version": 1, "name": "health", "offset": 0, "length": 1},
{"version": 1, "name": "credits", "offset": 1, "length": 1},
{"version": 1, "name": "experience", "offset": 2, "length": 1},
{"version": 1, "name": "shots", "offset": 3, "length": 1},
{"version": 1, "name": "hits", "offset": 4, "length": 1},
{"version": 1, "name": "hits_he", "offset": 5, "length": 1},
{"version": 1, "name": "hits_penetrated", "offset": 6, "length": 1},
{"version": 1, "name": "damage_dealt", "offset": 7, "length": 1},
{"version": 1, "name": "damage_assisted", "offset": 8, "length": 1},
{"version": 1, "name": "damage_received", "offset": 9, "length": 1},
{"version": 1, "name": "hits_received", "offset": 10, "length": 1},
{"version": 1, "name": "spotted", "offset": 11, "length": 1},
{"version": 1, "name": "enemies_damaged", "offset": 12, "length": 1},
{"version": 1, "name": "kills", "offset": 13, "length": 1},
{"version": 1, "name": "team_damage", "offset": 14, "length": 1},
{"version": 1, "name": "team_kills", "offset": 15, "length": 1},
{"version": 1, "name": "is_team_killer", "offset": 16, "length": 1},
{"version": 1, "name": "capturePoints", "offset": 17, "length": 1},
{"version": 1, "name": "droppedCapturePoints", "offset": 18, "length": 1},
{"version": 1, "name": "mileage", "offset": 19, "length": 1},
{"version": 1, "name": "lifeTime", "offset": 20, "length": 1},
{"version": 1, "name": "killerID", "offset": 21, "length": 1},
{"version": 1, "name": "achievements", "offset": 22, "length": 1},
{"version": 1, "name": "repair", "offset": 23, "length": 1},
{"version": 1, "name": "freeXP", "offset": 24, "length": 1},
{"version": 1, "name": "details", "offset": 25, "length": 1},
{"version": 1, "name": "userid", "offset": 26, "length": 1},
{"version": 1, "name": "team", "offset": 27, "length": 1},
{"version": 1, "name": "tank", "offset": 28, "length": 1},
{"version": 1, "name": "gold", "offset": 29, "length": 1},
{"version": 1, "name": "xpPenalty", "offset": 30, "length": 1},
{"version": 1, "name": "creditsPenalty", "offset": 31, "length": 1},
{"version": 1, "name": "creditsContributionIn", "offset": 32, "length": 1},
{"version": 1, "name": "creditsContributionOut", "offset": 33, "length": 1},
{"version": 1, "name": "tmenXP", "offset": 34, "length": 1},
{"version": 1, "name": "eventCredits", "offset": 35, "length": 1},
{"version": 1, "name": "eventGold", "offset": 36, "length": 1},
{"version": 1, "name": "eventXP", "offset": 37, "length": 1},
{"version": 1, "name": "eventFreeXP", "offset": 38, "length": 1},
{"version": 1, "name": "eventTMenXP", "offset": 39, "length": 1},
{"version": 1, "name": "autoRepairCost", "offset": 40, "length": 1},
{"version": 1, "name": "autoLoadCost", "offset": 41, "length": 1},
{"version": 1, "name": "autoEquipCost", "offset": 42, "length": 1},
{"version": 1, "name": "premium", "offset": 43, "length": 1},
{"version": 1, "name": "premiumXPFactor10", "offset": 44, "length": 1},
{"version": 1, "name": "premiumCreditsFactor10", "offset": 45, "length": 1},
{"version": 1, "name": "dailyXPFactor10", "offset": 46, "length": 1},
{"version": 1, "name": "aogasFactor10", "offset": 47, "length": 1},
{"version": 1, "name": "markOfMastery", "offset": 48, "length": 1},
{"version": 1, "name": "dossierPopUps", "offset": 49, "length": 1}
]
The other chunks need a lot more of work.
What exactly does not work with cURL, can you post the error?

lubox #5 Posted 05 October 2012 - 09:47 AM

    Lance-corporal

  • Player
  • 31799 battles
  • 52
  • [THEOS] THEOS
  • Member since:
    11-24-2011
Hi,
First of all, I must say, that I've used curl first time. So maybe I did some stupi mistake   .


I've tried this:

curl --upload-file 24769073450438803.dat http://www.vbaddict.net/br2json.php --referer 24769073450438803.dat -o result.json


And it generated result.json file with this content:

ERROR
The requested URL could not be retrieved
------------------------------------
Invalid Request error was encountered while trying to process the request:
PUT /br2json.php HTTP/1.1
User-Agent: curl/7.23.1 (x86_64-pc-win32) libcurl/7.23.1
Host: www.vbaddict.net
Accept: */*
Referer: 24769073450438803.dat
Content-Length: 6615
Expect: 100-continue
Some possible problems are:
  * Missing or unknown request method.
  * Missing URL.
  * Missing HTTP Identifier (HTTP/1.0).
  * Request is too large.
  * Content-Length missing for POST or PUT requests.
  * Illegal character in hostname; underscores are not allowed.
  * HTTP/1.1 Expect: feature is being asked from an HTTP/1.0 software.
Your cache administrator is {webmaster}.
------------------------------------
Generated Fri, 05 Oct 2012 08:39:31 GMT by localhost (squid/3.1.20)


What is wrong?

Thx for advice about first part :) I've analyzed presence of player identities in that file. And my goal is to find amount of damage, XP and some other info about all players in battle. Do U know anything about the rest of data file?

LuboX

Edited by lubox, 05 October 2012 - 10:04 AM.


lubox #6 Posted 05 October 2012 - 10:43 AM

    Lance-corporal

  • Player
  • 31799 battles
  • 52
  • [THEOS] THEOS
  • Member since:
    11-24-2011
Or maybe i Can specify more my question:

How can I analyze begining and length of particular chunks?

LuboX

Phalynx #7 Posted 05 October 2012 - 10:45 AM

    First Sergeant

  • Player
  • 7557 battles
  • 1,122
  • [MTW] MTW
  • Member since:
    07-14-2011
You can use this little tool convert your battle results:
http://www.vbaddict....tsConverter.exe

Syntax:
BattleResultsConverter.exe battleresult.dat
It will create a battleresult.json in same path.

Phalynx #8 Posted 05 October 2012 - 10:47 AM

    First Sergeant

  • Player
  • 7557 battles
  • 1,122
  • [MTW] MTW
  • Member since:
    07-14-2011

View Postlubox, on 05 October 2012 - 10:43 AM, said:

Or maybe i Can specify more my question:

How can I analyze begining and length of particular chunks?

LuboX

Currently I don't have time to share the converter, as I need to prepare it for public.

All data stored in that file can be read via cPickle.

lubox #9 Posted 05 October 2012 - 11:18 AM

    Lance-corporal

  • Player
  • 31799 battles
  • 52
  • [THEOS] THEOS
  • Member since:
    11-24-2011

View PostPhalynx, on 05 October 2012 - 10:45 AM, said:

You can use this little tool convert your battle results:
http://www.vbaddict....tsConverter.exe

Syntax:
BattleResultsConverter.exe battleresult.dat
It will create a battleresult.json in same path.

Oh thanks ... this if very userfull for me :)

As I see, you created that in Visual Basic. Can you share source code? (or send it to my email sobulkebrh@centrum.cz)

Anyway, thanks for you Help... This small converting tool will do the job

L.

Phalynx #10 Posted 05 October 2012 - 11:28 AM

    First Sergeant

  • Player
  • 7557 battles
  • 1,122
  • [MTW] MTW
  • Member since:
    07-14-2011
Here is the really simple code. Nothing tricky, just a WebClient request to the php file and write the output to a file.

Spoiler                     


lubox #11 Posted 05 October 2012 - 11:33 AM

    Lance-corporal

  • Player
  • 31799 battles
  • 52
  • [THEOS] THEOS
  • Member since:
    11-24-2011

View PostPhalynx, on 05 October 2012 - 11:28 AM, said:

Here is the really simple code. Nothing tricky, just a WebClient request to the php file and write the output to a file.

Spoiler                     

I see ... :)

adri1wcrow #12 Posted 11 October 2012 - 04:24 PM

    Private

  • Player
  • 0 battles
  • 5
  • Member since:
    04-19-2012
What is the 'typeCompDescr' meaning?

Phalynx #13 Posted 11 October 2012 - 04:33 PM

    First Sergeant

  • Player
  • 7557 battles
  • 1,122
  • [MTW] MTW
  • Member since:
    07-14-2011
typeCompDescr contains the tankid and countryid, which has been already parsed in the JSON to tankID, countryID and tankName.

tanksource = bresult['personal']['typeCompDescr']
bresult['personal']['tankID'] = tanksource //256
bresult['personal']['countryID'] = ((tanksource - bresult['personal']['tankID'] * 256)-1) //16
bresult['personal']['tankName'] = get_tank_data(tanksdata, bresult['personal']['countryID'], bresult['personal']['tankID'], "title")


adri1wcrow #14 Posted 12 October 2012 - 04:42 AM

    Private

  • Player
  • 0 battles
  • 5
  • Member since:
    04-19-2012

View PostPhalynx, on 11 October 2012 - 04:33 PM, said:

typeCompDescr contains the tankid and countryid, which has been already parsed in the JSON to tankID, countryID and tankName.

tanksource = bresult['personal']['typeCompDescr']
bresult['personal']['tankID'] = tanksource //256
bresult['personal']['countryID'] = ((tanksource - bresult['personal']['tankID'] * 256)-1) //16
bresult['personal']['tankName'] = get_tank_data(tanksdata, bresult['personal']['countryID'], bresult['personal']['tankID'], "title")

How you find the meaning of the number? I can't imagine it.

Phalynx #15 Posted 12 October 2012 - 08:17 AM

    First Sergeant

  • Player
  • 7557 battles
  • 1,122
  • [MTW] MTW
  • Member since:
    07-14-2011

View Postadri1wcrow, on 12 October 2012 - 04:42 AM, said:

How you find the meaning of the number? I can't imagine it.
The knowledge about that countryid/nationid and tankid comes from the russian community, I suppose they have it from the devs. Or someone was able to debug the running exe aka reverse engineering.

adri1wcrow #16 Posted 13 October 2012 - 06:28 PM

    Private

  • Player
  • 0 battles
  • 5
  • Member since:
    04-19-2012
I can't use the 'BattleResultsConverter.exe' to convert dat only when the dat in the same path. Just like 'BattleResultsConverter.exe temp\1.dat'. It will return 'can not find a part of the path 'D: emp emp\1.json''
And I'm new in python and c#. So I failed to use the python to send the request to the php.
Is there any way to resolve it if not boring you?

I will try to fix it by make a exe use your c# src.

Edited by adri1wcrow, 14 October 2012 - 01:13 PM.


RammSkz #17 Posted 08 November 2012 - 05:42 AM

    Private

  • Player
  • 0 battles
  • 1
  • Member since:
    11-08-2012

View PostPhalynx, on 05 October 2012 - 10:47 AM, said:

All data stored in that file can be read via cPickle.
Tried to use cPickle within python 2.7, but all I get in unpickled data are a few numbers (exp, credits, etc.) and unreadable strings like
v\xa1\x99\x05p\xa1\x99\x05q\xa1\x99\x05l\xa1\x99\x05u\xa1\x99\x05m\xa1\x99\x05r\xa1\x99\x05x\xa1\x99\x05\x00\x00\x00\x00\x03\x00\x00\x00\x03\x00_\x05\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x92\x01\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x02\x00\x00\x00\x02\x00\x80\x02\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x04\x00\x00\x00\x02\x00`\x02\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x01\x00\x00\x00\x01\x00V\x00\x00\x00\x00\x00\x00\x00\x01\x00\x01\x00\x01\x00\x00\x00\x01\x00\xcc\x01\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x01\x00\x00\x00\x01\x00\xcb\x01\x00\x00\x01\x00\x00\x00\x00\x00\x01\x00\x02\x00\x00\x00\x02\x002\x00\x00\x00\x01\x00\x00\x00'
What am I doing wrong?

Edited by RammSkz, 08 November 2012 - 05:43 AM.


Phalynx #18 Posted 08 November 2012 - 11:12 AM

    First Sergeant

  • Player
  • 7557 battles
  • 1,122
  • [MTW] MTW
  • Member since:
    07-14-2011
You need to do a struct.unpack on that data.

AgentBlue #19 Posted 29 November 2012 - 03:12 PM

    Private

  • Player
  • 0 battles
  • 3
  • Member since:
    11-29-2012
So I downloaded your battlereportconverter.exe as well as put the code posted into my own application but when the json file is saved, there are just 2 blank lines. Why is this happening?

Phalynx #20 Posted 29 November 2012 - 03:48 PM

    First Sergeant

  • Player
  • 7557 battles
  • 1,122
  • [MTW] MTW
  • Member since:
    07-14-2011
Seems to be not a valid battle result file.