forked from zxcvqwerasdf/TFT-OCR-BOT
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchampion.py
61 lines (52 loc) · 2.15 KB
/
champion.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""
Contains all information related to an individual board slot used by the bot
"""
class Champion:
"""Champion class that contains information about a single unit on the board or bench"""
# pylint: disable=too-many-instance-attributes,too-few-public-methods,too-many-arguments
def __init__(
self,
name: str,
coords: tuple,
build,
slot: int,
size: int,
final_comp: bool,
trait1: str,
trait2: str,
trait3: str
) -> None:
self.name: str = name
self.coords: tuple = coords
self.build = build
self.index: int = slot
self.size: int = size
self.completed_items: list = []
self.current_building: list = []
self.max_item_slots: int = 3
self.final_comp: bool = final_comp
self.traits = [trait1, trait2, trait3]
def __str__(self) -> str:
return (
f"Champion(name={self.name}, coords={self.coords}, "
f"build={self.build}, index={self.index}, size={self.size}, "
f"completed_items={self.completed_items}, "
f"current_building={self.current_building}, final_comp={self.final_comp}, "
f"traits={self.traits}"
)
def does_need_items(self) -> bool:
"""Returns True if the champion instance needs items, False otherwise"""
if len(self.completed_items) == 3 and len(self.current_building) == 0:
return False # No need for more items if already 3 completed items and no ongoing builds
# Allow adding more items if there's less than 3 completed items, or there's an ongoing build
return True
def has_available_item_slots(self):
"""Check if the champion has available item slots."""
max_item_slots = 3
return len(self.completed_items) < max_item_slots
def check_trait(self, item: str) -> bool:
"""Check if the champion has a specific trait based on the item passed."""
# Remove "Emblem" from the item name
trait_to_check = item.replace("Emblem", "")
# Check if the trait exists in the champion's traits
return trait_to_check in self.traits