何か問題が発生することなく、これをすべて正しくループする方法がわかりません。
8000hp を下回ると、コンソールに「プロセスは終了コード 0 で終了しました」と表示されます。
基本的に、私は無限にループする必要があります>= 8000ヘルスの場合に攻撃+敵レベル+戦闘値の条件が満たされていることを確認します(敵レベル<= 1およびBV <= 51)
敵のレベルまたはBVが>=の場合、「再検索」する必要があります
ヘルス <=8000 の場合、再び戦うのに十分になるまでスリープする必要があります
自分でテストするためのテスト アカウントを次に示します。
ユーザー: testaccount123 パス: python123 ゲーム: https://s9-en.bitefight.gameforge.com/user/login
from selenium import webdriver
import time
import re
driver = webdriver.Chrome("C:\\Users\\JC
WIN10\\PycharmProjects\\BitefightPvpBOT\\drivers\\chromedriver.exe")
driver.set_page_load_timeout(10)
driver.get("https://s9-en.bitefight.gameforge.com/user/login") # SERVER
LOGIN PAGE
driver.find_element_by_name("user").send_keys("testaccount123") # USERNAME
time.sleep(1)
driver.find_element_by_name("pass").send_keys("python123") # PASSWORD
time.sleep(1)
driver.find_element_by_class_name("btn-small").click() # LOGIN BUTTON
time.sleep(1)
driver.get("https://s9-en.bitefight.gameforge.com/robbery/index") # HUNT PAGE
time.sleep(1)
driver.find_element_by_name("optionsearch").click() # Werewolf Hunt
time.sleep(2)
enemyLevel = int(driver.find_element_by_xpath('//td[.="Level:"]/following-
sibling::td').text)
BV = int(driver.find_element_by_xpath('//td[.="Battle value:"]/following-
sibling::td').text)
elem = driver.find_element_by_xpath('//div[@class="gold"]')
HP = re.search(r'(\d+\.\d+)\s+/', elem.text).group(1)
HP = int(HP.replace('.', ''))
while enemyLevel <= 1 and BV <= 51 and HP >= 8000:
driver.find_element_by_xpath("//form/div/div/button").click() #Attack
time.sleep(2)
BattleReport = driver.find_element_by_id("reportResult") # BATTLE REPORT
print(BattleReport.text) # OUTPUTS BATTLE REPORT
time.sleep(2)
print("------ ------")
driver.get("https://s9-en.bitefight.gameforge.com/robbery/index")
driver.find_element_by_name("optionsearch").click() # Werewolf Hunt
time.sleep(2)
else:
driver.find_element_by_name("optionsearch").click()
print("Finding new victim")
お分かりのように、私はループがかなり苦手です。どうすればこれに最もよく取り組むことができますか?while ループを試してみましたが、何かが欠けていない限り、正しく動作させることができませんでした。
よろしくお願いいたします