Skip to content

Commit

Permalink
Fixed incorrect marking if matched affix is also inherent (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisoro authored Jul 1, 2024
1 parent c5b2941 commit 8a43626
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ feature request or issue reports join the [discord](https://discord.gg/YyzaPhAN6
- Formats like `[ dexterity, 33 ]` are still completely valid. The importer creates affix fields which look
like `{name: dexterity, value: 33}`. These are identical and either format can be used interchangeably. We
recommend starting all new builds through the importer, so examples show the format the importer uses.
- Mouse control isn't possible
- Due to your local windows settings, the tool might not be able to control the mouse. Just run the tool as admin
and it should work. If you don't want to run it as admin, you can disable the mouse control in the params.ini
by setting `vision_mode_only` to `true`.

### Configs

Expand Down
2 changes: 1 addition & 1 deletion src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

TP = concurrent.futures.ThreadPoolExecutor()

__version__ = "5.6.2"
__version__ = "5.6.3"
8 changes: 4 additions & 4 deletions src/item/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
@dataclass
class _MatchedFilter:
profile: str
matched_affixes: list[str] = field(default_factory=list)
matched_affixes: list[Affix] = field(default_factory=list)
did_match_aspect: bool = False


Expand Down Expand Up @@ -108,7 +108,7 @@ def _check_affixes(self, item: Item) -> _FilterResult:
if not matched_inherents:
continue
all_matches = matched_affixes + matched_inherents
LOGGER.info(f"Matched {profile_name}.Affixes.{filter_name}: {all_matches}")
LOGGER.info(f"Matched {profile_name}.Affixes.{filter_name}: {[x.name for x in all_matches]}")
res.keep = True
res.matched.append(_MatchedFilter(f"{profile_name}.{filter_name}", all_matches))
return res
Expand Down Expand Up @@ -195,15 +195,15 @@ def _did_files_change(self) -> bool:
return True
return any(os.path.getmtime(file_path) > self.last_loaded for file_path in self.all_file_pathes)

def _match_affixes_count(self, expected_affixes: list[AffixFilterCountModel], item_affixes: list[Affix]) -> list[str]:
def _match_affixes_count(self, expected_affixes: list[AffixFilterCountModel], item_affixes: list[Affix]) -> list[Affix]:
result = []
for count_group in expected_affixes:
greater_affix_count = 0
group_res = []
for affix in count_group.count:
matched_item_affix = next((a for a in item_affixes if a.name == affix.name), None)
if matched_item_affix is not None and self._match_item_aspect_or_affix(affix, matched_item_affix):
group_res.append(affix.name)
group_res.append(matched_item_affix)
if matched_item_affix.type == AffixType.greater:
greater_affix_count += 1
if count_group.minCount <= len(group_res) <= count_group.maxCount and greater_affix_count >= count_group.minGreaterAffixCount:
Expand Down
7 changes: 2 additions & 5 deletions src/scripts/vision_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from src.config.loader import IniConfigLoader
from src.config.models import HandleRaresType
from src.config.ui import ResManager
from src.item.data.affix import 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
Expand Down Expand Up @@ -264,10 +263,8 @@ def vision_mode():
# Show matched bullets
if item_descr is not None and len(res.matched) > 0:
bullet_width = thick * 3
all_affixes = item_descr.affixes + item_descr.inherent
non_tempered_affixes = [affix for affix in all_affixes if affix.type != AffixType.tempered]
for affix in non_tempered_affixes:
if affix.loc is not None and any(a == affix.name for a in res.matched[0].matched_affixes):
for affix in res.matched[0].matched_affixes:
if affix.loc is not None:
draw_rect(canvas, bullet_width, affix, off, "#23fc5d")

if item_descr.aspect is not None and any(m.did_match_aspect for m in res.matched):
Expand Down

0 comments on commit 8a43626

Please sign in to comment.