diff --git a/worlds/tunic/combat_logic.py b/worlds/tunic/combat_logic.py index a58fc16a5e..00a0c6681b 100644 --- a/worlds/tunic/combat_logic.py +++ b/worlds/tunic/combat_logic.py @@ -1,4 +1,4 @@ -from typing import Dict, List, NamedTuple, Tuple +from typing import Dict, List, NamedTuple, Tuple, Optional from BaseClasses import CollectionState from .rules import has_sword, has_melee @@ -45,12 +45,14 @@ area_data: Dict[str, AreaStats] = { } -def has_combat_reqs(area_name: str, state: CollectionState, player: int) -> bool: - data = area_data[area_name] +def has_combat_reqs(area_name: str, state: CollectionState, player: int, alt_data: Optional[AreaStats] = None) -> bool: + data = alt_data or area_data[area_name] extra_att_needed = 0 extra_def_needed = 0 extra_mp_needed = 0 has_magic = state.has_any({"Magic Wand", "Gun"}, player) + stick_bool = False + sword_bool = False for item in data.equipment: if item == "Stick": if not has_melee(state, player): @@ -60,6 +62,8 @@ def has_combat_reqs(area_name: str, state: CollectionState, player: int) -> bool extra_att_needed -= 16 else: return False + else: + stick_bool = True elif item == "Sword": if not has_sword(state, player): @@ -77,6 +81,9 @@ def has_combat_reqs(area_name: str, state: CollectionState, player: int) -> bool extra_def_needed += 2 else: return False + else: + sword_bool = True + elif item == "Shield": if not state.has("Shield", player): extra_def_needed += 2 @@ -93,7 +100,35 @@ def has_combat_reqs(area_name: str, state: CollectionState, player: int) -> bool modified_stats = AreaStats(data.att_level + extra_att_needed, data.def_level + extra_def_needed, data.potion_level, data.hp_level, data.sp_level, data.mp_level + extra_mp_needed, data.potion_count) if not has_required_stats(modified_stats, state, player): - return False + # we may need to check if you would have the required stats if you were missing a weapon + # if someone has a better way of doing this, please tell me lmao + if sword_bool and "Sword" in data.equipment and "Magic" in data.equipment: + # we need to check if you would have the required stats if you didn't have melee + equip_list = [item for item in data.equipment if item != "Sword"] + more_modified_stats = AreaStats(data.att_level - 16, data.def_level, data.potion_level, + data.hp_level, data.sp_level, data.mp_level + 4, data.potion_count, + equip_list) + if has_combat_reqs("none", state, player, more_modified_stats): + return True + + # and we need to check if you would have the required stats if you didn't have magic + equip_list = [item for item in data.equipment if item != "Magic"] + more_modified_stats = AreaStats(data.att_level + 2, data.def_level + 2, data.potion_level, + data.hp_level, data.sp_level, data.mp_level - 16, data.potion_count, + equip_list) + if has_combat_reqs("none", state, player, more_modified_stats): + return True + + elif stick_bool and "Stick" in data.equipment and "Magic" in data.equipment: + # we need to check if you would have the required stats if you didn't have the stick + equip_list = [item for item in data.equipment if item != "Stick"] + more_modified_stats = AreaStats(data.att_level - 16, data.def_level, data.potion_level, + data.hp_level, data.sp_level, data.mp_level + 4, data.potion_count, + equip_list) + if has_combat_reqs("none", state, player, more_modified_stats): + return True + else: + return False return True