chestercs 2 年之前
父節點
當前提交
14988926c8
共有 1 個文件被更改,包括 44 次插入105 次删除
  1. 44 105
      klanhaboru_main.au3

+ 44 - 105
klanhaboru_main.au3

@@ -1,6 +1,7 @@
 ;;Klanhaboru fun
-AutoItSetOption("SendKeyDelay", 3)
-AutoItSetOption("SendKeyDownDelay", 5)
+;; https://git.petyuspolisz.com/chestercs/klanhaboru/src/master/klanhaboru_main.au3
+AutoItSetOption("SendKeyDelay", 1)
+AutoItSetOption("SendKeyDownDelay", 0)
 AutoItSetOption("WinTitleMatchMode", 2)
 Global $gameTitle = "Klánháború"
 Global $pageLoadTime = 1500 ;inMs
@@ -14,13 +15,12 @@ Global $villageId = 		IniRead(@ScriptDir & "/config.ini", "Options", "villageId"
 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
+   gyujtogetes(true, 2, 0, 0, 0, 0, 0, 0, 0, 0) ;$mode, $landzsas, $kardforgato, $bardos, $ijasz, $konnyulovas, $lovasijasz, $nehezlovas, $lovag
    Sleep($gyujtogetesWaitTime)
-   trainUnits(0, 0, 0, 5) ;$landzsas, $kardforgato, $bardos, $ijasz
+   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
 WEnd
@@ -28,7 +28,7 @@ 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)
+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)
    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)
@@ -37,56 +37,27 @@ func gyujtogetes($mode, $landzsas, $kardforgato, $bardos, $ijasz, $konnyulovas,
    navigateUrl(getGameUrl("place", "scavenge"))
    Sleep($pageLoadTime)
 
-   if ($landzsas > 0) Then
-	  jsExecutor("document.getElementsByName('spear')[0].value = '" & $landzsas & "';")
+   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();")
    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)
@@ -104,31 +75,15 @@ func trainUnits($landzsas, $kardforgato, $bardos, $ijasz)
    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
+   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")
    ConsoleWrite(@CRLF)
    Sleep($pageLoadTime)
@@ -143,31 +98,15 @@ func trainLovassag($kem, $konnyulovas, $lovasijasz, $nehezlovas)
    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
+   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")
    ConsoleWrite(@CRLF)
    Sleep($pageLoadTime)