Skip to content

Commit

Permalink
handle camelCase and single rupee
Browse files Browse the repository at this point in the history
  • Loading branch information
threeandthreee committed Sep 2, 2024
1 parent 3865507 commit 41b256d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 94 deletions.
91 changes: 1 addition & 90 deletions worlds/ladx/ItemIconGuessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
# RUPEES_20
'COIN': 'RUPEES_20',
'MONEY': 'RUPEES_20',
'RUPEE': 'RUPEES_20',

# RUPEES_50

Expand Down Expand Up @@ -352,8 +353,6 @@
'PIECE OF HEART': 'HEART_PIECE',

# Final Fantasy 1
'AEGISSHIELD': 'SHIELD',
'DRAGONARMOR': 'BLUE_TUNIC',
'OXYALE': 'MEDICINE',
'VORPAL': 'SWORD',
'XCALBER': 'SWORD',
Expand All @@ -368,96 +367,8 @@
'COJIRO': 'ROOSTER',

#SMZ3
'ARROWUPGRADE10': 'MAX_ARROWS_UPGRADE',
'ARROWUPGRADE5': 'MAX_ARROWS_UPGRADE',
'BIGKEY': 'NIGHTMARE_KEY',
'BIGKEYDP': 'NIGHTMARE_KEY',
'BIGKEYEP': 'NIGHTMARE_KEY',
'BIGKEYGT': 'NIGHTMARE_KEY',
'BIGKEYIP': 'NIGHTMARE_KEY',
'BIGKEYMM': 'NIGHTMARE_KEY',
'BIGKEYPD': 'NIGHTMARE_KEY',
'BIGKEYSP': 'NIGHTMARE_KEY',
'BIGKEYSW': 'NIGHTMARE_KEY',
'BIGKEYTH': 'NIGHTMARE_KEY',
'BIGKEYTR': 'NIGHTMARE_KEY',
'BIGKEYTT': 'NIGHTMARE_KEY',
'BLUEBOOMERANG': 'BOOMERANG',
'BOMBUPGRADE10': 'MAX_BOMBS_UPGRADE',
'BOMBUPGRADE5': 'MAX_BOMBS_UPGRADE',
'BOTTLEWITHBEE': 'MEDICINE',
'BOTTLEWITHBLUEPOTION': 'MEDICINE',
'BOTTLEWITHFAIRY': 'MEDICINE',
'BOTTLEWITHGOLDBEE': 'MEDICINE',
'BOTTLEWITHGREENPOTION': 'MEDICINE',
'BOTTLEWITHREDPOTION': 'MEDICINE',
'BYRNA': 'MAGIC_ROD',
'COMPASSDP': 'COMPASS',
'COMPASSEP': 'COMPASS',
'COMPASSGT': 'COMPASS',
'COMPASSIP': 'COMPASS',
'COMPASSMM': 'COMPASS',
'COMPASSPD': 'COMPASS',
'COMPASSSP': 'COMPASS',
'COMPASSSW': 'COMPASS',
'COMPASSTH': 'COMPASS',
'COMPASSTR': 'COMPASS',
'COMPASSTT': 'COMPASS',
'ETANK': 'HEART_CONTAINER',
'FIFTYRUPEES': 'RUPEES_50',
'FIREROD': 'MAGIC_ROD',
'FIVERUPEES': 'RUPEES_20',
'HEARTCONTAINER': 'HEART_CONTAINER',
'HEARTCONTAINERREFILL': 'HEART_CONTAINER',
'HEARTPIECE': 'HEART_PIECE',
'HIJUMP': 'FEATHER',
'ICEROD': 'MAGIC_ROD',
'KEYCT': 'KEY',
'KEYDP': 'KEY',
'KEYGT': 'KEY',
'KEYHC': 'KEY',
'KEYIP': 'KEY',
'KEYMM': 'KEY',
'KEYPD': 'KEY',
'KEYSP': 'KEY',
'KEYSW': 'KEY',
'KEYTH': 'KEY',
'KEYTR': 'KEY',
'KEYTT': 'KEY',
'MAPDP': 'MAP',
'MAPEP': 'MAP',
'MAPGT': 'MAP',
'MAPHC': 'MAP',
'MAPIP': 'MAP',
'MAPMM': 'MAP',
'MAPPD': 'MAP',
'MAPSP': 'MAP',
'MAPSW': 'MAP',
'MAPTH': 'MAP',
'MAPTR': 'MAP',
'MAPTT': 'MAP',
'ONEHUNDREDRUPEES': 'RUPEES_100',
'ONERUPEE': 'RUPEES_20',
'POWERBOMB': 'BOMB',
'PROGRESSIVEGLOVE': 'POWER_BRACELET',
'PROGRESSIVESHIELD': 'SHIELD',
'PROGRESSIVESWORD': 'SWORD',
'PROGRESSIVETUNIC': 'RED_TUNIC',
'REDBOOMERANG': 'BOOMERANG',
'SILVERARROWS': 'SINGLE_ARROW',
'SMMAPBRINSTAR': 'MAP',
'SMMAPLOWERNORFAIR': 'MAP',
'SMMAPMARIDIA': 'MAP',
'SMMAPWRECKEDSHIP': 'MAP',
'SOMARIA': 'MAGIC_ROD',
'SPACEJUMP': 'FEATHER',
'SPEEDBOOSTER': 'PEGASUS_BOOTS',
'TENARROWS': 'ARROWS_10',
'THREEBOMBS': 'BOMB',
'THREEHUNDREDRUPEES': 'RUPEES_500',
'TWENTYRUPEES': 'RUPEES_20',
'TWENTYRUPEES2': 'RUPEES_20',
'VARIA': 'RED_TUNIC',

# Sonic Adventure 2 Battle
'CHAOS EMERALD': 'PIECE_OF_POWER',
Expand Down
8 changes: 4 additions & 4 deletions worlds/ladx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pkgutil
import tempfile
import typing
import re

import bsdiff4

Expand Down Expand Up @@ -379,9 +380,6 @@ def guess_icon_for_other_world(self, other):
self.name_cache[item] = item
splits = item.split("_")
self.name_cache["".join(splits)] = item
for word in ['RUPEE', 'RUPEES']:
if word in splits:
self.name_cache["".join(reversed(splits))] = item
for word in item.split("_"):
if word not in ItemIconGuessing.FORBIDDEN and not word.isnumeric():
self.name_cache[word] = item
Expand All @@ -400,7 +398,9 @@ def guess_icon_for_other_world(self, other):
for phrase in ItemIconGuessing.PHRASES.keys():
if phrase in uppered:
return ItemIconGuessing.PHRASES[phrase]
possibles = other.upper().split(" ")
# pattern for breaking down camelCase, also separates out digits
pattern = re.compile(r"(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|(?<=[a-zA-Z])(?=\d)")
possibles = pattern.sub(' ', other).upper().replace('_', ' ').split(" ")
rejoined = "".join(possibles)
if rejoined in self.name_cache:
return self.name_cache[rejoined]
Expand Down

0 comments on commit 41b256d

Please sign in to comment.