MOj0 / LoR-Bot

Bot for Legends of Runeterra
MIT License
27 stars 14 forks source link

Script halts #17

Closed LostZeit closed 1 year ago

LostZeit commented 1 year ago

Bot is fine on selecting a deck but after it select the deck and game starts it just stops here, it was working fine before though.

PS C:\LoR-Bot> python .\LOR_Bot.py
PvP Mode
SELECTING DECK NOW!
SELECTING DECK NOW!
Unknown mana...
Unknown mana...
Unknown mana...
Exception in thread Thread-1 (run):
Traceback (most recent call last):
  File "C:\Python311\Lib\threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "C:\Python311\Lib\threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "C:\LoR-Bot\Bot.py", line 52, in run
    self.game_state, self.cards_on_board, self.deck_type, self.n_games, self.games_won = self.state_machine.get_game_info()
                                                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\LoR-Bot\StateMachine.py", line 78, in get_game_info
    self.game_state = self._get_game_state(self.frames, image)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\LoR-Bot\StateMachine.py", line 151, in _get_game_state
    self._get_deck_type()
  File "C:\LoR-Bot\StateMachine.py", line 204, in _get_deck_type
    self.deck = tuple(self.all_cards[cardCode] for cardCode, num_cards in self.cards_data["CardsInDeck"].items()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\LoR-Bot\StateMachine.py", line 204, in <genexpr>
    self.deck = tuple(self.all_cards[cardCode] for cardCode, num_cards in self.cards_data["CardsInDeck"].items()
                      ~~~~~~~~~~~~~~^^^^^^^^^^
KeyError: '06PZ007'
MOj0 commented 1 year ago

I see, you are getting a KeyError: '06PZ007', which should be fixed. KeyError means there is a card with a key that bot could not recognize ('06PZ007' in this case). This is strange, because I moved all KeyErrors to warnings.

I suggest you to delete the card_sets folder and run the program again, it will download all the card sets again, like it says in the notes section.

If that still does not work, I'm guessing Riot decided to make a bigger change as to how they handle keys and I will have to look at it thoroughly.

LostZeit commented 1 year ago

No luck, same issue after it downloaded the cards.

PS C:\LoR-Bot> remove-item .\card_sets\ -Recurse
PS C:\LoR-Bot> ls

    Directory: C:\LoR-Bot

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----          11/26/2022  5:06 PM                __pycache__
d----          10/14/2022  5:52 PM                gifs
d----          10/14/2022  5:52 PM                mana_values
-a---          10/14/2022  5:52 PM             20 .gitignore
-a---          10/14/2022  5:52 PM           1092 APICaller.py
-a---          10/14/2022  5:52 PM          13542 Bot.py
-a---          10/14/2022  5:52 PM           1167 Card.py
-a---          10/14/2022  5:52 PM         201078 constants.py
-a---          10/14/2022  5:52 PM           1858 download_card_sets.py
-a---          10/14/2022  5:52 PM           6729 Ephemeral.py
-a---          10/14/2022  5:52 PM           2664 Generic.py
-a---          10/14/2022  5:52 PM           1082 LICENSE
-a---          10/14/2022  5:52 PM           4307 LOR_Bot.py
-a---          10/14/2022  5:52 PM           1738 MouseHandler.py
-a---          10/14/2022  5:52 PM           3120 Pirates.py
-a---          10/14/2022  5:52 PM           2938 README.md
-a---          12/14/2022  6:26 PM            123 requirements.txt
-a---          10/14/2022  5:52 PM           9859 StateMachine.py
-a---          10/14/2022  5:52 PM           5119 Strategy.py

PS C:\LoR-Bot> python .\LOR_Bot.py
PvP Mode
SELECTING DECK NOW!
SELECTING DECK NOW!
SELECTING DECK NOW!
Unknown mana...
Exception in thread Thread-1 (run):
Traceback (most recent call last):
  File "C:\Python311\Lib\threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "C:\Python311\Lib\threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "C:\LoR-Bot\Bot.py", line 52, in run
    self.game_state, self.cards_on_board, self.deck_type, self.n_games, self.games_won = self.state_machine.get_game_info()
                                                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\LoR-Bot\StateMachine.py", line 78, in get_game_info
    self.game_state = self._get_game_state(self.frames, image)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\LoR-Bot\StateMachine.py", line 151, in _get_game_state
    self._get_deck_type()
  File "C:\LoR-Bot\StateMachine.py", line 204, in _get_deck_type
    self.deck = tuple(self.all_cards[cardCode] for cardCode, num_cards in self.cards_data["CardsInDeck"].items()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\LoR-Bot\StateMachine.py", line 204, in <genexpr>
    self.deck = tuple(self.all_cards[cardCode] for cardCode, num_cards in self.cards_data["CardsInDeck"].items()
                      ~~~~~~~~~~~~~~^^^^^^^^^^
KeyError: '06PZ007'
MOj0 commented 1 year ago

Ok. After checking the Developer portal I saw there is another card set called https://dd.b.pvp.net/latest/set6cde-en_us.zip which the bot does not download. I suggest downloading it either manually or through code and see if it works.

LostZeit commented 1 year ago

That fixes the issue, looks like it was just missing the set.

MOj0 commented 1 year ago

Fixed here https://github.com/MOj0/LoR-Bot/commit/eacd3f07a69e511f02c4b1e5e4442293e91597d1