diff --git a/.github/actions/setup_env/action.yml b/.github/actions/setup_env/action.yml index 7fed025d..af7dac63 100644 --- a/.github/actions/setup_env/action.yml +++ b/.github/actions/setup_env/action.yml @@ -9,6 +9,7 @@ runs: uses: actions/setup-python@v5 with: python-version: "3.12" + cache: "pip" - name: Install dependencies shell: powershell diff --git a/assets/lang/enUS/sigils.json b/assets/lang/enUS/sigils.json index 5583310f..2667d5dc 100644 --- a/assets/lang/enUS/sigils.json +++ b/assets/lang/enUS/sigils.json @@ -203,7 +203,7 @@ }, "positive": { "": " after attacking an enemy, your thorns are increased by for seconds, up to at max stacks.", - "ancestors_favor": "ancestors favor extra lunar shrines and more glyph experience earned at the end of this dungeon.", + "ancestors_favor": "ancestors favor you earn more experience while within this dungeon", "ancestral_awakening": "ancestral awakening you earn more glyph experience at the end of this dungeon.", "battle_hardened": "battle hardened gain damage reduction for every health you are missing.", "control_impaired_explosions": "control impaired explosions being hit by control impairing effects creates an explosion around you.", diff --git a/assets/lang/enUS/tooltips.json b/assets/lang/enUS/tooltips.json index 6b2e3b2b..d46dc2d2 100644 --- a/assets/lang/enUS/tooltips.json +++ b/assets/lang/enUS/tooltips.json @@ -1,4 +1,3 @@ { - "ItemPower": "item power", - "ItemTier": "tier" + "ItemPower": "item power" } diff --git a/src/__init__.py b/src/__init__.py index 25f0f39a..a24a69f8 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -2,4 +2,4 @@ TP = concurrent.futures.ThreadPoolExecutor() -__version__ = "5.8.3" +__version__ = "5.8.4" diff --git a/src/item/descr/item_type.py b/src/item/descr/item_type.py index 803a537f..e993e9a6 100644 --- a/src/item/descr/item_type.py +++ b/src/item/descr/item_type.py @@ -23,7 +23,7 @@ def read_item_type_and_rarity( if found_rarity: item.rarity = found_rarity - if "sigil" in concatenated_str and Dataloader().tooltips["ItemTier"] in concatenated_str: + if "sigil" in concatenated_str: item.item_type = ItemType.Sigil elif any( substring in concatenated_str.lower() @@ -31,7 +31,9 @@ def read_item_type_and_rarity( "consumable", "grand cache", "reputation cache", + "rune of", "treasure goblin cache", + "tribute of", "whispering key", ] ): @@ -47,9 +49,7 @@ def read_item_type_and_rarity( if item.rarity == ItemRarity.Common: return item, concatenated_str - if item.item_type == ItemType.Sigil: - item.power = _find_sigil_tier(concatenated_str) - else: + if item.item_type != ItemType.Sigil: item = _find_item_power_and_type(item, concatenated_str) if item.item_type is None: masked_red, _ = color_filter(crop_top, COLORS.unusable_red, False) @@ -58,7 +58,9 @@ def read_item_type_and_rarity( item = _find_item_power_and_type(item, concatenated_str) non_magic_or_sigil = item.rarity != ItemRarity.Magic or item.item_type == ItemType.Sigil - power_or_type_bad = (item.power is None and item.item_type not in [ItemType.Elixir, ItemType.TemperManual]) or item.item_type is None + power_or_type_bad = ( + item.power is None and item.item_type not in [ItemType.Elixir, ItemType.Sigil, ItemType.TemperManual] + ) or item.item_type is None if non_magic_or_sigil and power_or_type_bad: return None, concatenated_str @@ -102,19 +104,6 @@ def _find_item_power_and_type(item: Item, concatenated_str: str) -> Item: return item -def _find_sigil_tier(concatenated_str: str) -> int | None: - for error, correction in Dataloader().error_map.items(): - concatenated_str = concatenated_str.replace(error, correction) - if Dataloader().tooltips["ItemTier"] in concatenated_str: - idx = concatenated_str.index(Dataloader().tooltips["ItemTier"]) - split_words = concatenated_str[idx:].split() - if len(split_words) == 2: - following_word = split_words[1] - if following_word.isdigit(): - return int(following_word) - return None - - def _find_item_rarity(concatenated_str: str) -> ItemRarity | None: for rarity in ItemRarity: if rarity.value in concatenated_str: diff --git a/src/tools/data/custom_sigils_enUS.json b/src/tools/data/custom_sigils_enUS.json index 5ac93ad6..fa2c64e1 100644 --- a/src/tools/data/custom_sigils_enUS.json +++ b/src/tools/data/custom_sigils_enUS.json @@ -4,5 +4,8 @@ }, "major": { "the_beast_in_ice": "the beast in ice imprisoned no longer, face the beast in ice in its frozen cave." + }, + "positive": { + "ancestors_favor": "ancestors favor you earn more experience while within this dungeon" } } diff --git a/src/tools/gen_data.py b/src/tools/gen_data.py index f2a9872d..1bc1b87a 100644 --- a/src/tools/gen_data.py +++ b/src/tools/gen_data.py @@ -208,8 +208,6 @@ def main(d4data_dir: Path, companion_app_dir: Path): for arString in data["arStrings"]: if arString["szLabel"] == "ItemPower": tooltip_dict["ItemPower"] = remove_content_in_braces(check_ms(arString["szText"].lower())) - if arString["szLabel"] == "ItemTier": - tooltip_dict["ItemTier"] = remove_content_in_braces(check_ms(arString["szText"].lower())) with open(D4LF_BASE_DIR / f"assets/lang/{language}/tooltips.json", "w", encoding="utf-8") as json_file: json.dump(tooltip_dict, json_file, indent=4, ensure_ascii=False, sort_keys=True) json_file.write("\n") diff --git a/tests/assets/item/season5/1440p_small_sigil_1.png b/tests/assets/item/season5/1440p_small_sigil_1.png deleted file mode 100644 index b675baae..00000000 Binary files a/tests/assets/item/season5/1440p_small_sigil_1.png and /dev/null differ diff --git a/tests/assets/item/season5/1440p_small_sigil_2.png b/tests/assets/item/season5/1440p_small_sigil_2.png deleted file mode 100644 index 78625135..00000000 Binary files a/tests/assets/item/season5/1440p_small_sigil_2.png and /dev/null differ diff --git a/tests/assets/item/season6/1440p_small_compass_1.png b/tests/assets/item/season6/1440p_small_compass_1.png new file mode 100644 index 00000000..1c134654 Binary files /dev/null and b/tests/assets/item/season6/1440p_small_compass_1.png differ diff --git a/tests/assets/item/season6/1440p_small_rune_magic_1.png b/tests/assets/item/season6/1440p_small_rune_magic_1.png new file mode 100644 index 00000000..7dc77910 Binary files /dev/null and b/tests/assets/item/season6/1440p_small_rune_magic_1.png differ diff --git a/tests/assets/item/season6/1440p_small_rune_magic_2.png b/tests/assets/item/season6/1440p_small_rune_magic_2.png new file mode 100644 index 00000000..a851873b Binary files /dev/null and b/tests/assets/item/season6/1440p_small_rune_magic_2.png differ diff --git a/tests/assets/item/season6/1440p_small_rune_rare_1.png b/tests/assets/item/season6/1440p_small_rune_rare_1.png new file mode 100644 index 00000000..2f8ecd8c Binary files /dev/null and b/tests/assets/item/season6/1440p_small_rune_rare_1.png differ diff --git a/tests/assets/item/season6/1440p_small_rune_rare_2.png b/tests/assets/item/season6/1440p_small_rune_rare_2.png new file mode 100644 index 00000000..4b47d54b Binary files /dev/null and b/tests/assets/item/season6/1440p_small_rune_rare_2.png differ diff --git a/tests/assets/item/season6/1440p_small_sigil_1.png b/tests/assets/item/season6/1440p_small_sigil_1.png new file mode 100644 index 00000000..f0afafe6 Binary files /dev/null and b/tests/assets/item/season6/1440p_small_sigil_1.png differ diff --git a/tests/assets/item/season6/1440p_small_sigil_2.png b/tests/assets/item/season6/1440p_small_sigil_2.png new file mode 100644 index 00000000..999332bc Binary files /dev/null and b/tests/assets/item/season6/1440p_small_sigil_2.png differ diff --git a/tests/assets/item/season6/1440p_small_tribute_magic_1.png b/tests/assets/item/season6/1440p_small_tribute_magic_1.png new file mode 100644 index 00000000..051917ac Binary files /dev/null and b/tests/assets/item/season6/1440p_small_tribute_magic_1.png differ diff --git a/tests/item/read_descr_season5_test.py b/tests/item/read_descr_season5_test.py index 3d9f6c1f..176d1e79 100644 --- a/tests/item/read_descr_season5_test.py +++ b/tests/item/read_descr_season5_test.py @@ -377,31 +377,6 @@ ), ] -sigil = [ - ( - (2560, 1440), - f"{BASE_PATH}/1440p_small_sigil_1.png", - Item( - affixes=[Affix(name="quick_killer"), Affix(name="empowered_elites_poison_enchanted")], - inherent=[Affix(name="sanguine_chapel", type=AffixType.inherent)], - item_type=ItemType.Sigil, - power=41, - rarity=ItemRarity.Common, - ), - ), - ( - (2560, 1440), - f"{BASE_PATH}/1440p_small_sigil_2.png", - Item( - affixes=[Affix(name="extra_shrines"), Affix(name="stormbanes_wrath")], - inherent=[Affix(name="buried_halls", type=AffixType.inherent)], - item_type=ItemType.Sigil, - power=23, - rarity=ItemRarity.Common, - ), - ), -] - def _run_test_helper(img_res: tuple[int, int], input_img: str, expected_item: Item): Cam().update_window_pos(0, 0, *img_res) @@ -413,8 +388,3 @@ def _run_test_helper(img_res: tuple[int, int], input_img: str, expected_item: It @pytest.mark.parametrize(("img_res", "input_img", "expected_item"), items) def test_item(img_res: tuple[int, int], input_img: str, expected_item: Item): _run_test_helper(img_res=img_res, input_img=input_img, expected_item=expected_item) - - -@pytest.mark.parametrize(("img_res", "input_img", "expected_item"), sigil) -def test_sigil(img_res: tuple[int, int], input_img: str, expected_item: Item): - _run_test_helper(img_res=img_res, input_img=input_img, expected_item=expected_item) diff --git a/tests/item/read_descr_season6_test.py b/tests/item/read_descr_season6_test.py new file mode 100644 index 00000000..8bdc191a --- /dev/null +++ b/tests/item/read_descr_season6_test.py @@ -0,0 +1,110 @@ +import cv2 +import pytest + +from src.cam import Cam +from src.config import BASE_DIR +from src.item.data.affix import Affix, AffixType +from src.item.data.item_type import ItemType +from src.item.data.rarity import ItemRarity +from src.item.descr.read_descr import read_descr +from src.item.models import Item + +BASE_PATH = BASE_DIR / "tests/assets/item/season6" + +items = [] + +materials = [ + ( + (2560, 1440), + f"{BASE_PATH}/1440p_small_compass_1.png", + Item( + item_type=ItemType.Material, + rarity=ItemRarity.Common, + ), + ), + ( + (2560, 1440), + f"{BASE_PATH}/1440p_small_rune_magic_1.png", + Item( + item_type=ItemType.Material, + rarity=ItemRarity.Magic, + ), + ), + ( + (2560, 1440), + f"{BASE_PATH}/1440p_small_rune_magic_2.png", + Item( + item_type=ItemType.Material, + rarity=ItemRarity.Magic, + ), + ), + ( + (2560, 1440), + f"{BASE_PATH}/1440p_small_rune_rare_1.png", + Item( + item_type=ItemType.Material, + rarity=ItemRarity.Rare, + ), + ), + ( + (2560, 1440), + f"{BASE_PATH}/1440p_small_rune_rare_2.png", + Item( + item_type=ItemType.Material, + rarity=ItemRarity.Rare, + ), + ), + ( + (2560, 1440), + f"{BASE_PATH}/1440p_small_tribute_magic_1.png", + Item( + item_type=ItemType.Material, + rarity=ItemRarity.Magic, + ), + ), +] + +sigils = [ + ( + (2560, 1440), + f"{BASE_PATH}/1440p_small_sigil_1.png", + Item( + affixes=[Affix(name="ancestors_favor"), Affix(name="monster_barrier")], + inherent=[Affix(name="carrion_fields", type=AffixType.inherent)], + item_type=ItemType.Sigil, + rarity=ItemRarity.Common, + ), + ), + ( + (2560, 1440), + f"{BASE_PATH}/1440p_small_sigil_2.png", + Item( + affixes=[Affix(name="ancestors_favor"), Affix(name="monster_barrier")], + inherent=[Affix(name="whispering_pines", type=AffixType.inherent)], + item_type=ItemType.Sigil, + rarity=ItemRarity.Common, + ), + ), +] + + +def _run_test_helper(img_res: tuple[int, int], input_img: str, expected_item: Item): + Cam().update_window_pos(0, 0, *img_res) + img = cv2.imread(input_img) + item = read_descr(expected_item.rarity, img) + assert item == expected_item + + +@pytest.mark.parametrize(("img_res", "input_img", "expected_item"), items) +def test_item(img_res: tuple[int, int], input_img: str, expected_item: Item): + _run_test_helper(img_res=img_res, input_img=input_img, expected_item=expected_item) + + +@pytest.mark.parametrize(("img_res", "input_img", "expected_item"), materials) +def test_materials(img_res: tuple[int, int], input_img: str, expected_item: Item): + _run_test_helper(img_res=img_res, input_img=input_img, expected_item=expected_item) + + +@pytest.mark.parametrize(("img_res", "input_img", "expected_item"), sigils) +def test_sigils(img_res: tuple[int, int], input_img: str, expected_item: Item): + _run_test_helper(img_res=img_res, input_img=input_img, expected_item=expected_item)