mik-ril / Mario

A bot for Travian Kingdoms.
1 stars 0 forks source link

bot stops just before the game loads #1

Closed Gyrolyn closed 1 year ago

Gyrolyn commented 1 year ago

hey i love automating repeated works with code specially if they are on web but i was looking for a place to start and learn more about the web part and so i found this code (i'm also playing travian kingdoms)

everything is installed and bot works for the first part of logging in it uses the password and username correctly and gets passed the welcome page but just before the games loads it returns error and says it can't find the tribe i tried to put higher delay in constants.py but it didn't work any idea how it should be fixed ?

mik-ril commented 1 year ago

Thank you for the feedback. Needless to say, this never occurred to me.

Could you copy/paste here what is it dumped in the terminal? Are you playing on a COM or regional server? The game is already loaded (you see the village) when this error shows up? Do you have already finished the tutorial?

Basically to detect the tribe the bot opens your profile on the gameworld (the button in the upper-right with your username on it) and then reads the tribe, in the HTML code romans, teutons and galus are assigned with a value of 1, 2 and 3, respectively.

When you say "just before the game loads" I'm worried the game takes too long to load, as the tribe is detected after the game is loaded. In particular after the green page with the sword and the percentage of loading. How much time (more or less) does it take for the game to load?

Gyrolyn commented 1 year ago

i was playing on a COM server and the game wasn't loaded while that error happened and i have finished tutorial i tried running it again and see how much time it takes for the game to load and this time the bot actually worked through that it took about 4 seconds to load game (i had a background download last time i tried this and the loading time might have been 2 or 3 more seconds longer)

but again after that it showed another error and didn't do anything else here is the respond the bot showed: C:\Users\Mohammad\Documents\GitHub\Mario>python main.py 12/25/2022 01:39:58 PM Looking for an adventure... 12/25/2022 01:40:01 PM Hero not available for adventure 12/25/2022 01:40:01 PM Training troops in 0... Exception in thread the bigger they are: Traceback (most recent call last): File "C:\Users\Mohammad\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1016, in _bootstrap_inner self.run() File "C:\Users\Mohammad\AppData\Local\Programs\Python\Python310\lib\threading.py", line 953, in run self._target(*self._args, **self._kwargs) File "C:\Users\Mohammad\Documents\GitHub\Mario\src\train_t.py", line 19, in thread_train train_troops(driver, tribe, village, troops) File "C:\Users\Mohammad\Documents\GitHub\Mario\src\train.py", line 65, in train_troops select_and_train(driver, reference, troop) File "C:\Users\Mohammad\Documents\GitHub\Mario\src\train.py", line 13, in select_and_train driver.find_element(By.CSS_SELECTOR, f'img[data="{reference + troop[0]}"]').click() File "C:\Users\Mohammad\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 861, in find_element return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"] File "C:\Users\Mohammad\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 444, in execute self.error_handler.check_response(response) File "C:\Users\Mohammad\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 249, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"img[data="11"]"} (Session info: chrome=108.0.5359.125) Stacktrace: Backtrace: (No symbol) [0x004AF243] (No symbol) [0x00437FD1] (No symbol) [0x0032D04D] (No symbol) [0x0035C0B0] (No symbol) [0x0035C22B] (No symbol) [0x0038E612] (No symbol) [0x003785D4] (No symbol) [0x0038C9EB] (No symbol) [0x00378386] (No symbol) [0x0035163C] (No symbol) [0x0035269D] GetHandleVerifier [0x00749A22+2655074] GetHandleVerifier [0x0073CA24+2601828] GetHandleVerifier [0x00558C0A+619850] GetHandleVerifier [0x00557830+614768] (No symbol) [0x004405FC] (No symbol) [0x00445968] (No symbol) [0x00445A55] (No symbol) [0x0045051B] BaseThreadInitThunk [0x760100F9+25] RtlGetAppContainerNamedObjectPath [0x77CA7BBE+286] RtlGetAppContainerNamedObjectPath [0x77CA7B8E+238]

mik-ril commented 1 year ago

That's nice, basically the game was taking too much time to load respect to the delay parameter.

For this new error, I understand you are a teuton (please confirm) trying to train clubs in the first village. Is your barrak in the right slot? Or have you modified the slot relative to the barrak?

Basically the bot cannot find the club image, my guess is that it's opening the wrong building but you should be able to see what it is opening. Let me know, otherwise I will try to reproduce your error (I didn't actually tested it for teutons but it should be right anyway).

Gyrolyn commented 1 year ago

yes i'm a teuton and sorry no i didn't knew i should do that but now that i fixed that bot is working perfectly :)) so yeah your idea was right and thanks a lot for your help. i might put some time in looking into this code and learn about the packages but yeah it's great for now 👍

mik-ril commented 1 year ago

You're welcome, unfortunately the village slots have a fixed reference, independent of the building you place in a specific slot, however you can find everything in the readme file. Let me know if you find other issues.