HearthSim / python-hslog

Python module to parse Hearthstone Power.log files
https://hearthsim.info
MIT License
62 stars 13 forks source link

Battlegrounds - How to get the board's state at the beginning of combat #10

Closed samuel-chp closed 4 years ago

samuel-chp commented 4 years ago

Hi,

I want to collect both players' minions at the start of the battle phase on Battlegrounds. I periodically read the Power.log and want to detect when the phases change and all minions have been created for combat.

How do I know when the log contains all the entities for combat?

samuel-chp commented 4 years ago

Ok, I figure it out myself. When the combat is about to begin this line is printed in the log : D 14:03:20.8593382 GameState.DebugPrintPower() - BLOCK_START BlockType=TRIGGER Entity=[entityName=XXX id=XXX zone=PLAY zonePos=0 cardId=TB_BaconShop_DragBuy player=4] EffectCardId=System.Collections.Generic.List 1[System.String] EffectIndex=0 Target=0 SubOption=-1 TriggerKeyword=0

And to know when the boards are ready, I search for this line : TAG_CHANGE Entity=GameEntity tag=STEP value=MAIN_END

So I read dynamically the log file, and when I detect the first line, I wait for the second line to be print and then I parse the log and I limit the packets until the one corresponding to the TAG_CHANGE line.