38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
from random import randint
|
|
|
|
from adventure.context import broadcast, get_current_context, get_dungeon_master
|
|
from adventure.search import find_item_in_room
|
|
|
|
|
|
def action_climb(target: str) -> str:
|
|
"""
|
|
Climb a structure or natural feature.
|
|
|
|
Args:
|
|
target: The object or feature to climb.
|
|
"""
|
|
_, action_room, action_actor = get_current_context()
|
|
|
|
dungeon_master = get_dungeon_master()
|
|
# Assume 'climbable' is an attribute that marks climbable targets
|
|
climbable_feature = find_item_in_room(action_room, target)
|
|
|
|
if climbable_feature and climbable_feature.attributes.get("climbable", False):
|
|
climb_difficulty = int(climbable_feature.attributes.get("difficulty", 5))
|
|
climb_roll = randint(1, 20)
|
|
|
|
# Get flavor text for the climb attempt
|
|
flavor_text = dungeon_master(
|
|
f"Describe {action_actor.name}'s attempt to climb {target}."
|
|
)
|
|
if climb_roll > climb_difficulty:
|
|
broadcast(
|
|
f"{action_actor.name} successfully climbs the {target}. {flavor_text}"
|
|
)
|
|
return f"You successfully climb the {target}."
|
|
else:
|
|
broadcast(f"{action_actor.name} fails to climb the {target}. {flavor_text}")
|
|
return f"You fail to climb the {target}."
|
|
else:
|
|
return f"The {target} is not climbable."
|