Pre-combat-rewrite: Backup current state before comprehensive combat frontend rewrite
This commit is contained in:
@@ -15,6 +15,45 @@ def get_locale_string(value: Union[str, Dict[str, str]], lang: str = 'en') -> st
|
||||
return str(value)
|
||||
|
||||
|
||||
# Translation maps for backend messages
|
||||
DIRECTION_TRANSLATIONS = {
|
||||
'north': {'en': 'north', 'es': 'norte'},
|
||||
'south': {'en': 'south', 'es': 'sur'},
|
||||
'east': {'en': 'east', 'es': 'este'},
|
||||
'west': {'en': 'west', 'es': 'oeste'},
|
||||
'northeast': {'en': 'northeast', 'es': 'noreste'},
|
||||
'northwest': {'en': 'northwest', 'es': 'noroeste'},
|
||||
'southeast': {'en': 'southeast', 'es': 'sureste'},
|
||||
'southwest': {'en': 'southwest', 'es': 'suroeste'},
|
||||
}
|
||||
|
||||
def translate_travel_message(direction: str, location_name: str, lang: str = 'en') -> str:
|
||||
"""Translate a travel message to the user's language."""
|
||||
dir_translated = DIRECTION_TRANSLATIONS.get(direction, {}).get(lang, direction)
|
||||
|
||||
if lang == 'es':
|
||||
return f"Viajas al {dir_translated} hacia {location_name}."
|
||||
else:
|
||||
return f"You travel {dir_translated} to {location_name}."
|
||||
|
||||
|
||||
import json
|
||||
|
||||
def create_combat_message(message_type: str, **data) -> str:
|
||||
"""Create a structured combat message with type and data.
|
||||
|
||||
Args:
|
||||
message_type: Type of combat message (combat_start, player_attack, etc.)
|
||||
**data: Dynamic data for the message (damage, npc_name, etc.)
|
||||
|
||||
Returns:
|
||||
Dictionary with 'type' and 'data' fields
|
||||
"""
|
||||
return json.dumps({
|
||||
"type": message_type,
|
||||
"data": data
|
||||
})
|
||||
|
||||
def calculate_distance(x1: float, y1: float, x2: float, y2: float) -> float:
|
||||
"""
|
||||
Calculate distance between two points using Euclidean distance.
|
||||
|
||||
Reference in New Issue
Block a user