|
|
@@ -1,6 +1,5 @@
|
|
|
#include <Date.au3>
|
|
|
;; Klanhaboru fun
|
|
|
-;; https://git.petyuspolisz.com/chestercs/klanhaboru/src/master/klanhaboru_main.au3
|
|
|
|
|
|
#Region === Configurations
|
|
|
AutoItSetOption("SendKeyDelay", 1)
|
|
|
@@ -8,160 +7,227 @@
|
|
|
AutoItSetOption("WinTitleMatchMode", 2)
|
|
|
AutoItSetOption("TrayAutoPause" ,0)
|
|
|
|
|
|
- Global $browser = IniRead(@ScriptDir & "/config.ini", "Options", "browser", "Google Chrome")
|
|
|
- Global $gameTitle = IniRead(@ScriptDir & "/config.ini", "Options", "gameTitle", "Klánháború")
|
|
|
- Global $server = IniRead(@ScriptDir & "/config.ini", "Options", "server", "hu83") ; get it from game url
|
|
|
- Global $villageId = IniRead(@ScriptDir & "/config.ini", "Options", "villageId", "1") ; get it from game url
|
|
|
- Global $scavengeMode = IniRead(@ScriptDir & "/config.ini", "Options", "scavengeMode", "2") ; Mode 0-3 (0-Lusta gyûjtögetõk, 1-Szerény gyûjtögetõk, 2-Okos gyûjtögetõk, 3-Kiváló gyûjtögetõk)
|
|
|
- Global $traytip = IniRead(@ScriptDir & "/config.ini", "Options", "trayTip", true)
|
|
|
-
|
|
|
- Global $trainUnitRepeatTimer = 3600 ; in seconds (default: 1h)
|
|
|
- Global $trainLovassagRepeatTimer = 3600 ; in seconds (default: 1h)
|
|
|
- Global $epitesRepeatTimer = 3600 ; in seconds (default: 10min)
|
|
|
- Global $trainKnightRepeatTimer = 9000 ; in seconds (default: 10min)
|
|
|
+ Global $browser = IniRead(@ScriptDir & "/config.ini", "Options", "browser", "Google Chrome")
|
|
|
+ Global $gameTitle = IniRead(@ScriptDir & "/config.ini", "Options", "gameTitle", "Klánháború")
|
|
|
+ Global $server = IniRead(@ScriptDir & "/config.ini", "Options", "server", "hu83") ; get it from game url
|
|
|
+ Global $villageId = IniRead(@ScriptDir & "/config.ini", "Options", "villageId", "1") ; get it from game url
|
|
|
+ Global $scavengeMode = IniRead(@ScriptDir & "/config.ini", "Options", "scavengeMode", "2") ; Mode 0-3 (0-Lusta gyûjtögetõk, 1-Szerény gyûjtögetõk, 2-Okos gyûjtögetõk, 3-Kiváló gyûjtögetõk)
|
|
|
+ Global $traytip = IniRead(@ScriptDir & "/config.ini", "Options", "trayTip", true)
|
|
|
+ Global $debug = IniRead(@ScriptDir & "/config.ini", "Options", "debug", false)
|
|
|
Global $gyujtogetesEventTimer = eventStart(0) ; delay task after bot started with seconds (default: 0)
|
|
|
Global $trainUnitsEventTimer = eventStart(0) ; delay task after bot started with seconds (default: 0)
|
|
|
Global $trainLovassagEventTimer = eventStart(0) ; delay task after bot started with seconds (default: 0)
|
|
|
+ Global $trainMachinesEventTimer = eventStart(0) ; delay task after bot started with seconds (default: 0)
|
|
|
Global $epitesEventTimer = eventStart(0) ; delay task after bot started with seconds (default: 0)
|
|
|
Global $trainKnightEventTimer = eventStart(0) ; delay task after bot started with seconds (default: 0)
|
|
|
- Global $pageLoadTime = 1500 ; inMs
|
|
|
- Global $sleepTimesInEndOfTasks = 2200 ; inMs
|
|
|
-#EndRegion
|
|
|
+ Global $sendAttackEventTimer = eventStart(0) ; delay task after bot started with seconds (default: 0)
|
|
|
|
|
|
+ Global $pageLoadTime = 0 ; inMs ; look at navigateToUrl last WinWaitActive
|
|
|
+ Global $sleepTimesInEndOfTasks = 3000 ; inMs
|
|
|
+#EndRegion
|
|
|
|
|
|
|
|
|
-While 1
|
|
|
- gyujtogetes(false, 2, -1, -1, -1, -1, -1, -1, -1, 0) ; sendAll, mode, landzsas, kardforgato, bardos, ijasz, konnyulovas, lovasijasz, nehezlovas, lovag (can be -1 what is meant to all unit button)
|
|
|
- trainUnits(0, 0, 0, 5) ; landzsas, kardforgato, bardos, ijasz (can be -1 what is meant to all unit button)
|
|
|
- trainLovassag(0, 5, 0, 0) ; kem, konnyulovas, lovasijasz, nehezlovas (can be -1 what is meant to all unit button)
|
|
|
- epites("wood") ; Options: main, barracks, stable, watchtower, smith, place, statue, market, wood, stone, iron, farm, storage, hide, wall
|
|
|
- trainKnight()
|
|
|
- TrayTipGG("")
|
|
|
+While loopEnd()
|
|
|
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;; Gyûjtögetés
|
|
|
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;; sendAll, mode, landzsas, kardforgato, bardos, ijasz, konnyulovas, lovasijasz, nehezlovas, lovag (-1 meant to send all unit button)
|
|
|
+ $gyujtogetesEventTimer = gyujtogetes(false, 3, 0, 0, 0, 0, -1, -1, -1, 0, $gyujtogetesEventTimer)
|
|
|
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;; Train Units
|
|
|
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;; landzsas, kardforgato, bardos, ijasz (can be -1 what is meant to all unit button)
|
|
|
+ $trainUnitsEventTimer = trainUnits( 0, 0, 0, 0, 3600, $trainUnitsEventTimer)
|
|
|
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;; Train Lovassag
|
|
|
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;; kem, konnyulovas, lovasijasz, nehezlovas (can be -1 what is meant to all unit button)
|
|
|
+ $trainLovassagEventTimer = trainLovassag( 0, 0, 0, 0, 3600, $trainLovassagEventTimer)
|
|
|
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;; Train Machinery
|
|
|
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;; kos, katapult (can be -1 what is meant to all unit button)
|
|
|
+ $trainMachinesEventTimer = trainMachines( 0, 0, 3600, $trainMachinesEventTimer)
|
|
|
+
|
|
|
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;; Építés
|
|
|
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;; Options: main, barracks, stable, watchtower, smith, place, statue, market, wood, stone, iron, farm, storage, hide, wall
|
|
|
+ $epitesEventTimer = epites( "farm", 3600, $epitesEventTimer)
|
|
|
+
|
|
|
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;; Train Knight
|
|
|
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
+ $trainKnightEventTimer = trainKnight( 9000, $trainKnightEventTimer)
|
|
|
+
|
|
|
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;; Send Attack
|
|
|
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;; $x, $y, $landzsas, $kardforgato, $bardos, $ijasz, $kem, $konnyulovas, $lovasijasz, $nehezlovas, $kos, $katapult, $lovag, $nemes, $eventTimer, $repeatTimer
|
|
|
+ $sendAttackEventTimer = sendAttack( 490, 562, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 3600, $sendAttackEventTimer) ; 10800 - 3h
|
|
|
WEnd
|
|
|
|
|
|
|
|
|
-
|
|
|
#Region === Functions
|
|
|
-Func gyujtogetes($sendAll, $mode, $landzsas, $kardforgato, $bardos, $ijasz, $konnyulovas, $lovasijasz, $nehezlovas, $lovag) ;Mode 0-3 (0-Lusta gyûjtögetõk, 1-Szerény gyûjtögetõk, 2-Okos gyûjtögetõk, 3-Kiváló gyûjtögetõk)
|
|
|
- If (Not eventTriggered($gyujtogetesEventTimer)) Then Return false
|
|
|
- If ($sendAll = false and $landzsas = 0 and $kardforgato = 0 and $bardos = 0 and $ijasz = 0 and $konnyulovas = 0 and $lovasijasz = 0 and $nehezlovas = 0 and $lovag = 0) Then Return False
|
|
|
+Func loopEnd()
|
|
|
+ TrayTipGG("")
|
|
|
+ Sleep(1000)
|
|
|
+ return true
|
|
|
+EndFunc
|
|
|
+
|
|
|
+Func gyujtogetes($sendAll, $mode, $landzsas, $kardforgato, $bardos, $ijasz, $konnyulovas, $lovasijasz, $nehezlovas, $lovag, $eventTimer) ;Mode 0-3 (0-Lusta gyûjtögetõk, 1-Szerény gyûjtögetõk, 2-Okos gyûjtögetõk, 3-Kiváló gyûjtögetõk)
|
|
|
+ If ($sendAll = false and $landzsas = 0 and $kardforgato = 0 and $bardos = 0 and $ijasz = 0 and $konnyulovas = 0 and $lovasijasz = 0 and $nehezlovas = 0 and $lovag = 0) Then Return $eventTimer
|
|
|
+ If (Not eventTriggered($eventTimer)) Then Return $eventTimer
|
|
|
TraytipGG("Gyüjtögetés started!" & @CRLF)
|
|
|
openNewTab()
|
|
|
navigateUrl(getGameUrl("place", "scavenge"), false)
|
|
|
- Sleep($pageLoadTime)
|
|
|
+
|
|
|
+ $seconds = parseTimeToSeconds(getDataWithJs("document.getElementsByClassName('scavenge-option')[" & $mode & "].getElementsByClassName('return-countdown')[0]"))
|
|
|
+ If ($seconds > 0) Then
|
|
|
+ $eventTimer = eventStart($seconds)
|
|
|
+ endTask("Gyüjtögetés in progress, next event: " & $eventTimer)
|
|
|
+ Return $eventTimer
|
|
|
+ EndIf
|
|
|
+
|
|
|
If ($sendAll) Then
|
|
|
sendJsClickByClass("fill-all")
|
|
|
Else
|
|
|
- If ($landzsas > 0) Then jsExecutor("document.getElementsByName('spear')[0].value = '" & $landzsas & "';")
|
|
|
- If ($kardforgato > 0) Then jsExecutor("document.getElementsByName('sword')[0].value = '" & $kardforgato & "';")
|
|
|
- If ($bardos > 0) Then jsExecutor("document.getElementsByName('axe')[0].value = '" & $bardos & "';")
|
|
|
- If ($ijasz > 0) Then jsExecutor("document.getElementsByName('archer')[0].value = '" & $ijasz & "';")
|
|
|
- If ($konnyulovas > 0) Then jsExecutor("document.getElementsByName('light')[0].value = '" & $konnyulovas & "';")
|
|
|
- If ($lovasijasz > 0) Then jsExecutor("document.getElementsByName('marcher')[0].value = '" & $lovasijasz & "';")
|
|
|
- If ($nehezlovas > 0) Then jsExecutor("document.getElementsByName('heavy')[0].value = '" & $nehezlovas & "';")
|
|
|
- If ($lovag > 0) Then jsExecutor("document.getElementsByName('knight')[0].value = '" & $lovag & "';")
|
|
|
-
|
|
|
- If ($landzsas < 0) Then jsExecutor("document.getElementsByName('spear')[0].parentElement.children[1].click();")
|
|
|
- If ($kardforgato < 0) Then jsExecutor("document.getElementsByName('sword')[0].parentElement.children[1].click();")
|
|
|
- If ($bardos < 0) Then jsExecutor("document.getElementsByName('axe')[0].parentElement.children[1].click();")
|
|
|
- If ($ijasz < 0) Then jsExecutor("document.getElementsByName('archer')[0].parentElement.children[1].click();")
|
|
|
- If ($konnyulovas < 0) Then jsExecutor("document.getElementsByName('light')[0].parentElement.children[1].click();")
|
|
|
- If ($lovasijasz < 0) Then jsExecutor("document.getElementsByName('marcher')[0].parentElement.children[1].click();")
|
|
|
- If ($nehezlovas < 0) Then jsExecutor("document.getElementsByName('heavy')[0].parentElement.children[1].click();")
|
|
|
- If ($lovag < 0) Then jsExecutor("document.getElementsByName('knight')[0].parentElement.children[1].click();")
|
|
|
+ sendUnits($landzsas, $kardforgato, $bardos, $ijasz)
|
|
|
+ sendLovassag(0, $konnyulovas, $lovasijasz, $nehezlovas)
|
|
|
+ sendRoyalties($lovag, 0)
|
|
|
EndIf
|
|
|
- Sleep(300)
|
|
|
jsExecutor("document.getElementsByClassName('scavenge-option')[" & $mode & "].getElementsByClassName('btn-default')[0].click();")
|
|
|
- Sleep($pageLoadTime)
|
|
|
- $gyujtogetesEventTimer = eventStart(parseTimeToSeconds(getDataWithJs("document.getElementsByClassName('scavenge-option')[" & $mode & "].getElementsByClassName('return-countdown')[0]")))
|
|
|
- closeTab()
|
|
|
- TraytipGG("Gyüjtögetés done, next event: " & $gyujtogetesEventTimer & @CRLF)
|
|
|
- ConsoleWrite(@CRLF)
|
|
|
- Sleep($sleepTimesInEndOfTasks)
|
|
|
+ Sleep(1000)
|
|
|
+ $seconds = parseTimeToSeconds(getDataWithJs("document.getElementsByClassName('scavenge-option')[" & $mode & "].getElementsByClassName('return-countdown')[0]"))
|
|
|
+ If ($seconds > 0) Then
|
|
|
+ $eventTimer = eventStart($seconds)
|
|
|
+ endTask("Gyüjtögetés done, next event: " & $eventTimer)
|
|
|
+ Return $eventTimer
|
|
|
+ EndIf
|
|
|
+ endTask("Gyüjtögetés ERROR!", 3)
|
|
|
+ Return $eventTimer
|
|
|
EndFunc
|
|
|
|
|
|
|
|
|
-Func trainUnits($landzsas, $kardforgato, $bardos, $ijasz)
|
|
|
- If (Not eventTriggered($trainUnitsEventTimer)) Then Return false
|
|
|
- If ($landzsas = 0 and $kardforgato = 0 and $bardos = 0 and $ijasz = 0) Then Return False
|
|
|
+Func trainUnits($landzsas, $kardforgato, $bardos, $ijasz, $repeatTimer, $eventTimer)
|
|
|
+ If ($landzsas = 0 and $kardforgato = 0 and $bardos = 0 and $ijasz = 0) Then Return $eventTimer
|
|
|
+ If (Not eventTriggered($trainUnitsEventTimer)) Then Return $eventTimer
|
|
|
TraytipGG("Train Units started!" & @CRLF)
|
|
|
openNewTab()
|
|
|
navigateUrl(getGameUrl("barracks"), false)
|
|
|
- Sleep($pageLoadTime)
|
|
|
- If ($landzsas > 0) Then jsExecutor("document.getElementsByName('spear')[0].value = '" & $landzsas & "';")
|
|
|
- If ($kardforgato > 0) Then jsExecutor("document.getElementsByName('sword')[0].value = '" & $kardforgato & "';")
|
|
|
- If ($bardos > 0) Then jsExecutor("document.getElementsByName('axe')[0].value = '" & $bardos & "';")
|
|
|
- If ($ijasz > 0) Then jsExecutor("document.getElementsByName('archer')[0].value = '" & $ijasz & "';")
|
|
|
- If ($landzsas < 0) Then jsExecutor("document.getElementsByName('spear')[0].parentElement.children[1].click();")
|
|
|
- If ($kardforgato < 0) Then jsExecutor("document.getElementsByName('sword')[0].parentElement.children[1].click();")
|
|
|
- If ($bardos < 0) Then jsExecutor("document.getElementsByName('axe')[0].parentElement.children[1].click();")
|
|
|
- If ($ijasz < 0) Then jsExecutor("document.getElementsByName('archer')[0].parentElement.children[1].click();")
|
|
|
+ sendUnits($landzsas, $kardforgato, $bardos, $ijasz)
|
|
|
sendJsClickByClass("btn-recruit")
|
|
|
- Sleep($pageLoadTime)
|
|
|
- $trainUnitsEventTimer = eventStart($trainUnitRepeatTimer)
|
|
|
- closeTab()
|
|
|
- TraytipGG("Train Units done, next event: " & $trainUnitsEventTimer & @CRLF)
|
|
|
- ConsoleWrite(@CRLF)
|
|
|
- Sleep($sleepTimesInEndOfTasks)
|
|
|
+
|
|
|
+ $eventTimer = eventStart($repeatTimer)
|
|
|
+ endTask("Train Units done, next event: " & $eventTimer)
|
|
|
+ Return $eventTimer
|
|
|
EndFunc
|
|
|
|
|
|
|
|
|
-Func trainLovassag($kem, $konnyulovas, $lovasijasz, $nehezlovas)
|
|
|
- If (Not eventTriggered($trainLovassagEventTimer)) Then Return false
|
|
|
- If ($kem = 0 and $konnyulovas = 0 and $lovasijasz = 0 and $nehezlovas = 0) Then Return False
|
|
|
+Func trainLovassag($kem, $konnyulovas, $lovasijasz, $nehezlovas, $repeatTimer, $eventTimer)
|
|
|
+ If ($kem = 0 and $konnyulovas = 0 and $lovasijasz = 0 and $nehezlovas = 0) Then Return $eventTimer
|
|
|
+ If (Not eventTriggered($trainLovassagEventTimer)) Then Return $eventTimer
|
|
|
TraytipGG("Train Lovassag started!" & @CRLF)
|
|
|
openNewTab()
|
|
|
navigateUrl(getGameUrl("stable"), false)
|
|
|
Sleep($pageLoadTime)
|
|
|
- If ($kem > 0) Then jsExecutor("document.getElementsByName('spy')[0].value = '" & $kem & "';")
|
|
|
- If ($konnyulovas > 0) Then jsExecutor("document.getElementsByName('light')[0].value = '" & $konnyulovas & "';")
|
|
|
- If ($lovasijasz > 0) Then jsExecutor("document.getElementsByName('marcher')[0].value = '" & $lovasijasz & "';")
|
|
|
- If ($nehezlovas > 0) Then jsExecutor("document.getElementsByName('heavy')[0].value = '" & $nehezlovas & "';")
|
|
|
- If ($kem < 0) Then jsExecutor("document.getElementsByName('spy')[0].parentElement.children[1].click();")
|
|
|
- If ($konnyulovas < 0) Then jsExecutor("document.getElementsByName('light')[0].parentElement.children[1].click();")
|
|
|
- If ($lovasijasz < 0) Then jsExecutor("document.getElementsByName('marcher')[0].parentElement.children[1].click();")
|
|
|
- If ($nehezlovas < 0) Then jsExecutor("document.getElementsByName('heavy')[0].parentElement.children[1].click();")
|
|
|
+ sendLovassag($kem, $konnyulovas, $lovasijasz, $nehezlovas)
|
|
|
sendJsClickByClass("btn-recruit")
|
|
|
+
|
|
|
+ $eventTimer = eventStart($repeatTimer)
|
|
|
+ endTask("Train Lovassag done, next event: " & $eventTimer)
|
|
|
+ Return $eventTimer
|
|
|
+EndFunc
|
|
|
+
|
|
|
+Func trainMachines($kos, $katapult, $repeatTimer, $eventTimer)
|
|
|
+ If ($kos = 0 and $katapult = 0 and) Then Return $eventTimer
|
|
|
+ If (Not eventTriggered($trainMachinesEventTimer)) Then Return $eventTimer
|
|
|
+ TraytipGG("Train Machines started!" & @CRLF)
|
|
|
+ openNewTab()
|
|
|
+ navigateUrl(getGameUrl("garage"), false)
|
|
|
Sleep($pageLoadTime)
|
|
|
- $trainLovassagEventTimer = eventStart($trainLovassagRepeatTimer)
|
|
|
- closeTab()
|
|
|
- TraytipGG("Train Lovassag done, next event: " & $trainLovassagEventTimer & @CRLF)
|
|
|
- ConsoleWrite(@CRLF)
|
|
|
- Sleep($sleepTimesInEndOfTasks)
|
|
|
+ sendMachines($kos, $katapult)
|
|
|
+ sendJsClickByClass("btn-recruit")
|
|
|
+
|
|
|
+ $eventTimer = eventStart($repeatTimer)
|
|
|
+ endTask("Train Machines done, next event: " & $eventTimer)
|
|
|
+ Return $eventTimer
|
|
|
EndFunc
|
|
|
|
|
|
|
|
|
-Func epites($buildingId) ;Options: main, barracks, stable, watchtower, smith, place, statue, market, wood, stone, iron, farm, storage, hide, wall
|
|
|
- If (Not eventTriggered($epitesEventTimer)) Then Return false
|
|
|
+Func epites($buildingId, $repeatTimer, $eventTimer) ;Options: main, barracks, stable, watchtower, smith, place, statue, market, wood, stone, iron, farm, storage, hide, wall
|
|
|
+ If (Not eventTriggered($epitesEventTimer)) Then Return $eventTimer
|
|
|
TraytipGG("Epites started: " & $buildingId & @CRLF)
|
|
|
openNewTab()
|
|
|
navigateUrl(getGameUrl("main"), false)
|
|
|
Sleep($pageLoadTime)
|
|
|
jsExecutor("document.querySelector('{#}main_buildrow_" & $buildingId & "').querySelector('a.btn-build').click();")
|
|
|
- Sleep($pageLoadTime)
|
|
|
- $epitesEventTimer = eventStart($epitesRepeatTimer)
|
|
|
- closeTab()
|
|
|
- TraytipGG("Epites done, next event: " & $epitesEventTimer & @CRLF)
|
|
|
- ConsoleWrite(@CRLF)
|
|
|
- Sleep($sleepTimesInEndOfTasks)
|
|
|
+
|
|
|
+ $eventTimer = eventStart($repeatTimer)
|
|
|
+ endTask("Epites done, next event: " & $eventTimer)
|
|
|
+ Return $eventTimer
|
|
|
EndFunc
|
|
|
|
|
|
|
|
|
-Func trainKnight()
|
|
|
- If (Not eventTriggered($trainKnightEventTimer)) Then Return false
|
|
|
+Func trainKnight($repeatTimer, $eventTimer)
|
|
|
+ If (Not eventTriggered($trainKnightEventTimer)) Then Return $eventTimer
|
|
|
TraytipGG("Train Knight started! " & @CRLF)
|
|
|
openNewTab()
|
|
|
navigateUrl(getGameUrl("statue"), false)
|
|
|
Sleep($pageLoadTime)
|
|
|
sendJsClickByClass("knight_train_launch")
|
|
|
- Sleep(1200)
|
|
|
+ Sleep(500)
|
|
|
sendJsClickByClass("knight_regimen_confirm")
|
|
|
+
|
|
|
+ $eventTimer = eventStart($repeatTimer)
|
|
|
+ endTask("Train Knight, next event: " & $eventTimer & @CRLF)
|
|
|
+ Return $eventTimer
|
|
|
+EndFunc
|
|
|
+
|
|
|
+Func sendAttack($x, $y, $landzsas, $kardforgato, $bardos, $ijasz, $kem, $konnyulovas, $lovasijasz, $nehezlovas, $kos, $katapult, $lovag, $nemes, $repeatTimer, $eventTimer)
|
|
|
+ If ($landzsas = 0 and $kardforgato = 0 and $bardos = 0 and $ijasz = 0 and $kem = 0 and $konnyulovas = 0 and $lovasijasz = 0 and $nehezlovas = 0 and $kos = 0 and $katapult = 0 and $lovag = 0 and $nemes = 0) Then Return $eventTimer
|
|
|
+ If (Not eventTriggered($sendAttackEventTimer)) Then Return $eventTimer
|
|
|
+ If ($x = null or $y = null) Then Return $eventTimer
|
|
|
+ TraytipGG("Send Attack started!" & @CRLF)
|
|
|
+ openNewTab()
|
|
|
+ navigateUrl(getGameUrl("place"), false)
|
|
|
Sleep($pageLoadTime)
|
|
|
- $trainKnightEventTimer = eventStart($trainKnightRepeatTimer)
|
|
|
- closeTab()
|
|
|
- TraytipGG("Train Knight, next event: " & $trainKnightEventTimer & @CRLF)
|
|
|
- ConsoleWrite(@CRLF)
|
|
|
- Sleep($sleepTimesInEndOfTasks)
|
|
|
+ sendUnits($landzsas, $kardforgato, $bardos, $ijasz)
|
|
|
+ sendLovassag($kem, $konnyulovas, $lovasijasz, $nehezlovas)
|
|
|
+ sendMachines($kos, $katapult)
|
|
|
+ sendRoyalties($lovag, $nemes)
|
|
|
+ jsExecutor("document.getElementsByClassName('target-input-field')[0].value = '" & $x & "|" & $y & "'")
|
|
|
+ sendJsClickById("target_attack")
|
|
|
+ Sleep(1000)
|
|
|
+ sendJsClickById("troop_confirm_submit")
|
|
|
+
|
|
|
+
|
|
|
+ $eventTimer = eventStart($repeatTimer)
|
|
|
+ endTask("Send Attack done, next event: " & $eventTimer)
|
|
|
+ Return $eventTimer
|
|
|
+EndFunc
|
|
|
+
|
|
|
+Func sendUnits($landzsas, $kardforgato, $bardos, $ijasz)
|
|
|
+ If ($landzsas > 0) Then jsExecutor("{$}('input[name=spear]').val('" & $landzsas & "').trigger('keyup');")
|
|
|
+ If ($kardforgato > 0) Then jsExecutor("{$}('input[name=sword]').val('" & $kardforgato & "').trigger('keyup');")
|
|
|
+ If ($bardos > 0) Then jsExecutor("{$}('input[name=axe]').val('" & $bardos & "').trigger('keyup');")
|
|
|
+ If ($ijasz > 0) Then jsExecutor("{$}('input[name=archer]').val('" & $ijasz & "').trigger('keyup');")
|
|
|
+ If ($landzsas < 0) Then jsExecutor("document.getElementsByName('spear')[0].parentElement.lastElementChild.click();")
|
|
|
+ If ($kardforgato < 0) Then jsExecutor("document.getElementsByName('sword')[0].parentElement.lastElementChild.click();")
|
|
|
+ If ($bardos < 0) Then jsExecutor("document.getElementsByName('axe')[0].parentElement.lastElementChild.click();")
|
|
|
+ If ($ijasz < 0) Then jsExecutor("document.getElementsByName('archer')[0].parentElement.lastElementChild.click();")
|
|
|
+EndFunc
|
|
|
+
|
|
|
+Func sendLovassag($kem, $konnyulovas, $lovasijasz, $nehezlovas)
|
|
|
+ If ($kem > 0) Then jsExecutor("{$}('input[name=spy]').val('" & $kem & "').trigger('keyup');")
|
|
|
+ If ($konnyulovas > 0) Then jsExecutor("{$}('input[name=light]').val('" & $konnyulovas & "').trigger('keyup');")
|
|
|
+ If ($lovasijasz > 0) Then jsExecutor("{$}('input[name=marcher]').val('" & $lovasijasz & "').trigger('keyup');")
|
|
|
+ If ($nehezlovas > 0) Then jsExecutor("{$}('input[name=heavy]').val('" & $nehezlovas & "').trigger('keyup');")
|
|
|
+ If ($kem < 0) Then jsExecutor("document.getElementsByName('spy')[0].parentElement.lastElementChild.click();")
|
|
|
+ If ($konnyulovas < 0) Then jsExecutor("document.getElementsByName('light')[0].parentElement.lastElementChild.click();")
|
|
|
+ If ($lovasijasz < 0) Then jsExecutor("document.getElementsByName('marcher')[0].parentElement.lastElementChild.click();")
|
|
|
+ If ($nehezlovas < 0) Then jsExecutor("document.getElementsByName('heavy')[0].parentElement.lastElementChild.click();")
|
|
|
+EndFunc
|
|
|
+
|
|
|
+Func sendMachines($kos, $katapult)
|
|
|
+ If ($kos > 0) Then jsExecutor("{$}('input[name=ram]').val('" & $kos & "').trigger('keyup');")
|
|
|
+ If ($katapult > 0) Then jsExecutor("{$}('input[name=catapult]').val('" & $katapult & "').trigger('keyup');")
|
|
|
+ If ($kos < 0) Then jsExecutor("document.getElementsByName('ram')[0].parentElement.lastElementChild.click();")
|
|
|
+ If ($katapult < 0) Then jsExecutor("document.getElementsByName('catapult')[0].parentElement.lastElementChild.click();")
|
|
|
+EndFunc
|
|
|
+
|
|
|
+Func sendRoyalties($lovag, $nemes)
|
|
|
+ If ($lovag > 0) Then jsExecutor("{$}('input[name=knight]').val('" & $lovag & "').trigger('keyup');")
|
|
|
+ If ($nemes > 0) Then jsExecutor("{$}('input[name=snob]').val('" & $nemes & "').trigger('keyup');")
|
|
|
+ If ($lovag < 0) Then jsExecutor("document.getElementsByName('knight')[0].parentElement.lastElementChild.click();")
|
|
|
+ If ($nemes < 0) Then jsExecutor("document.getElementsByName('snob')[0].parentElement.lastElementChild.click();")
|
|
|
EndFunc
|
|
|
#EndRegion
|
|
|
|
|
|
@@ -169,24 +235,23 @@ EndFunc
|
|
|
#Region === Helper Functions
|
|
|
Func openNewTab()
|
|
|
WinActivate($browser)
|
|
|
- Sleep(500)
|
|
|
+ Sleep(100)
|
|
|
Send("^t")
|
|
|
- Sleep(1000)
|
|
|
+ Sleep(100)
|
|
|
EndFunc
|
|
|
|
|
|
Func closeTab()
|
|
|
Send("^w")
|
|
|
- Sleep(1000)
|
|
|
EndFunc
|
|
|
|
|
|
Func getGameUrl($screen, $mode = "")
|
|
|
$url = "https://" & $server & ".klanhaboru.hu/game.php?village=" & $villageId & "&screen=" & $screen
|
|
|
- If (Not $mode == "") Then $url &= "&mode=" & $mode
|
|
|
+ If (Not ($mode = "")) Then $url &= "&mode=" & $mode
|
|
|
return $url
|
|
|
EndFunc
|
|
|
|
|
|
Func sendJsClickById($elementId)
|
|
|
- jsExecutor("document.getElementsById('" & $elementId & "').click();")
|
|
|
+ jsExecutor("document.getElementById('" & $elementId & "').click();")
|
|
|
EndFunc
|
|
|
|
|
|
Func sendJsClickByClass($classId)
|
|
|
@@ -194,53 +259,48 @@ Func sendJsClickByClass($classId)
|
|
|
EndFunc
|
|
|
|
|
|
Func jsExecutor($code)
|
|
|
- TraytipGG($code & @CRLF, 0, false)
|
|
|
navigateUrl("javascript:(function(){{}" & $code & "{}})();")
|
|
|
EndFunc
|
|
|
|
|
|
Func navigateUrl($url, $waitForGame = true)
|
|
|
WinWaitActive($browser)
|
|
|
+ If ($debug == true) Then TraytipGG($url & @CRLF)
|
|
|
If ($waitForGame) Then WinWaitActive($gameTitle)
|
|
|
- ;TraytipGG($url & @CRLF)
|
|
|
- Sleep(300)
|
|
|
Send("^l")
|
|
|
- Sleep(300)
|
|
|
+ Sleep(10)
|
|
|
Send("^a")
|
|
|
- Sleep(100)
|
|
|
- ConsoleWrite($url & @CRLF)
|
|
|
+ Sleep(10)
|
|
|
Send($url)
|
|
|
- Sleep(100)
|
|
|
Send("{ENTER}")
|
|
|
- Sleep(300)
|
|
|
+ WinWaitActive($gameTitle) ; now pageLoadTime can be 0
|
|
|
EndFunc
|
|
|
|
|
|
Func getDataWithJs($jsSelector)
|
|
|
$clipBoardCache = ClipGet()
|
|
|
jsExecutor("window.location = '{#}'{+}" & $jsSelector & ".innerHTML")
|
|
|
- Sleep(300)
|
|
|
Send("^l")
|
|
|
- Sleep(300)
|
|
|
+ Sleep(10)
|
|
|
Send("^a")
|
|
|
- Sleep(100)
|
|
|
+ Sleep(10)
|
|
|
Send("^c")
|
|
|
- Sleep(400)
|
|
|
+ Sleep(100)
|
|
|
$data = ClipGet()
|
|
|
ClipPut($clipBoardCache)
|
|
|
$data = StringSplit( $data, "#")
|
|
|
If ($data[0] < 2) Then
|
|
|
- TraytipGG("getDataWithJs error!" & $data & " Expected array size 2, actual: " & $data[0] & @CRLF, 3)
|
|
|
- Sleep(2000)
|
|
|
+ If ($debug == true) Then TraytipGG("getDataWithJs error!" & $data & " Expected array size 2, actual: " & $data[0] & @CRLF, 3)
|
|
|
+ If ($debug == true) Then Sleep(2000)
|
|
|
return ""
|
|
|
EndIf
|
|
|
- TraytipGG("Data received: " & $data[2] & @CRLF)
|
|
|
+ TraytipGG("Data: " & $data[2] & @CRLF)
|
|
|
return $data[2]
|
|
|
EndFunc
|
|
|
|
|
|
Func parseTimeToSeconds($string)
|
|
|
$parsedString = StringSplit( $string, ":")
|
|
|
If ($parsedString[0] < 3) Then
|
|
|
- TraytipGG("parseTimeToSeconds error! Expected array size 3, actual: " & $parsedString[0] & @CRLF, 3)
|
|
|
- Sleep(2000)
|
|
|
+ If ($debug == true) Then TraytipGG("parseTimeToSeconds error! Expected array size 3, actual: " & $parsedString[0] & @CRLF, 3)
|
|
|
+ If ($debug == true) Then Sleep(2000)
|
|
|
return 0
|
|
|
EndIf
|
|
|
$hours = $parsedString[1]
|
|
|
@@ -250,8 +310,17 @@ Func parseTimeToSeconds($string)
|
|
|
EndFunc
|
|
|
|
|
|
Func TraytipGG($text, $icon = 1, $console = true)
|
|
|
- If ($traytip = true) then ToolTip($text, 150, 75, $gameTitle & " - " & $server & " - " & $villageId, $icon)
|
|
|
- If ($console = true) then ConsoleWrite($text)
|
|
|
+ If ($traytip == true) then ToolTip($text, 150, 75, $gameTitle & " - " & $server & " - " & $villageId, $icon)
|
|
|
+ If ($console == true) then ConsoleWrite($text)
|
|
|
+EndFunc
|
|
|
+
|
|
|
+Func endTask($logText, $icon = 1)
|
|
|
+ TraytipGG($logText & @CRLF, $icon)
|
|
|
+ ConsoleWrite(@CRLF)
|
|
|
+ Sleep($sleepTimesInEndOfTasks)
|
|
|
+ closeTab()
|
|
|
+ TrayTipGG("")
|
|
|
+ return true
|
|
|
EndFunc
|
|
|
#EndRegion
|
|
|
|