Rename has_stick to has_melee, some fixes per Medic's review

This commit is contained in:
Scipio Wright
2024-07-04 08:44:57 -04:00
parent 02e7e6a9a2
commit 48edbdbb8b
3 changed files with 21 additions and 20 deletions

View File

@@ -1,6 +1,6 @@
from typing import Dict, List, NamedTuple, TYPE_CHECKING
from BaseClasses import CollectionState
from .rules import has_sword, has_stick
from .rules import has_sword, has_melee
if TYPE_CHECKING:
from . import TunicWorld
@@ -57,27 +57,28 @@ enemy_encounters: Dict[str, EncounterData] = {
def has_combat_logic(level: int, required_items: List[str], state: CollectionState, player: int) -> bool:
# no stick, no power
if not has_stick(state, player):
if not has_melee(state, player):
return False
# if level required is 0, just return true, you already have stick
if level == 0:
return True
# use the helper for sword
if "Sword" in required_items and not has_sword(state, player):
return False
else:
required_items.remove("Sword")
if "Sword" in required_items:
if not has_sword(state, player):
return False
else:
required_items.remove("Sword")
if required_items and not state.has_all(required_items, player):
return False
power = (get_att_power(state, player) + get_def_power(state, player) + get_potion_power(state, player)
+ get_hp_power(state, player) + get_mp_power(state, player) + get_other_power(state, player))
return True if power >= level else False
return power >= level
def get_att_power(state: CollectionState, player: int) -> int:
# not relevant if you don't have a weapon that benefits from attack
if not has_stick(state, player):
if not has_melee(state, player):
return 0
power = state.count_from_list({"ATT Offering", "Hero Relic - ATT"}, player)
sword_upgrades = state.count("Sword Upgrade", player)

View File

@@ -1,7 +1,7 @@
from typing import Dict, FrozenSet, Tuple, TYPE_CHECKING
from worlds.generic.Rules import set_rule, forbid_item
from .options import IceGrappling, LadderStorage
from .rules import (has_ability, has_sword, has_stick, has_ice_grapple_logic, has_lantern, has_mask, can_ladder_storage,
from .rules import (has_ability, has_sword, has_melee, has_ice_grapple_logic, has_lantern, has_mask, can_ladder_storage,
laurels_zip)
from .er_data import Portal
from .ladder_storage_data import ow_ladder_groups, region_ladders, easy_ls, medium_ls, hard_ls
@@ -452,10 +452,10 @@ def set_er_region_rules(world: "TunicWorld", regions: Dict[str, Region], portal_
regions["Beneath the Well Front"].connect(
connecting_region=regions["Beneath the Well Main"],
rule=lambda state: has_stick(state, player) or state.has(fire_wand, player))
rule=lambda state: has_melee(state, player) or state.has(fire_wand, player))
regions["Beneath the Well Main"].connect(
connecting_region=regions["Beneath the Well Front"],
rule=lambda state: has_stick(state, player) or state.has(fire_wand, player))
rule=lambda state: has_melee(state, player) or state.has(fire_wand, player))
regions["Beneath the Well Main"].connect(
connecting_region=regions["Beneath the Well Back"],
@@ -463,7 +463,7 @@ def set_er_region_rules(world: "TunicWorld", regions: Dict[str, Region], portal_
regions["Beneath the Well Back"].connect(
connecting_region=regions["Beneath the Well Main"],
rule=lambda state: has_ladder("Ladders in Well", state, world)
and (has_stick(state, player) or state.has(fire_wand, player)))
and (has_melee(state, player) or state.has(fire_wand, player)))
regions["Well Boss"].connect(
connecting_region=regions["Dark Tomb Checkpoint"])
@@ -1325,9 +1325,9 @@ def set_er_location_rules(world: "TunicWorld") -> None:
# Events
set_rule(multiworld.get_location("Eastern Bell", player),
lambda state: (has_stick(state, player) or state.has(fire_wand, player)))
lambda state: (has_melee(state, player) or state.has(fire_wand, player)))
set_rule(multiworld.get_location("Western Bell", player),
lambda state: (has_stick(state, player) or state.has(fire_wand, player)))
lambda state: (has_melee(state, player) or state.has(fire_wand, player)))
set_rule(multiworld.get_location("Furnace Fuse", player),
lambda state: has_ability(prayer, state, world))
set_rule(multiworld.get_location("South and West Fortress Exterior Fuses", player),

View File

@@ -49,7 +49,7 @@ def has_ability(ability: str, state: CollectionState, world: "TunicWorld") -> bo
# a check to see if you can whack things in melee at all
def has_stick(state: CollectionState, player: int) -> bool:
def has_melee(state: CollectionState, player: int) -> bool:
return (state.has("Stick", player) or state.has("Sword Upgrade", player, 1)
or state.has("Sword", player))
@@ -79,7 +79,7 @@ def can_ladder_storage(state: CollectionState, world: "TunicWorld") -> bool:
return False
if world.options.ladder_storage_without_items:
return True
return has_stick(state, world.player) or state.has(grapple, world.player)
return has_melee(state, world.player) or state.has(grapple, world.player)
def has_mask(state: CollectionState, world: "TunicWorld") -> bool:
@@ -104,7 +104,7 @@ def set_region_rules(world: "TunicWorld") -> None:
multiworld.get_entrance("Overworld -> Overworld Holy Cross", player).access_rule = \
lambda state: has_ability(holy_cross, state, world)
multiworld.get_entrance("Overworld -> Beneath the Well", player).access_rule = \
lambda state: has_stick(state, player) or state.has(fire_wand, player)
lambda state: has_melee(state, player) or state.has(fire_wand, player)
multiworld.get_entrance("Overworld -> Dark Tomb", player).access_rule = \
lambda state: has_lantern(state, world)
multiworld.get_entrance("Overworld -> West Garden", player).access_rule = \
@@ -237,7 +237,7 @@ def set_location_rules(world: "TunicWorld") -> None:
or (has_lantern(state, world) and (has_sword(state, player) or state.has(fire_wand, player)))
or has_ice_grapple_logic(False, IceGrappling.option_medium, state, world))
set_rule(multiworld.get_location("West Furnace - Lantern Pickup", player),
lambda state: has_stick(state, player) or state.has_any({fire_wand, laurels}, player))
lambda state: has_melee(state, player) or state.has_any({fire_wand, laurels}, player))
set_rule(multiworld.get_location("Secret Gathering Place - 10 Fairy Reward", player),
lambda state: state.has(fairies, player, 10))
@@ -310,9 +310,9 @@ def set_location_rules(world: "TunicWorld") -> None:
# Beneath the Vault
set_rule(multiworld.get_location("Beneath the Fortress - Bridge", player),
lambda state: has_stick(state, player) or state.has_any({laurels, fire_wand}, player))
lambda state: has_melee(state, player) or state.has_any({laurels, fire_wand}, player))
set_rule(multiworld.get_location("Beneath the Fortress - Obscured Behind Waterfall", player),
lambda state: has_stick(state, player) and has_lantern(state, world))
lambda state: has_melee(state, player) and has_lantern(state, world))
# Quarry
set_rule(multiworld.get_location("Quarry - [Central] Above Ladder Dash Chest", player),