|
|
@@ -1,199 +1,222 @@
|
|
|
#include <Date.au3>
|
|
|
-;;Klanhaboru fun
|
|
|
+;; Klanhaboru fun
|
|
|
;; https://git.petyuspolisz.com/chestercs/klanhaboru/src/master/klanhaboru_main.au3
|
|
|
-AutoItSetOption("SendKeyDelay", 0)
|
|
|
-AutoItSetOption("SendKeyDownDelay", 0)
|
|
|
-AutoItSetOption("WinTitleMatchMode", 2)
|
|
|
-
|
|
|
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
-;; User Config
|
|
|
-Global $trainUnitRepeatTimer = 3600 ;in seconds
|
|
|
-Global $trainLovassagRepeatTimer = 3600 ;in seconds
|
|
|
-Global $epitesRepeatTimer = 300 ;in seconds
|
|
|
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
-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")
|
|
|
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
-Global $gameTitle = "Klánháború"
|
|
|
-Global $gyujtogetesEventTimer
|
|
|
-Global $trainUnitsEventTimer = eventStart($trainUnitRepeatTimer)
|
|
|
-Global $trainLovassagEventTimer = eventStart($trainLovassagRepeatTimer)
|
|
|
-Global $epitesEventTimer = eventStart($epitesRepeatTimer)
|
|
|
-Global $pageLoadTime = 1500 ;inMs
|
|
|
-
|
|
|
-
|
|
|
-WinWaitActive($gameTitle)
|
|
|
-Sleep(1000)
|
|
|
+
|
|
|
+#Region === Configurations
|
|
|
+ AutoItSetOption("SendKeyDelay", 1)
|
|
|
+ AutoItSetOption("SendKeyDownDelay", 2)
|
|
|
+ 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 = true
|
|
|
+
|
|
|
+ Global $trainUnitRepeatTimer = 3600 ; in seconds (default: 1h)
|
|
|
+ Global $trainLovassagRepeatTimer = 3600 ; in seconds (default: 1h)
|
|
|
+ Global $epitesRepeatTimer = 600 ; in seconds (default: 10min)
|
|
|
+ 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 $epitesEventTimer = eventStart(0) ; delay task after bot started with seconds (default: 0)
|
|
|
+ Global $pageLoadTime = 1500 ;inMs
|
|
|
+ Global $sleepTimesInEndOfTasks = 2200 ;inMs
|
|
|
+#EndRegion
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
While 1
|
|
|
- gyujtogetes(true, 2, 0, 0, 0, 0, 0, 0, 0, 0) ;$mode, $landzsas, $kardforgato, $bardos, $ijasz, $konnyulovas, $lovasijasz, $nehezlovas, $lovag
|
|
|
- trainUnits(0, 0, 0, 0) ;$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
|
|
|
- Sleep(1000)
|
|
|
+ gyujtogetes(true, 2, 0, 0, 0, 0, 0, 0, 0, 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, 0) ; landzsas, kardforgato, bardos, ijasz (can be -1 what is meant to all unit button)
|
|
|
+ trainLovassag(0, 0, 0, 0) ; kem, konnyulovas, lovasijasz, nehezlovas (can be -1 what is meant to all unit button)
|
|
|
+ ;epites("wall") ; Options: main, barracks, stable, watchtower, smith, place, statue, market, wood, stone, iron, farm, storage, hide, wall
|
|
|
+ TrayTipGG("")
|
|
|
WEnd
|
|
|
|
|
|
|
|
|
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
-;; 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
|
|
|
- ConsoleWrite("Gyüjtögetés started!" & @CRLF)
|
|
|
- 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
|
|
|
- ConsoleWrite("Gyüjtögetés Skip!" & @CRLF)
|
|
|
- Return False
|
|
|
- EndIf
|
|
|
- navigateUrl(getGameUrl("place", "scavenge"))
|
|
|
- Sleep($pageLoadTime)
|
|
|
|
|
|
- if ($sendAll) Then
|
|
|
+#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
|
|
|
+ TraytipGG("Gyüjtögetés started!" & @CRLF)
|
|
|
+ openNewTab()
|
|
|
+ navigateUrl(getGameUrl("place", "scavenge"), false)
|
|
|
+ Sleep($pageLoadTime)
|
|
|
+ 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();")
|
|
|
+ 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();")
|
|
|
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]")))
|
|
|
- ConsoleWrite("Gyüjtögetés done, next event: " & $gyujtogetesEventTimer & @CRLF)
|
|
|
+ closeTab()
|
|
|
+ TraytipGG("Gyüjtögetés done, next event: " & $gyujtogetesEventTimer & @CRLF)
|
|
|
ConsoleWrite(@CRLF)
|
|
|
+ Sleep($sleepTimesInEndOfTasks)
|
|
|
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
|
|
|
- ConsoleWrite("Train Units started!" & @CRLF)
|
|
|
- navigateUrl(getGameUrl("barracks", ""))
|
|
|
+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
|
|
|
+ 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();")
|
|
|
+ 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();")
|
|
|
sendJsClickByClass("btn-recruit")
|
|
|
Sleep($pageLoadTime)
|
|
|
$trainUnitsEventTimer = eventStart($trainUnitRepeatTimer)
|
|
|
- ConsoleWrite("Train Units done, next event: " & $trainUnitsEventTimer & @CRLF)
|
|
|
+ closeTab()
|
|
|
+ TraytipGG("Train Units done, next event: " & $trainUnitsEventTimer & @CRLF)
|
|
|
ConsoleWrite(@CRLF)
|
|
|
+ Sleep($sleepTimesInEndOfTasks)
|
|
|
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
|
|
|
- ConsoleWrite("Train Lovassag started!" & @CRLF)
|
|
|
- navigateUrl(getGameUrl("stable", ""))
|
|
|
+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
|
|
|
+ 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();")
|
|
|
+ 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();")
|
|
|
sendJsClickByClass("btn-recruit")
|
|
|
Sleep($pageLoadTime)
|
|
|
$trainLovassagEventTimer = eventStart($trainLovassagRepeatTimer)
|
|
|
- ConsoleWrite("Train Lovassag done, next event: " & $trainLovassagEventTimer & @CRLF)
|
|
|
+ closeTab()
|
|
|
+ TraytipGG("Train Lovassag done, next event: " & $trainLovassagEventTimer & @CRLF)
|
|
|
ConsoleWrite(@CRLF)
|
|
|
+ Sleep($sleepTimesInEndOfTasks)
|
|
|
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
|
|
|
- ConsoleWrite("Epites started: " & $buildingId & @CRLF)
|
|
|
- navigateUrl(getGameUrl("main", ""))
|
|
|
+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
|
|
|
+ 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)
|
|
|
- ConsoleWrite("Epites done, next event: " & $epitesEventTimer & @CRLF)
|
|
|
+ closeTab()
|
|
|
+ TraytipGG("Epites done, next event: " & $epitesEventTimer & @CRLF)
|
|
|
ConsoleWrite(@CRLF)
|
|
|
+ Sleep($sleepTimesInEndOfTasks)
|
|
|
EndFunc
|
|
|
+#EndRegion
|
|
|
|
|
|
|
|
|
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
-;; Helper Functions
|
|
|
-func getGameUrl($screen, $mode)
|
|
|
+#Region === Helper Functions
|
|
|
+Func openNewTab()
|
|
|
+ WinActivate($browser)
|
|
|
+ Sleep(500)
|
|
|
+ Send("^t")
|
|
|
+ Sleep(1000)
|
|
|
+EndFunc
|
|
|
+
|
|
|
+Func closeTab()
|
|
|
+ Send("^w")
|
|
|
+ Sleep(1000)
|
|
|
+EndFunc
|
|
|
+
|
|
|
+Func getGameUrl($screen, $mode)
|
|
|
return "https://" & $server & ".klanhaboru.hu/game.php?village=" & $villageId & "&screen=" & $screen & "&mode=" & $mode
|
|
|
EndFunc
|
|
|
|
|
|
-func sendJsClickById($elementId)
|
|
|
+Func sendJsClickById($elementId)
|
|
|
jsExecutor("document.getElementsById('" & $elementId & "').click();")
|
|
|
EndFunc
|
|
|
|
|
|
-func sendJsClickByClass($classId)
|
|
|
+Func sendJsClickByClass($classId)
|
|
|
jsExecutor("document.getElementsByClassName('" & $classId & "')[0].click();")
|
|
|
EndFunc
|
|
|
|
|
|
-func jsExecutor($code)
|
|
|
- $code = "javascript:(function(){{}" & $code & "{}})();"
|
|
|
- navigateUrl($code)
|
|
|
+Func jsExecutor($code)
|
|
|
+ TraytipGG($code & @CRLF, 0, false)
|
|
|
+ navigateUrl("javascript:(function(){{}" & $code & "{}})();")
|
|
|
EndFunc
|
|
|
|
|
|
-func navigateUrl($url)
|
|
|
- WinWaitActive($gameTitle)
|
|
|
- ;ConsoleWrite($url & @CRLF)
|
|
|
+Func navigateUrl($url, $waitForGame = true)
|
|
|
+ WinWaitActive($browser)
|
|
|
+ If ($waitForGame) Then WinWaitActive($gameTitle)
|
|
|
+ ;TraytipGG($url & @CRLF)
|
|
|
Sleep(300)
|
|
|
Send("^l")
|
|
|
Sleep(300)
|
|
|
Send("^a")
|
|
|
- Sleep(300)
|
|
|
+ Sleep(100)
|
|
|
Send($url)
|
|
|
- Sleep(300)
|
|
|
+ Sleep(100)
|
|
|
Send("{ENTER}")
|
|
|
Sleep(300)
|
|
|
EndFunc
|
|
|
|
|
|
-func getDataWithJs($jsSelector)
|
|
|
+Func getDataWithJs($jsSelector)
|
|
|
$clipBoardCache = ClipGet()
|
|
|
jsExecutor("window.location = '{#}'{+}" & $jsSelector & ".innerHTML")
|
|
|
Sleep(300)
|
|
|
Send("^l")
|
|
|
Sleep(300)
|
|
|
Send("^a")
|
|
|
- Sleep(300)
|
|
|
+ Sleep(100)
|
|
|
Send("^c")
|
|
|
- Sleep(300)
|
|
|
+ Sleep(400)
|
|
|
$data = ClipGet()
|
|
|
ClipPut($clipBoardCache)
|
|
|
$data = StringSplit( $data, "#")
|
|
|
- if ($data[0] < 2) Then
|
|
|
- ConsoleWrite("getDataWithJs error!" & $data & " Expected array size 2, actual: " & $data[0] & @CRLF)
|
|
|
+ If ($data[0] < 2) Then
|
|
|
+ TraytipGG("getDataWithJs error!" & $data & " Expected array size 2, actual: " & $data[0] & @CRLF, 3)
|
|
|
+ Sleep(2000)
|
|
|
return ""
|
|
|
EndIf
|
|
|
- ConsoleWrite("Data received: " & $data[2] & @CRLF)
|
|
|
+ TraytipGG("Data received: " & $data[2] & @CRLF)
|
|
|
return $data[2]
|
|
|
EndFunc
|
|
|
|
|
|
-func parseTimeToSeconds($string)
|
|
|
+Func parseTimeToSeconds($string)
|
|
|
$parsedString = StringSplit( $string, ":")
|
|
|
- if ($parsedString[0] < 3) Then
|
|
|
- ConsoleWrite("parseTimeToSeconds error! Expected array size 3, actual: " & $parsedString[0] & @CRLF)
|
|
|
+ If ($parsedString[0] < 3) Then
|
|
|
+ TraytipGG("parseTimeToSeconds error! Expected array size 3, actual: " & $parsedString[0] & @CRLF, 3)
|
|
|
+ Sleep(2000)
|
|
|
return 0
|
|
|
EndIf
|
|
|
$hours = $parsedString[1]
|
|
|
@@ -202,60 +225,64 @@ func parseTimeToSeconds($string)
|
|
|
return ($hours*3600+$minutes*60+$seconds)
|
|
|
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)
|
|
|
+EndFunc
|
|
|
+#EndRegion
|
|
|
|
|
|
|
|
|
#Region === EventHandlers
|
|
|
- Func eventStart($secondsToWait = 3, $mode = "s")
|
|
|
- return _DateAdd($mode, $secondsToWait, _NowCalc())
|
|
|
- EndFunc
|
|
|
-
|
|
|
- Func eventCountDown($targetDate, $mode = "s")
|
|
|
- return _DateDiff($mode, _NowCalc(), $targetDate)
|
|
|
- EndFunc
|
|
|
-
|
|
|
- Func eventTimePassed($startDate, $targetDate = _NowCalc(), $mode = "s")
|
|
|
- return _DateDiff($mode, $startDate, $targetDate)
|
|
|
- EndFunc
|
|
|
-
|
|
|
- Func eventTimeCompare($startDate, $targetDate, $mode = "s")
|
|
|
- return _DateDiff($mode, $startDate, $targetDate)
|
|
|
- EndFunc
|
|
|
-
|
|
|
- Func eventTriggered($targetDate, $mode = "s")
|
|
|
- return eventCountDown($targetDate, $mode) <= 0
|
|
|
- EndFunc
|
|
|
-
|
|
|
- Func compareTimeEventFormatted($startTime, $endTime = _NowCalc())
|
|
|
- $seconds = StringFormat("%02i", Mod(eventTimeCompare($startTime, $endTime, "s"), 60))
|
|
|
- $minutes = StringFormat("%02i", Mod(eventTimeCompare($startTime, $endTime, "n"), 60))
|
|
|
- $hours = StringFormat("%01i", eventTimeCompare($startTime, $endTime, "h"))
|
|
|
- if ($hours <> -1 and $minutes <> -1 and $seconds <> -1) then
|
|
|
- return $hours &":" &$minutes &":" &$seconds
|
|
|
- else
|
|
|
- return ""
|
|
|
- EndIf
|
|
|
- EndFunc
|
|
|
-
|
|
|
- Func countdownTimeEventFormatted($endTime)
|
|
|
- $seconds = StringFormat("%02i", Mod(eventCountDown($endTime, "s"), 60))
|
|
|
- $minutes = StringFormat("%02i", Mod(eventCountDown($endTime, "n"), 60))
|
|
|
- $hours = StringFormat("%01i", eventCountDown($endTime, "h"))
|
|
|
- if ($hours <> -1 and $minutes <> -1 and $seconds <> -1) then
|
|
|
- return $hours &":" &$minutes &":" &$seconds
|
|
|
- else
|
|
|
- return ""
|
|
|
- EndIf
|
|
|
- EndFunc
|
|
|
-
|
|
|
- Func passedTimeEventFormatted($startTime, $endTime = _NowCalc())
|
|
|
- $seconds = StringFormat("%02i", Mod(eventTimePassed($startTime, $endTime, "s"), 60))
|
|
|
- $minutes = StringFormat("%02i", Mod(eventTimePassed($startTime, $endTime, "n"), 60))
|
|
|
- $hours = StringFormat("%01i", eventTimePassed($startTime, $endTime, "h"))
|
|
|
- if ($hours <> -1 and $minutes <> -1 and $seconds <> -1) then
|
|
|
- return $hours &":" &$minutes &":" &$seconds
|
|
|
- else
|
|
|
- return ""
|
|
|
- EndIf
|
|
|
- EndFunc
|
|
|
+Func eventStart($secondsToWait = 3, $mode = "s")
|
|
|
+ return _DateAdd($mode, $secondsToWait, _NowCalc())
|
|
|
+EndFunc
|
|
|
+
|
|
|
+Func eventCountDown($targetDate, $mode = "s")
|
|
|
+ return _DateDiff($mode, _NowCalc(), $targetDate)
|
|
|
+EndFunc
|
|
|
+
|
|
|
+Func eventTimePassed($startDate, $targetDate = _NowCalc(), $mode = "s")
|
|
|
+ return _DateDiff($mode, $startDate, $targetDate)
|
|
|
+EndFunc
|
|
|
+
|
|
|
+Func eventTimeCompare($startDate, $targetDate, $mode = "s")
|
|
|
+ return _DateDiff($mode, $startDate, $targetDate)
|
|
|
+EndFunc
|
|
|
+
|
|
|
+Func eventTriggered($targetDate, $mode = "s")
|
|
|
+ return eventCountDown($targetDate, $mode) <= 0
|
|
|
+EndFunc
|
|
|
+
|
|
|
+Func compareTimeEventFormatted($startTime, $endTime = _NowCalc())
|
|
|
+ $seconds = StringFormat("%02i", Mod(eventTimeCompare($startTime, $endTime, "s"), 60))
|
|
|
+ $minutes = StringFormat("%02i", Mod(eventTimeCompare($startTime, $endTime, "n"), 60))
|
|
|
+ $hours = StringFormat("%01i", eventTimeCompare($startTime, $endTime, "h"))
|
|
|
+ If ($hours <> -1 and $minutes <> -1 and $seconds <> -1) then
|
|
|
+ return $hours &":" &$minutes &":" &$seconds
|
|
|
+ Else
|
|
|
+ EndIf
|
|
|
+ return ""
|
|
|
+EndFunc
|
|
|
+
|
|
|
+Func countdownTimeEventFormatted($endTime)
|
|
|
+ $seconds = StringFormat("%02i", Mod(eventCountDown($endTime, "s"), 60))
|
|
|
+ $minutes = StringFormat("%02i", Mod(eventCountDown($endTime, "n"), 60))
|
|
|
+ $hours = StringFormat("%01i", eventCountDown($endTime, "h"))
|
|
|
+ If ($hours <> -1 and $minutes <> -1 and $seconds <> -1) then
|
|
|
+ return $hours &":" &$minutes &":" &$seconds
|
|
|
+ Else
|
|
|
+ return ""
|
|
|
+ EndIf
|
|
|
+EndFunc
|
|
|
+
|
|
|
+Func passedTimeEventFormatted($startTime, $endTime = _NowCalc())
|
|
|
+ $seconds = StringFormat("%02i", Mod(eventTimePassed($startTime, $endTime, "s"), 60))
|
|
|
+ $minutes = StringFormat("%02i", Mod(eventTimePassed($startTime, $endTime, "n"), 60))
|
|
|
+ $hours = StringFormat("%01i", eventTimePassed($startTime, $endTime, "h"))
|
|
|
+ If ($hours <> -1 and $minutes <> -1 and $seconds <> -1) then
|
|
|
+ return $hours &":" &$minutes &":" &$seconds
|
|
|
+ Else
|
|
|
+ return ""
|
|
|
+ EndIf
|
|
|
+EndFunc
|
|
|
#EndRegion
|