12-22-2014, 04:53 AM
It's not sufficient to detect When Home button appears: all troops and spells may not have been used for the battle. In this case, return home appears only after 3min timeout. Also, depending you get at least one star or not, the button is either "Surrender" or "End battle", with a prompt in the first case.
The best solution is to check gold + elixir change, and stop the battle after 30sec without changes. It works perfectly fine for me. It does not take that much cpu.
On my bot done in Java, i have a JSON config for:
- the army to train,
- the troops to deploy, in which order, how many, when to enable hero ability etc.
Sample army config:
Sample deploy config:
It's very convenient to change the trained army, troop deployment because it does not require to change the code. But, hey, it's a hell easier in Java.
The best solution is to check gold + elixir change, and stop the battle after 30sec without changes. It works perfectly fine for me. It does not take that much cpu.
On my bot done in Java, i have a JSON config for:
- the army to train,
- the troops to deploy, in which order, how many, when to enable hero ability etc.
Sample army config:
Quote:{
"BARBARIAN": "108",
"ARCHER": "107"
}
Sample deploy config:
Quote:[
{
"@type": "ScootCorners",
"troop": "BARBARIAN"
},
{
"@type": "HoldOn",
"duration": "10",
"unit": "SECONDS"
},
{
"@type": "SendTroopCount",
"troop": "BARBARIAN",
"count": "30",
"distribution": "RANDOM"
},
{
"@type": "SendTroopCount",
"troop": "ARCHER",
"count": "30",
"distribution": "RANDOM"
},
{
"@type": "HoldOn",
"duration": "2",
"unit": "SECONDS"
},
...
]
It's very convenient to change the trained army, troop deployment because it does not require to change the code. But, hey, it's a hell easier in Java.