Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading comps from lolchess.gg #171

Open
wants to merge 173 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
173 commits
Select commit Hold shift + click to select a range
1bb65f3
release
zxcvqwerasdf Dec 9, 2022
41c5350
readme update
zxcvqwerasdf Dec 9, 2022
bdce0db
level up in early rounds
Sizzzles Dec 22, 2022
ffcec2c
Fix misspelled item and augment position update
Sizzzles Dec 22, 2022
755d489
Fixed warnings
Sizzzles Dec 22, 2022
e5f6667
Updated for set 8
Sizzzles Dec 22, 2022
1a4ec7d
Comp importing works again
Sizzzles Dec 22, 2022
4ee841d
Checks items more frequently and added more augments
Sizzzles Jan 19, 2023
f892b27
Added more level ups
Sizzzles Jan 19, 2023
3a8122c
Exits game after victory instead of waiting
Sizzzles Jan 19, 2023
1c77975
Augment reroll and spacing cleanup
Sizzzles Jan 19, 2023
071db41
Clears anvils after PvE rounds
Sizzzles Jan 19, 2023
c3a0b8d
Delay for champion moves and Pillow ver update
Sizzzles Jan 19, 2023
7c7ca27
Update screen_coords.py
Sizzzles Jan 20, 2023
1870925
updated screen_coords.py
Sizzzles Jan 20, 2023
a5560eb
Updated item pickup for units put on far right
Sizzzles Jan 20, 2023
a66195f
Victory continue button actually works now
Sizzzles Jan 20, 2023
c95e5cc
Added victory exit fuction, Should work now
Sizzzles Jan 21, 2023
2200c4d
Faster accept on queues, should pickup all orbs
Sizzzles Jan 22, 2023
71fa34d
Actually selects augments from list
Sizzzles Jan 22, 2023
99799fc
Update arena.py
Sizzzles Jan 22, 2023
48cc318
Update screen_coords.py
Sizzzles Jan 22, 2023
262fa5e
Changed league path back to default
Sizzzles Feb 7, 2023
a0f01f9
Fixed Augments not being picked at 2-1
Sizzzles Feb 7, 2023
63996c9
Updated coords for comps such as underground
Sizzzles Feb 8, 2023
8f662b3
Item placement now happens after anvil rounds
Sizzzles Feb 8, 2023
774b60b
Update README.md
Sizzzles Feb 8, 2023
33581e3
Code Cleanup
Sizzzles Feb 26, 2023
7a77cd7
Fixed Auto Comps
Sizzzles Feb 26, 2023
6ff2e19
auto comps rewrite || New requirements
Sizzzles Mar 2, 2023
7189c85
Added planned feature
Sizzzles Mar 2, 2023
8916859
Dynamic augments testing
Sizzzles Mar 5, 2023
2d2181e
Dynamic augments testing
Sizzzles Mar 6, 2023
2b1655b
Update README.md
Sizzzles Mar 6, 2023
0f551ba
Dynamic and user defined augments
Sizzzles Mar 6, 2023
71eed17
Dynamic and user defined augments
Sizzzles Mar 6, 2023
3f9f133
Merge branch 'testing' of https://github.com/Sizzzles/TFT-OCR-BOT int…
Sizzzles Mar 6, 2023
cfac2d0
Dynamic and user defined augments
Sizzzles Mar 6, 2023
eeb890e
Delete cached_data directory
Sizzzles Mar 7, 2023
b48114e
removed unneeded default position after carousel
Sizzzles Mar 7, 2023
7751837
Added missing buy champ 3 when bench full
Sizzzles Mar 7, 2023
19ca8ff
Merge branch 'main' of https://github.com/Sizzzles/TFT-OCR-BOT
Sizzzles Mar 7, 2023
c4fd05c
Merge branch 'main' into main
Sizzzles Mar 7, 2023
5d6dc18
Update arena.py
Sizzzles Mar 7, 2023
f77fb84
AttributeError fix
Sizzzles Mar 8, 2023
d561831
refactoring and code clean up
Sizzzles Mar 8, 2023
7de8af8
refactoring and code clean up
Sizzzles Mar 8, 2023
7fe7afc
refactoring and code clean up
Sizzzles Mar 8, 2023
6f17526
refactoring and code clean up
Sizzzles Mar 8, 2023
37a97fc
refactoring and code clean up
Sizzzles Mar 8, 2023
7319e52
refactoring and code clean up
Sizzzles Mar 8, 2023
dffc140
refactoring and code clean up
Sizzzles Mar 8, 2023
3af5156
refactoring and code clean up
Sizzzles Mar 8, 2023
8f683d6
refactoring and code clean up
Sizzzles Mar 8, 2023
59d7b61
refactoring and code clean up
Sizzzles Mar 8, 2023
b43f9c7
refactoring and code clean up
Sizzzles Mar 8, 2023
9a23cec
refactoring and code clean up
Sizzzles Mar 8, 2023
175f02d
Update auto_comps.py
Sizzzles Mar 8, 2023
04fa19e
Update auto_comps.py
Sizzzles Mar 8, 2023
4ebd9fd
Update auto_comps.py
Sizzzles Mar 8, 2023
8883089
Update auto_comps.py
Sizzzles Mar 8, 2023
55aefe0
Update auto_comps.py
Sizzzles Mar 8, 2023
b107b49
Update auto_comps.py
Sizzzles Mar 8, 2023
4423463
Update auto_comps.py
Sizzzles Mar 8, 2023
96cdfdf
Fixed auto comp augments not being added
Sizzzles Mar 10, 2023
7590e52
Comp augments cleanup
Sizzzles Mar 12, 2023
ae67f29
Removed Combat Training duplicate
Sizzzles Mar 12, 2023
9409c83
increased sleep between clicks for move_unknown
Sizzzles Mar 12, 2023
dfb16ce
Set 8.5 update
Sizzzles Mar 25, 2023
a39599f
Fixed early loss.... (Maybe?)
Sizzzles Mar 27, 2023
415bb18
Merge branch 'main' into main
Sizzzles Mar 28, 2023
444255a
updates comps by deleting old versions on launch
Sizzzles Mar 28, 2023
3778447
Delayed auto queue after game
Sizzzles Mar 28, 2023
b862c3f
delayed move_unnkown, wasnt placing some units
Sizzzles Mar 28, 2023
734814d
Merge branch 'main' of https://github.com/Sizzzles/TFT-OCR-BOT
Sizzzles Mar 28, 2023
b870f8d
Merge branch 'main' into main
Sizzzles Mar 28, 2023
876ed9c
Types /ff since button disabled
Sizzzles Mar 28, 2023
c6810f2
Merge branch 'main' of https://github.com/Sizzzles/TFT-OCR-BOT
Sizzzles Mar 28, 2023
aa3aa32
Updated main.py
Sizzzles Mar 28, 2023
a72e375
10 sec queue delay to fix ghost match
Sizzzles Mar 29, 2023
87c6f3e
Bel'Veth fixed
Sizzzles Mar 29, 2023
3c59fa1
Stopped level up spam
Sizzzles Mar 29, 2023
cb554d1
move_known and move_unknown have same delay
Sizzzles Mar 29, 2023
86a333f
Decreased tacticians crown check sleep
Sizzzles Mar 30, 2023
46e64ea
Updated anvil, item placement rounds
Sizzzles Mar 30, 2023
4757139
Pickup items timing reverted, removed select_shop
Sizzzles Mar 30, 2023
d6cd4c3
Update arena.py
Sizzzles Mar 30, 2023
eac1052
Added second round, moved bench cleanup order
Sizzzles Mar 31, 2023
59de466
Removed take all button, adjusted item pick loc
Sizzzles Mar 31, 2023
96fea6f
Merge branch 'main' into main
Sizzzles Mar 31, 2023
672eff6
Second round fix
Sizzzles Mar 31, 2023
03a1dc4
Move champion delay changed
Sizzzles Mar 31, 2023
f0d821f
Item checks after carousels
Sizzzles Mar 31, 2023
c6efde8
Refactorings and optimizations
danparizher Apr 2, 2023
42794e5
Merge branch 'main' into main
Sizzzles Apr 3, 2023
6a77778
Merge pull request #14 from Arborym/main
Sizzzles Apr 3, 2023
6bc86fd
Played with timings to move units
Sizzzles Apr 3, 2023
e04ef26
Comp update confirmation
Sizzzles Apr 3, 2023
5cc8b66
Revert "Comp update confirmation"
Sizzzles Apr 3, 2023
6f488e6
Comp update confirmation
Sizzzles Apr 3, 2023
6a9297a
Update README.md
Sizzzles Apr 3, 2023
7d2006d
Update README.md
Sizzzles Apr 3, 2023
72c94e0
Moved comp update confirmation to main.py
Sizzzles Apr 3, 2023
5631a60
Fixed accidental deletion of auto comps selector
Sizzzles Apr 3, 2023
e3ab141
Possible fix for level up looping
Sizzzles May 13, 2023
d9d0722
Fix for incorrect Nunu name usage in comps
Sizzzles May 13, 2023
32b15c5
Update main.py
Sizzzles May 13, 2023
0a1571e
Item pickup coords update
Sizzzles May 20, 2023
fceebde
Item order fix, added Tacticians Crown for portals
Sizzzles May 20, 2023
e534a1a
Update README.md
Sizzzles May 24, 2023
7f080b6
Working Set 9 Version
Sizzzles Jun 17, 2023
3842c34
Working Set 9 Version
Sizzzles Jun 17, 2023
3a25661
Working Set 9 Version
Sizzzles Jun 17, 2023
0dd1562
Update issue templates
Sizzzles Jun 20, 2023
3aedd9e
Region Augment and Augment Rerolls update
Sizzzles Jun 20, 2023
668c233
Added Portal round, delay for region augment
Sizzzles Jun 20, 2023
0aa452b
Second round starting delay
Sizzzles Jun 21, 2023
af12f19
Improvements for Set 9
Sizzzles Jun 21, 2023
ee8297a
Update README.md
Sizzzles Jul 9, 2023
89d3436
Merge pull request #18 from Sizzzles/Sizzzles-patch-1
Sizzzles Jul 9, 2023
a21f3df
Create Close Stale Issues..yml
Sizzzles Jul 10, 2023
7ae477f
Update Close Stale Issues..yml
Sizzzles Jul 10, 2023
c814ecf
Update Close Stale Issues..yml
Sizzzles Jul 10, 2023
4d6034b
Delete Close Stale Issues..yml
Sizzzles Jul 10, 2023
d32290f
Changes to unit levels, assets, item pickups
Sizzzles Jul 31, 2023
c9ef2ce
Merge branch 'main' of https://github.com/Sizzzles/TFT-OCR-BOT
Sizzzles Jul 31, 2023
3c79c9c
update pylint
Sizzzles Jul 31, 2023
8ce267b
.gitignore update
Sizzzles Jul 31, 2023
b96a80f
Refactors and whitespace removal
Sizzzles Aug 7, 2023
129449c
Small Refactor
danparizher Sep 3, 2023
72c91ee
Merge pull request #22 from Arborym/main
Sizzzles Sep 5, 2023
32d5c97
Improvements
Sizzzles Sep 5, 2023
c01656d
9.5 Update
Sizzzles Sep 17, 2023
e9a6ffc
Update README.md
Sizzzles Sep 18, 2023
f44d3fd
comp builder imports set number now
Sizzzles Sep 18, 2023
b2388a5
Merge branch 'main' of https://github.com/Sizzzles/TFT-OCR-BOT
Sizzzles Sep 18, 2023
43061fc
updated .gitignore
Sizzzles Oct 15, 2023
47d0ed2
Fix - Level added to summon units, TF name fix
Sizzzles Oct 15, 2023
b552812
Match OG bot
Sizzzles Oct 15, 2023
54787fd
Set 10 Update, Code Refactoring
Sizzzles Nov 22, 2023
3776cc8
Use game_assets + lolchess augments
Sizzzles Nov 22, 2023
d639f1f
Fix Akali naming, always picking augments (PvE)
Sizzzles Nov 22, 2023
06a3744
Added headliners, use undefined items and fixes
Sizzzles Dec 27, 2023
e6c817c
Update issue templates
Sizzzles Dec 27, 2023
1e36bd6
Update issue templates
Sizzzles Dec 27, 2023
d40b86b
Fixed comp retrieval, improved logic, readability
Sizzzles Jan 27, 2024
b7b6a03
"removed" debug prints
Sizzzles Jan 27, 2024
be5c6b8
Avoid Augments/Clearer Headliner replacement
Sizzzles Feb 4, 2024
e39262d
Comps load again..... For now
Sizzzles Feb 8, 2024
19ca0be
Improve checking in queue and fix avoid augments
Sizzzles Feb 12, 2024
daddc7e
Added avoid portals and changed some screen_coords
Sizzzles Feb 12, 2024
b542d4d
Fix: Keeping carousel Illaoi if in comp
Sizzzles Feb 13, 2024
a36b205
Update requirements.txt typo
Sizzzles Feb 28, 2024
6d33a14
Tacticians Crown logic improved, added retry to auto_queue
Sizzzles Feb 28, 2024
ed8f46b
Merge branch 'main' of https://github.com/Sizzzles/TFT-OCR-BOT
Sizzzles Feb 28, 2024
257c8c6
Removed Tacticians Crown debug logging
Sizzzles Feb 28, 2024
c317734
Set 11 update (probably broke something)
Sizzzles Mar 21, 2024
abe3156
Fix set 11 update crash (rip headliners)
Sizzzles Mar 21, 2024
72a4ffa
Removed board debugs
Sizzzles Mar 21, 2024
eee34e4
Set 11 update: Augment coords and item names
Sizzzles Mar 21, 2024
71977d4
Fix champ name key errors
Sizzzles Mar 22, 2024
89f02f4
Removed all headliner code, fixed unit names
Sizzzles Mar 23, 2024
52821cd
Encounter rounds and fixed rek'sai name
Sizzzles Mar 23, 2024
681de0a
Forgot to update CRAFTABLE_ITEMS_DICT
Sizzzles Mar 24, 2024
5600418
Forgot space for Lee Sin
Sizzzles Mar 26, 2024
dbd3724
Trying to get dummies to work + fix_bench_state for Xayah Rakan
Sizzzles Mar 26, 2024
03671dd
Update Encounter Rounds + Pick Coords
Sizzzles Apr 10, 2024
b937bf2
Use of champion duplicators and CUSTOM COMPS
Sizzzles Apr 10, 2024
59ae864
Fix duplicator crash and Added trait emblem logic
Sizzzles Apr 12, 2024
d828d49
Trait check for Trait emblem logic
Sizzzles Apr 12, 2024
55fbce9
Item pick coords change
Sizzzles Apr 12, 2024
74bcd6c
Fix Kayle crash in duplicators and improve glove placement on wrong c…
Sizzzles Apr 16, 2024
3f122af
Match og bot
Sizzzles Apr 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,6 @@ ASALocalRun/
.localhistory/
*.pyproj
.vscode
test2222.py
dump_comps.py
cached_data/cached8.json
Sizzzles marked this conversation as resolved.
Show resolved Hide resolved
41 changes: 6 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,9 @@
![main](https://i.imgur.com/roX0N3C.png)
Fork of https://github.com/jfd02/TFT-OCR-BOT (Get the installation instructions, but use the files from this repository)

## NOTES:
- Make sure you don't have any overlays on (Blitz, Mobalytics, etc.).
- League & client must be in English.
- 16:9 resolution borderless windowed is required in League, the game must also be on the main monitor (Use 1920x1080 for best results).
- If the program crashes, create an issue with the error.

## INSTALLATION:
1. Install Python 3.10.6 from https://www.python.org/downloads/windows/
- Note that Python 3.10.6 cannot be used on Windows 7 or earlier.
2. Clone the repository or download it from here https://github.com/jfd02/TFT-OCR-BOT/archive/refs/heads/main.zip
3. Open Command Prompt and change the current directory to the folder where main.py is located
4. Run pip install -r requirements.txt in Command Prompt
5. Install tesseract using the Windows installer available at: https://github.com/UB-Mannheim/tesseract/wiki
- Note the tesseract path from the installation.
- Set the tesseract path in the settings.py file (it may already be correct)
6. Configure settings.py so the league client path is correct
7. Disable all in-game overlays
8. Run the main.py file
- Implemented auto comps loading from lolchess (champion, board pos, items, augments)
- Fixed items adding (emblems, other items)
- Added new items (set 8)
- Various comps selection modes

## FEATURES:
![main](https://i.imgur.com/1bXOmag.png)
- Read the board state (Round / Level / Gold / Shop / Items)
- Keeps track of champions on the board and bench
- Pick a random item/champ from the carousel
- Pickup items from the board after PVE rounds
- Place correct items onto champions
- Plays the user-defined team comp
- Auto queue using the LCU API

## TODO:
- Implement tome of traits logic
- Revamp the gold spending function
- Revamp auto queue to have more safety checks / fail-safes
- Grab the best compositions from TFT website
- Intelligent carousel item selection
- Change item pickup to be based on the coordinates of orbs
![preview](https://user-images.githubusercontent.com/67195196/206607219-ce2f6397-ff3b-4543-87e8-17f8ab61325b.png)
72 changes: 45 additions & 27 deletions arena.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,32 @@
Handles the board / bench state inside of the game and
other variables used by the bot to make decisions
"""

import json
from time import sleep
import game_assets
import mk_functions
import screen_coords
from champion import Champion
import comps
import ocr
import game_functions
import arena_functions

from comps import CompsManager
import comps

class Arena:
"""Arena class that handles game logic such as board and bench state"""

# pylint: disable=too-many-instance-attributes,too-many-public-methods
def __init__(self, message_queue) -> None:
def __init__(self, message_queue, comps_manager : CompsManager) -> None:
self.comps_manager = comps_manager
self.comps_manager.SelectNextComp()
self.message_queue = message_queue
self.board_size = 0
self.bench: list[None] = [None, None, None, None, None, None, None, None, None]
self.board: list = []
self.board_unknown: list = []
self.unknown_slots: list = comps.get_unknown_slots()
self.champs_to_buy: list = comps.champions_to_buy()
self.unknown_slots: list = comps_manager.get_unknown_slots()
self.champs_to_buy: list = comps_manager.champions_to_buy()
self.board_names: list = []
self.items: list = []
self.final_comp = False
Expand All @@ -49,10 +51,10 @@ def bought_champion(self, name: str, slot: int) -> None:
self.bench[slot] = Champion(name=name,
coords=screen_coords.BENCH_LOC[slot].get_coords(
),
build=comps.COMP[name]["items"].copy(),
build=self.comps_manager.CURRENT_COMP()[1][name]["items"].copy(),
slot=slot,
size=game_assets.CHAMPIONS[name]["Board Size"],
final_comp=comps.COMP[name]["final_comp"])
size=self.comps_manager.champions[name]["Board Size"],
final_comp=self.comps_manager.CURRENT_COMP()[1][name]["final_comp"])
mk_functions.move_mouse(screen_coords.DEFAULT_LOC.get_coords())
sleep(0.5)
self.fix_bench_state()
Expand All @@ -72,15 +74,15 @@ def have_champion(self) -> Champion | None:
def move_known(self, champion: Champion) -> None:
"""Moves champion to the board"""
print(f" Moving {champion.name} to board")
destination: tuple = screen_coords.BOARD_LOC[comps.COMP[champion.name]["board_position"]].get_coords()
destination: tuple = screen_coords.BOARD_LOC[self.comps_manager.CURRENT_COMP()[1][champion.name]["board_position"]].get_coords()
mk_functions.left_click(champion.coords)
sleep(0.1)
mk_functions.left_click(destination)
champion.coords = destination
self.board.append(champion)
self.board_names.append(champion.name)
self.bench[champion.index] = None
champion.index = comps.COMP[champion.name]["board_position"]
champion.index = self.comps_manager.CURRENT_COMP()[1][champion.name]["board_position"]
self.board_size += champion.size

def move_unknown(self) -> None:
Expand Down Expand Up @@ -118,17 +120,16 @@ def move_champions(self) -> None:
self.move_unknown()
else:
bought_unknown = False
shop: list = arena_functions.get_shop()
shop: list = arena_functions.get_shop(self.comps_manager)
for champion in shop:
gold: int = arena_functions.get_gold()
valid_champ: bool = (
champion[1] in game_assets.CHAMPIONS and
game_assets.champion_gold_cost(champion[1]) <= gold and
game_assets.champion_board_size(champion[1]) == 1 and
champion[1] in self.comps_manager.champions and
self.comps_manager.champion_gold_cost(champion[1]) <= gold and
self.comps_manager.champion_board_size(champion[1]) == 1 and
champion[1] not in self.champs_to_buy and
champion[1] not in self.board_unknown
)

if valid_champ:
none_slot: int = arena_functions.empty_slot()
mk_functions.left_click(screen_coords.BUY_LOC[champion[0]].get_coords())
Expand Down Expand Up @@ -173,6 +174,7 @@ def clear_anvil(self) -> None:
mk_functions.press_e(screen_coords.BENCH_LOC[index].get_coords())
sleep(1)
mk_functions.left_click(screen_coords.BUY_LOC[2].get_coords())
sleep(0.5)

def place_items(self) -> None:
"""Iterates through items and tries to add them to champion"""
Expand Down Expand Up @@ -204,7 +206,7 @@ def add_item_to_champ(self, item_index: int, champ: Champion) -> None:
item_to_move: None = None
for build_item in champ.build:
build_item_components: list = list(
game_assets.FULL_ITEMS[build_item])
game_assets.FULL_ITEMS.get(build_item, []))
if item in build_item_components:
item_to_move: None = item
build_item_components.remove(item_to_move)
Expand Down Expand Up @@ -295,11 +297,11 @@ def spend_gold(self) -> None:
print(" Purchasing XP")
mk_functions.reroll()
print(" Rerolling shop")
shop: list = arena_functions.get_shop()
shop: list = arena_functions.get_shop(self.comps_manager)
print(f" Shop: {shop}")
for champion in shop:
if (champion[1] in self.champs_to_buy and
arena_functions.get_gold() - game_assets.CHAMPIONS[champion[1]]["Gold"] >= 0
arena_functions.get_gold() - self.comps_manager.champions[champion[1]]["Gold"] >= 0
):
none_slot: int = arena_functions.empty_slot()
if none_slot != -1:
Expand All @@ -308,7 +310,7 @@ def spend_gold(self) -> None:
self.bought_champion(champion[1], none_slot)
self.champs_to_buy.remove(champion[1])
else:
# Try to buy champ 3 when bench is full
"""Try to buy champ 3 when bench is full"""
print(f" Board is full but want {champion[1]}")
mk_functions.left_click(screen_coords.BUY_LOC[champion[0]].get_coords())
game_functions.default_pos()
Expand All @@ -326,20 +328,35 @@ def buy_xp_round(self) -> None:
if arena_functions.get_gold() >= 4:
mk_functions.buy_xp()


def load_aguments(self):
augments = self.comps_manager.CURRENT_COMP()[2]
return augments
Sizzzles marked this conversation as resolved.
Show resolved Hide resolved

def pick_augment(self) -> None:
"""Picks an augment from user defined augment priority list or defaults to first augment"""
"""Picks an augment from comp specific/user defined augment list or defaults to first augment"""
augments: list = []
game_augments = self.load_aguments()
for coords in screen_coords.AUGMENT_POS:
augment: str = ocr.get_text(screenxy=coords.get_coords(), scale=3, psm=7)
augments.append(augment)

for augment in augments:
for potential in comps.AUGMENTS:
if potential in augment:
print(f" Choosing augment {augment}")
mk_functions.left_click(screen_coords.AUGMENT_LOC[augments.index(augment)].get_coords())
return

try:
for potential in game_augments:
"""Picks an augment from comp defined augments"""
if potential in augment:
print(f" Choosing comp defined augment: {augment}")
mk_functions.left_click(screen_coords.AUGMENT_LOC[augments.index(augment)].get_coords())
return
except:
Sizzzles marked this conversation as resolved.
Show resolved Hide resolved
for potential in game_assets.AUGMENTS:
"""Picks an augment from user defined augments"""
if potential in augment:
print(f" Choosing user defined augment: {augment}")
mk_functions.left_click(screen_coords.AUGMENT_LOC[augments.index(augment)].get_coords())
return

if self.augment_roll:
print(" Rolling for augment")
mk_functions.left_click(screen_coords.AUGMENT_ROLL.get_coords())
Expand Down Expand Up @@ -367,6 +384,7 @@ def get_label(self) -> None:
for slot in self.bench
if isinstance(slot, Champion)
]

for slot in self.board:
if isinstance(slot, Champion):
labels.append((f"{slot.name}", slot.coords))
Expand Down
41 changes: 16 additions & 25 deletions arena_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import game_assets
import mk_functions
from vec4 import Vec4

from comps import CompsManager

def get_level() -> int:
"""Returns the level for the tactician"""
Expand Down Expand Up @@ -43,34 +43,29 @@ def get_gold() -> int:
return 0


def valid_champ(champ: str) -> str:
def valid_champ(champ: str, comps : CompsManager) -> str:
"""Matches champion string to a valid champion name string and returns it"""
if champ in game_assets.CHAMPIONS:
if champ in comps.champions:
return champ

return next(
(
champion
for champion in game_assets.CHAMPIONS
if SequenceMatcher(a=champion, b=champ).ratio() >= 0.7
),
"",
)
for champion in comps.champions:
if SequenceMatcher(a=champion, b=champ).ratio() >= 0.7:
return champion
return ""
Sizzzles marked this conversation as resolved.
Show resolved Hide resolved

def get_champ(screen_capture: ImageGrab.Image, name_pos: Vec4, shop_pos: int, shop_array: list) -> str:
def get_champ(screen_capture: ImageGrab.Image, name_pos: Vec4, shop_pos: int, shop_array: list, comps : CompsManager) -> str:
"""Returns a tuple containing the shop position and champion name"""
champ: str = screen_capture.crop(name_pos.get_coords())
champ: str = ocr.get_text_from_image(image=champ, whitelist="")
shop_array.append((shop_pos, valid_champ(champ)))

shop_array.append((shop_pos, valid_champ(champ, comps)))

def get_shop() -> list:
def get_shop(comps : CompsManager) -> list:
"""Returns the list of champions in the shop"""
screen_capture = ImageGrab.grab(bbox=screen_coords.SHOP_POS.get_coords())
shop: list = []
thread_list: list = []
for shop_index, name_pos in enumerate(screen_coords.CHAMP_NAME_POS):
thread = threading.Thread(target=get_champ, args=(screen_capture, name_pos, shop_index, shop))
thread = threading.Thread(target=get_champ, args=(screen_capture, name_pos, shop_index, shop, comps))
thread_list.append(thread)
for thread in thread_list:
thread.start()
Expand Down Expand Up @@ -104,15 +99,10 @@ def bench_occupied_check() -> list:

def valid_item(item: str) -> str | None:
"""Checks if the item passed in arg one is valid"""
return next(
(
valid_item_name
for valid_item_name in game_assets.ITEMS
if valid_item_name in item
or SequenceMatcher(a=valid_item_name, b=item).ratio() >= 0.7
),
None,
)
for valid_item_name in game_assets.ITEMS:
if valid_item_name in item or SequenceMatcher(a=valid_item_name, b=item).ratio() >= 0.7:
return valid_item_name
return None
Sizzzles marked this conversation as resolved.
Show resolved Hide resolved


def get_items() -> list:
Expand All @@ -125,3 +115,4 @@ def get_items() -> list:
item_bench.append(valid_item(item))
mk_functions.move_mouse(screen_coords.DEFAULT_LOC.get_coords())
return item_bench

Loading