Skip to content

Commit

Permalink
Merge pull request #262 from anthony5301/main
Browse files Browse the repository at this point in the history
Ability to specify which traits should buy to be headliner
  • Loading branch information
anthony5301 authored Nov 25, 2023
2 parents e56bf1d + 2a4e52f commit 403ef54
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 80 deletions.
6 changes: 4 additions & 2 deletions arena.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def spend_gold(self, speedy=False) -> None:
min_gold = 100 if speedy else (24 if self.spam_roll else 56)
while first_run or arena_functions.get_gold() >= min_gold:
if not first_run:
if arena_functions.get_level() != 9:
if arena_functions.get_level() != 10:
mk_functions.buy_xp()
print(" Purchasing XP")
mk_functions.reroll()
Expand All @@ -367,7 +367,9 @@ def spend_gold(self, speedy=False) -> None:
self.buy_champion(champion, 1)
elif (
champion[0] == 4
and arena_functions.check_headliner()
and (
arena_functions.check_headliner() & comps.get_headliner_tag(champion[1]) != 0
)
and not self.have_headliner
and comps.COMP[champion[1]]["final_comp"]
and arena_functions.get_gold()
Expand Down
7 changes: 4 additions & 3 deletions arena_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,14 @@ def get_items() -> list:

def check_headliner() -> bool:
"""Check if the last Champion in the store is a headliner"""
for positions in screen_coords.HEADLINER_POS:
result: int = 0
for index, positions in enumerate(screen_coords.HEADLINER_POS):
headliner: str = ocr.get_text(
screenxy=positions.get_coords(),
scale=3,
psm=10,
whitelist=ocr.ROUND_WHITELIST.replace("-", ""),
)
if headliner == "2":
return True
return False
result += 2**index
return result
50 changes: 37 additions & 13 deletions comps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,83 @@
Team composition used by the bot
Comps come from https://tftactics.gg/tierlist/team-comps
Items are in camel case and a-Z
The "headliner" tag represents a trait from bottom to top.
Set to True if you want it in your team.
Only final comp champion will become headliner and need to set the corresponding 'headliner' tag to True.
e.g. Only want "Sentinel" Ekko, set it to "headliner": [True, False, False]
e.g.2 want either "Sentinel" or "True Damage" Ekko, set it to "headliner": [True, False, True]
"""

COMP = {
"MissFortune": {
"board_position": 6,
"items": ["Deathblade","LastWhisper","GuinsoosRageblade"],
"items": ["Deathblade", "LastWhisper", "GuinsoosRageblade"],
"level": 2,
"final_comp": True
"final_comp": True,
"headliner": [False, True, False]
},
"Neeko": {
"board_position": 24,
"items": ["WarmogsArmor","BrambleVest","DragonsClaw"],
"items": ["WarmogsArmor", "BrambleVest", "DragonsClaw"],
"level": 3,
"final_comp": True
"final_comp": True,
"headliner": [False, False, False]
},
"Lucian": {
"board_position": 3,
"items": ["StatikkShiv"],
"level": 2,
"final_comp": True
"final_comp": True,
"headliner": [False, True, False]
},
"Kennen": {
"board_position": 17,
"items": ["Evenshroud"],
"level": 2,
"final_comp": True
"final_comp": True,
"headliner": [False, False, False]
},
"Ekko": {
"board_position": 5,
"items": [],
"level": 2,
"final_comp": True
"final_comp": True,
"headliner": [False, False, False]
},
"Bard": {
"board_position": 0,
"items": [],
"level": 2,
"final_comp": True
"final_comp": True,
"headliner": [False, True, False]
},
"KaiSa": {
"board_position": 1,
"items": [],
"level": 2,
"final_comp": True
"final_comp": True,
"headliner": [False, False, False]
},
"Lillia": {
"board_position": 16,
"items": [],
"level": 2,
"final_comp": True
"final_comp": True,
"headliner": [False, False, False]
},
"KSante": {
"board_position": 25,
"items": [],
"level": 2,
"final_comp": False
"final_comp": False,
"headliner": [False, False, False]
},
"Corki": {
"board_position": 7,
"items": [],
"level": 2,
"final_comp": False
"final_comp": False,
"headliner": [False, False, False]
}
}

Expand All @@ -72,7 +87,7 @@
AUGMENTS: list[str] = [
"That's Jazz Baby!",
"You Have My Bow",
"Blistering Strikes"
"Blistering Strikes",
"Buried Treasures",
"Switching Gears",
"Caretaker's Favor",
Expand Down Expand Up @@ -140,3 +155,12 @@ def get_unknown_slots() -> list:
for _, champion_data in COMP.items():
container.append(champion_data["board_position"])
return [n for n in range(27) if n not in container]


def get_headliner_tag(name: str) -> int:
"""Return what trait of specify champion can become headliner"""
return (
int(COMP[name]["headliner"][0])
+ int(COMP[name]["headliner"][1]) * 2
+ int(COMP[name]["headliner"][2]) * 4
)
6 changes: 5 additions & 1 deletion game.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ def second_round(self) -> None:
"""Move unknown champion to board after first carousel"""
print(f"\n[Second Round] {self.round}")
self.message_queue.put("CLEAR")
self.arena.bench[arena_functions.bench_occupied_check().index(True)] = "?"
while True:
result = arena_functions.bench_occupied_check()
if any(result):
break
self.arena.bench[result.index(True)] = "?"
self.arena.move_unknown()
self.end_round_tasks()

Expand Down
120 changes: 61 additions & 59 deletions game_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,65 +36,67 @@
ITEMS: set[str] = BASIC_ITEM.union(COMBINED_ITEMS).union(SUPPORT_ITEM).union(NON_CRAFTABLE_ITEMS).union(ORNN_ITEMS)

CHAMPIONS: dict[str, dict[str, int]] = {
"Ahri": {"Gold": 4, "Board Size": 1},
"Akali": {"Gold": 4, "Board Size": 1},
"Amumu": {"Gold": 3, "Board Size": 1},
"Annie": {"Gold": 1, "Board Size": 1},
"Aphelios": {"Gold": 2, "Board Size": 1},
"Bard": {"Gold": 2, "Board Size": 1},
"Blitzcrank": {"Gold": 4, "Board Size": 1},
"Caitlyn": {"Gold": 4, "Board Size": 1},
"Corki": {"Gold": 1, "Board Size": 1},
"Ekko": {"Gold": 3, "Board Size": 1},
"Evelynn": {"Gold": 1, "Board Size": 1},
"Ezreal": {"Gold": 4, "Board Size": 1},
"Garen": {"Gold": 2, "Board Size": 1},
"Gnar": {"Gold": 2, "Board Size": 1},
"Gragas": {"Gold": 2, "Board Size": 1},
"Illaoi": {"Gold": 5, "Board Size": 1},
"Jax": {"Gold": 2, "Board Size": 1},
"Jhin": {"Gold": 5, "Board Size": 1},
"Jinx": {"Gold": 1, "Board Size": 1},
"KaiSa": {"Gold": 2, "Board Size": 1},
"Karthus": {"Gold": 4, "Board Size": 1},
"Katarina": {"Gold": 2, "Board Size": 1},
"Kayle": {"Gold": 2, "Board Size": 1},
"Kayn": {"Gold": 5, "Board Size": 1},
"Kennen": {"Gold": 1, "Board Size": 1},
"KSante": {"Gold": 1, "Board Size": 1},
"Lillia": {"Gold": 1, "Board Size": 1},
"Lucian": {"Gold": 5, "Board Size": 1},
"Lulu": {"Gold": 3, "Board Size": 1},
"Lux": {"Gold": 3, "Board Size": 1},
"MissFortune": {"Gold": 3, "Board Size": 1},
"Mordekaiser": {"Gold": 3, "Board Size": 1},
"Nami": {"Gold": 1, "Board Size": 1},
"Neeko": {"Gold": 3, "Board Size": 1},
"Olaf": {"Gold": 1, "Board Size": 1},
"Pantheon": {"Gold": 2, "Board Size": 1},
"Poppy": {"Gold": 4, "Board Size": 1},
"Qiyana": {"Gold": 5, "Board Size": 1},
"Riven": {"Gold": 3, "Board Size": 1},
"Samira": {"Gold": 3, "Board Size": 1},
"Senna": {"Gold": 2, "Board Size": 1},
"Seraphine": {"Gold": 2, "Board Size": 1},
"Sett": {"Gold": 3, "Board Size": 1},
"Sona": {"Gold": 5, "Board Size": 1},
"TahmKench": {"Gold": 1, "Board Size": 1},
"Taric": {"Gold": 1, "Board Size": 1},
"Thresh": {"Gold": 4, "Board Size": 1},
"TwistedFate": {"Gold": 4, "Board Size": 1},
"Twitch": {"Gold": 2, "Board Size": 1},
"Urgot": {"Gold": 3, "Board Size": 1},
"Vex": {"Gold": 3, "Board Size": 1},
"Vi": {"Gold": 1, "Board Size": 1},
"Viego": {"Gold": 4, "Board Size": 1},
"Yasuo": {"Gold": 1, "Board Size": 1},
"Yone": {"Gold": 3, "Board Size": 1},
"Yorick": {"Gold": 5, "Board Size": 1},
"Zac": {"Gold": 4, "Board Size": 1},
"Zed": {"Gold": 4, "Board Size": 1},
"Ziggs": {"Gold": 5, "Board Size": 1}}
"Ahri":{"Gold":4,"BoardSize":1,"Trait1":"Spellweaver","Trait2":"KDA","Trait3":""},
"Akali":{"Gold":4,"BoardSize":1,"Trait1":"Executioner","Trait2":"Breakout","Trait3":"TrueDamage"},
"Amumu":{"Gold":3,"BoardSize":1,"Trait1":"Guardian","Trait2":"Emo","Trait3":""},
"Annie":{"Gold":1,"BoardSize":1,"Trait1":"Spellweaver","Trait2":"Emo","Trait3":""},
"Aphelios":{"Gold":2,"BoardSize":1,"Trait1":"Rapidfire","Trait2":"HEARTSTEEL","Trait3":""},
"Bard":{"Gold":2,"BoardSize":1,"Trait1":"Dazzler","Trait2":"Jazz","Trait3":""},
"Blitzcrank":{"Gold":4,"BoardSize":1,"Trait1":"Sentinel","Trait2":"Disco","Trait3":""},
"Caitlyn":{"Gold":4,"BoardSize":1,"Trait1":"Rapidfire","Trait2":"8bit","Trait3":""},
"Corki":{"Gold":1,"BoardSize":1,"Trait1":"BigShot","Trait2":"8bit","Trait3":""},
"Ekko":{"Gold":3,"BoardSize":1,"Trait1":"Sentinel","Trait2":"Spellweaver","Trait3":"TrueDamage"},
"Evelynn":{"Gold":1,"BoardSize":1,"Trait1":"CrowdDiver","Trait2":"K/DA","Trait3":""},
"Ezreal":{"Gold":4,"BoardSize":1,"Trait1":"BigShot","Trait2":"HEARTSTEEL","Trait3":""},
"Garen":{"Gold":2,"BoardSize":1,"Trait1":"Sentinel","Trait2":"8bit","Trait3":""},
"Gnar":{"Gold":2,"BoardSize":1,"Trait1":"Mosher","Trait2":"Superfan","Trait3":"Pentakill"},
"Gragas":{"Gold":2,"BoardSize":1,"Trait1":"Bruiser","Trait2":"Spellweaver","Trait3":"Disco"},
"Illaoi":{"Gold":5,"BoardSize":1,"Trait1":"Bruiser","Trait2":"ILLBEATS","Trait3":""},
"Jax":{"Gold":2,"BoardSize":1,"Trait1":"Mosher","Trait2":"EDM","Trait3":""},
"Jhin":{"Gold":5,"BoardSize":1,"Trait1":"BigShot","Trait2":"Maestro","Trait3":""},
"Jinx":{"Gold":1,"BoardSize":1,"Trait1":"Rapidfire","Trait2":"Punk","Trait3":""},
"Kai'Sa":{"Gold":2,"BoardSize":1,"Trait1":"BigShot","Trait2":"K/DA","Trait3":""},
"Karthus":{"Gold":4,"BoardSize":1,"Trait1":"Executioner","Trait2":"Pentakill","Trait3":""},
"Katarina":{"Gold":2,"BoardSize":1,"Trait1":"CrowdDiver","Trait2":"Country","Trait3":""},
"Kayle":{"Gold":2,"BoardSize":1,"Trait1":"Edgelord","Trait2":"Pentakill","Trait3":""},
"Kayn":{"Gold":5,"BoardSize":1,"Trait1":"Edgelord","Trait2":"Wildcard","Trait3":"HEARTSTEEL"},
"Kennen":{"Gold":1,"BoardSize":1,"Trait1":"Guardian","Trait2":"Superfan","Trait3":"TrueDamage"},
"K'Sante":{"Gold":1,"BoardSize":1,"Trait1":"Sentinel","Trait2":"HEARTSTEEL","Trait3":""},
"Lillia":{"Gold":1,"BoardSize":1,"Trait1":"Sentinel","Trait2":"Superfan","Trait3":"K/DA"},
"Lucian":{"Gold":5,"BoardSize":1,"Trait1":"Rapidfire","Trait2":"Jazz","Trait3":""},
"Lulu":{"Gold":3,"BoardSize":1,"Trait1":"Spellweaver","Trait2":"Hyperpop","Trait3":""},
"Lux":{"Gold":3,"BoardSize":1,"Trait1":"Dazzler","Trait2":"EDM","Trait3":""},
"MissFortune":{"Gold":3,"BoardSize":1,"Trait1":"BigShot","Trait2":"Jazz","Trait3":""},
"Mordekaiser":{"Gold":3,"BoardSize":1,"Trait1":"Sentinel","Trait2":"Pentakill","Trait3":""},
"Nami":{"Gold":1,"BoardSize":1,"Trait1":"Dazzler","Trait2":"Disco","Trait3":""},
"Neeko":{"Gold":3,"BoardSize":1,"Trait1":"Guardian","Trait2":"Superfan","Trait3":"K/DA"},
"Olaf":{"Gold":1,"BoardSize":1,"Trait1":"Bruiser","Trait2":"Pentakill","Trait3":""},
"Pantheon":{"Gold":2,"BoardSize":1,"Trait1":"Guardian","Trait2":"Punk","Trait3":""},
"Poppy":{"Gold":4,"BoardSize":1,"Trait1":"Mosher","Trait2":"Emo","Trait3":""},
"Qiyana":{"Gold":5,"BoardSize":1,"Trait1":"CrowdDiver","Trait2":"TrueDamage","Trait3":""},
"Riven":{"Gold":3,"BoardSize":1,"Trait1":"Edgelord","Trait2":"8bit","Trait3":""},
"Samira":{"Gold":3,"BoardSize":1,"Trait1":"Executioner","Trait2":"Country","Trait3":""},
"Senna":{"Gold":2,"BoardSize":1,"Trait1":"Rapidfire","Trait2":"TrueDamage","Trait3":""},
"Seraphine":{"Gold":2,"BoardSize":1,"Trait1":"Spellweaver","Trait2":"K/DA","Trait3":""},
"Sett":{"Gold":3,"BoardSize":1,"Trait1":"Mosher","Trait2":"Bruiser","Trait3":"HEARTSTEEL"},
"Sona":{"Gold":5,"BoardSize":1,"Trait1":"Spellweaver","Trait2":"Mixmaster","Trait3":""},
"TahmKench":{"Gold":1,"BoardSize":1,"Trait1":"Bruiser","Trait2":"Country","Trait3":""},
"Taric":{"Gold":1,"BoardSize":1,"Trait1":"Guardian","Trait2":"Disco","Trait3":""},
"Thresh":{"Gold":4,"BoardSize":1,"Trait1":"Guardian","Trait2":"Country","Trait3":""},
"TwistedFate":{"Gold":4,"BoardSize":1,"Trait1":"Dazzler","Trait2":"Disco","Trait3":""},
"Twitch":{"Gold":2,"BoardSize":1,"Trait1":"Executioner","Trait2":"Punk","Trait3":""},
"Urgot":{"Gold":3,"BoardSize":1,"Trait1":"Mosher","Trait2":"Country","Trait3":""},
"Vex":{"Gold":3,"BoardSize":1,"Trait1":"Executioner","Trait2":"Emo","Trait3":""},
"Vi":{"Gold":1,"BoardSize":1,"Trait1":"Mosher","Trait2":"Punk","Trait3":""},
"Viego":{"Gold":4,"BoardSize":1,"Trait1":"Edgelord","Trait2":"Pentakill","Trait3":""},
"Yasuo":{"Gold":1,"BoardSize":1,"Trait1":"Edgelord","Trait2":"TrueDamage","Trait3":""},
"Yone":{"Gold":3,"BoardSize":1,"Trait1":"CrowdDiver","Trait2":"Edgelord","Trait3":"HEARTSTEEL"},
"Yorick":{"Gold":5,"BoardSize":1,"Trait1":"Guardian","Trait2":"Mosher","Trait3":"Pentakill"},
"Zac":{"Gold":4,"BoardSize":1,"Trait1":"Bruiser","Trait2":"EDM","Trait3":""},
"Zed":{"Gold":4,"BoardSize":1,"Trait1":"CrowdDiver","Trait2":"EDM","Trait3":""},
"Ziggs":{"Gold":5,"BoardSize":1,"Trait1":"Dazzler","Trait2":"Hyperpop","Trait3":""}
}


ROUNDS: set[str] = {"1-1", "1-2", "1-3", "1-4",
"2-1", "2-2", "2-3", "2-4", "2-5", "2-6", "2-7",
Expand Down
4 changes: 2 additions & 2 deletions screen_coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@
VICTORY_POS: Vec4 = Vec4(GameWindow(906, 560, 1030, 587))

HEADLINER_POS: list[Vec4] = [
Vec4(GameWindow(1280, 964, 1289, 976)),
Vec4(GameWindow(1280, 1018, 1289, 1030)),
Vec4(GameWindow(1280, 990, 1289, 1002)),
Vec4(GameWindow(1280, 1018, 1289, 1030))
Vec4(GameWindow(1280, 964, 1289, 976))
]

BUY_LOC: list[Vec2] = [
Expand Down

0 comments on commit 403ef54

Please sign in to comment.