|
|
@@ -0,0 +1,252 @@
|
|
|
+;;Klanhaboru fun
|
|
|
+AutoItSetOption("SendKeyDelay", 3)
|
|
|
+AutoItSetOption("SendKeyDownDelay", 5)
|
|
|
+AutoItSetOption("WinTitleMatchMode", 2)
|
|
|
+Global $gameTitle = "Klánháború"
|
|
|
+Global $pageLoadTime = 1500 ;inMs
|
|
|
+Global $gyujtogetesWaitTime = 1200000 ;20m default fallback value
|
|
|
+
|
|
|
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
+;; User Config
|
|
|
+Global $server = IniRead(@ScriptDir & "/config.ini", "Options", "server", "hu83")
|
|
|
+Global $villageId = IniRead(@ScriptDir & "/config.ini", "Options", "villageId", "4446")
|
|
|
+;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 $scavengeMode = IniRead(@ScriptDir & "/config.ini", "Options", "scavengeMode", "2")
|
|
|
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
+
|
|
|
+WinActivate("chrome")
|
|
|
+WinWaitActive($gameTitle)
|
|
|
+Sleep(1000)
|
|
|
+While 1
|
|
|
+ gyujtogetes(2, -1, -1, -1, -1, -1, -1, -1, -1) ;$mode, $landzsas, $kardforgato, $bardos, $ijasz, $konnyulovas, $lovasijasz, $nehezlovas, $lovag
|
|
|
+ Sleep($gyujtogetesWaitTime)
|
|
|
+ trainUnits(0, 0, 0, 5) ;$landzsas, $kardforgato, $bardos, $ijasz
|
|
|
+ trainLovassag(0, 0, 0, 0) ;$kem, $konnyulovas, $lovasijasz, $nehezlovas
|
|
|
+ ;epites("wall") ;Options: main, barracks, stable, watchtower, smith, place, statue, market, wood, stone, iron, farm, storage, hide, wall
|
|
|
+WEnd
|
|
|
+
|
|
|
+
|
|
|
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
+;; Functions
|
|
|
+func gyujtogetes($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)
|
|
|
+ ConsoleWrite("Gyüjtögetés started!" & @CRLF)
|
|
|
+ if ($landzsas = 0 and $kardforgato = 0 and $bardos = 0 and $ijasz = 0 and $konnyulovas = 0 and $lovasijasz = 0 and $nehezlovas = 0 and $lovag = 0) Then
|
|
|
+ ConsoleWrite("Gyüjtögetés Skip!" & @CRLF)
|
|
|
+ Return False
|
|
|
+ EndIf
|
|
|
+ navigateUrl(getGameUrl("place", "scavenge"))
|
|
|
+ Sleep($pageLoadTime)
|
|
|
+
|
|
|
+ if ($landzsas > 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('spear')[0].value = '" & $landzsas & "';")
|
|
|
+ EndIf
|
|
|
+ if ($kardforgato > 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('sword')[0].value = '" & $kardforgato & "';")
|
|
|
+ EndIf
|
|
|
+ if ($bardos > 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('axe')[0].value = '" & $bardos & "';")
|
|
|
+ EndIf
|
|
|
+ if ($ijasz > 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('archer')[0].value = '" & $ijasz & "';")
|
|
|
+ EndIf
|
|
|
+ if ($konnyulovas > 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('light')[0].value = '" & $konnyulovas & "';")
|
|
|
+ EndIf
|
|
|
+ if ($lovasijasz > 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('marcher')[0].value = '" & $lovasijasz & "';")
|
|
|
+ EndIf
|
|
|
+ if ($nehezlovas > 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('heavy')[0].value = '" & $nehezlovas & "';")
|
|
|
+ EndIf
|
|
|
+ if ($lovag > 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('knight')[0].value = '" & $lovag & "';")
|
|
|
+ EndIf
|
|
|
+
|
|
|
+ if ($landzsas < 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('spear')[0].parentElement.children[1].click();")
|
|
|
+ EndIf
|
|
|
+ if ($kardforgato < 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('sword')[0].parentElement.children[1].click();")
|
|
|
+ EndIf
|
|
|
+ if ($bardos < 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('axe')[0].parentElement.children[1].click();")
|
|
|
+ EndIf
|
|
|
+ if ($ijasz < 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('archer')[0].parentElement.children[1].click();")
|
|
|
+ EndIf
|
|
|
+ if ($konnyulovas < 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('light')[0].parentElement.children[1].click();")
|
|
|
+ EndIf
|
|
|
+ if ($lovasijasz < 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('marcher')[0].parentElement.children[1].click();")
|
|
|
+ EndIf
|
|
|
+ if ($nehezlovas < 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('heavy')[0].parentElement.children[1].click();")
|
|
|
+ EndIf
|
|
|
+ if ($lovag < 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('knight')[0].parentElement.children[1].click();")
|
|
|
+ EndIf
|
|
|
+ ;sendJsClickByClass("fill-all")
|
|
|
+ Sleep(300)
|
|
|
+ jsExecutor("document.getElementsByClassName('scavenge-option')[" & $mode & "].getElementsByClassName('btn-default')[0].click();")
|
|
|
+ Sleep($pageLoadTime)
|
|
|
+ $gyujtogetesWaitTime = parseTimeToMs(getDataWithJs("document.getElementsByClassName('scavenge-option')[" & $mode & "].getElementsByClassName('return-countdown')[0]"))
|
|
|
+ ConsoleWrite("Gyüjtögetés wait time in ms: " & $gyujtogetesWaitTime & @CRLF)
|
|
|
+ ConsoleWrite(@CRLF)
|
|
|
+EndFunc
|
|
|
+
|
|
|
+
|
|
|
+func trainUnits($landzsas, $kardforgato, $bardos, $ijasz)
|
|
|
+ ConsoleWrite("Train Units started!" & @CRLF)
|
|
|
+ if ($landzsas = 0 and $kardforgato = 0 and $bardos = 0 and $ijasz = 0) Then
|
|
|
+ ConsoleWrite("Train Units Skip!" & @CRLF)
|
|
|
+ Return False
|
|
|
+ EndIf
|
|
|
+ navigateUrl(getGameUrl("barracks", ""))
|
|
|
+ Sleep($pageLoadTime)
|
|
|
+ if ($landzsas > 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('spear')[0].value = '" & $landzsas & "';")
|
|
|
+ EndIf
|
|
|
+ if ($kardforgato > 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('sword')[0].value = '" & $kardforgato & "';")
|
|
|
+ EndIf
|
|
|
+ if ($bardos > 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('axe')[0].value = '" & $bardos & "';")
|
|
|
+ EndIf
|
|
|
+ if ($ijasz > 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('archer')[0].value = '" & $ijasz & "';")
|
|
|
+ EndIf
|
|
|
+
|
|
|
+ if ($landzsas < 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('spear')[0].parentElement.children[1].click();")
|
|
|
+ EndIf
|
|
|
+ if ($kardforgato < 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('sword')[0].parentElement.children[1].click();")
|
|
|
+ EndIf
|
|
|
+ if ($bardos < 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('axe')[0].parentElement.children[1].click();")
|
|
|
+ EndIf
|
|
|
+ if ($ijasz < 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('archer')[0].parentElement.children[1].click();")
|
|
|
+ EndIf
|
|
|
+ sendJsClickByClass("btn-recruit")
|
|
|
+ ConsoleWrite(@CRLF)
|
|
|
+ Sleep($pageLoadTime)
|
|
|
+EndFunc
|
|
|
+
|
|
|
+
|
|
|
+func trainLovassag($kem, $konnyulovas, $lovasijasz, $nehezlovas)
|
|
|
+ ConsoleWrite("Train Lovassag started!" & @CRLF)
|
|
|
+ if ($kem = 0 and $konnyulovas = 0 and $lovasijasz = 0 and $nehezlovas = 0) Then
|
|
|
+ ConsoleWrite("Train Lovassag Skip!" & @CRLF)
|
|
|
+ Return False
|
|
|
+ EndIf
|
|
|
+ navigateUrl(getGameUrl("stable", ""))
|
|
|
+ Sleep($pageLoadTime)
|
|
|
+ if ($kem > 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('spy')[0].value = '" & $kem & "';")
|
|
|
+ EndIf
|
|
|
+ if ($konnyulovas > 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('light')[0].value = '" & $konnyulovas & "';")
|
|
|
+ EndIf
|
|
|
+ if ($lovasijasz > 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('marcher')[0].value = '" & $lovasijasz & "';")
|
|
|
+ EndIf
|
|
|
+ if ($nehezlovas > 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('heavy')[0].value = '" & $nehezlovas & "';")
|
|
|
+ EndIf
|
|
|
+
|
|
|
+ if ($kem < 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('spy')[0].parentElement.children[1].click();")
|
|
|
+ EndIf
|
|
|
+ if ($konnyulovas < 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('light')[0].parentElement.children[1].click();")
|
|
|
+ EndIf
|
|
|
+ if ($lovasijasz < 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('marcher')[0].parentElement.children[1].click();")
|
|
|
+ EndIf
|
|
|
+ if ($nehezlovas < 0) Then
|
|
|
+ jsExecutor("document.getElementsByName('heavy')[0].parentElement.children[1].click();")
|
|
|
+ EndIf
|
|
|
+ sendJsClickByClass("btn-recruit")
|
|
|
+ ConsoleWrite(@CRLF)
|
|
|
+ Sleep($pageLoadTime)
|
|
|
+EndFunc
|
|
|
+
|
|
|
+func epites($buildingId) ;Options: main, barracks, stable, watchtower, smith, place, statue, market, wood, stone, iron, farm, storage, hide, wall
|
|
|
+ ConsoleWrite("Epites started: " & $buildingId & @CRLF)
|
|
|
+ navigateUrl(getGameUrl("main", ""))
|
|
|
+ Sleep($pageLoadTime)
|
|
|
+ jsExecutor("document.querySelector('{#}main_buildrow_" & $buildingId & "').querySelector('a.btn-build').click();")
|
|
|
+ Sleep($pageLoadTime)
|
|
|
+ ConsoleWrite(@CRLF)
|
|
|
+EndFunc
|
|
|
+
|
|
|
+
|
|
|
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
+;; Helper Functions
|
|
|
+func parseTimeToMs($string)
|
|
|
+ $parsedString = StringSplit( $string, ":")
|
|
|
+ if ($parsedString[0] < 3) Then
|
|
|
+ ConsoleWrite("parseTimeToMs error! Expected array size 3, actual: " & $parsedString[0] & @CRLF)
|
|
|
+ return 0
|
|
|
+ EndIf
|
|
|
+ $hours = $parsedString[1]
|
|
|
+ $minutes = $parsedString[2]
|
|
|
+ $seconds = $parsedString[3]
|
|
|
+ return (($hours*3600+$minutes*60+$seconds)*1000)
|
|
|
+EndFunc
|
|
|
+
|
|
|
+
|
|
|
+func getDataWithJs($jsSelector)
|
|
|
+ $clipBoardCache = ClipGet()
|
|
|
+ jsExecutor("window.location = '{#}'{+}" & $jsSelector & ".innerHTML")
|
|
|
+ Sleep(300)
|
|
|
+ Send("^l")
|
|
|
+ Sleep(300)
|
|
|
+ Send("^a")
|
|
|
+ Sleep(300)
|
|
|
+ Send("^c")
|
|
|
+ $data = ClipGet()
|
|
|
+ ClipPut($clipBoardCache)
|
|
|
+ $data = StringSplit( $data, "#")
|
|
|
+ if ($data[0] < 2) Then
|
|
|
+ ConsoleWrite("getDataWithJs error! Expected array size 2, actual: " & $data[0] & @CRLF)
|
|
|
+ return ""
|
|
|
+ EndIf
|
|
|
+ ConsoleWrite("Data received: " & $data[2] & @CRLF)
|
|
|
+ return $data[2]
|
|
|
+EndFunc
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func getGameUrl($screen, $mode)
|
|
|
+ return "https://" & $server & ".klanhaboru.hu/game.php?village=" & $villageId & "&screen=" & $screen & "&mode=" & $mode
|
|
|
+EndFunc
|
|
|
+
|
|
|
+func sendJsClickById($elementId)
|
|
|
+ jsExecutor("document.getElementsById('" & $elementId & "').click();")
|
|
|
+EndFunc
|
|
|
+
|
|
|
+func sendJsClickByClass($classId)
|
|
|
+ jsExecutor("document.getElementsByClassName('" & $classId & "')[0].click();")
|
|
|
+EndFunc
|
|
|
+
|
|
|
+func jsExecutor($code)
|
|
|
+ $code = "javascript:(function(){{}" & $code & "{}})();"
|
|
|
+ navigateUrl($code)
|
|
|
+EndFunc
|
|
|
+
|
|
|
+func navigateUrl($url)
|
|
|
+ WinWaitActive($gameTitle)
|
|
|
+ ConsoleWrite($url & @CRLF)
|
|
|
+ Sleep(300)
|
|
|
+ Send("^l")
|
|
|
+ Sleep(300)
|
|
|
+ Send("^a")
|
|
|
+ Sleep(300)
|
|
|
+ Send($url)
|
|
|
+ Sleep(300)
|
|
|
+ Send("{ENTER}")
|
|
|
+ Sleep(300)
|
|
|
+EndFunc
|