Release v0.2.10: Update package-lock.json and CI config
This commit is contained in:
@@ -4,7 +4,7 @@ Loads and manages game items from JSON without bot dependencies.
|
||||
"""
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Dict, Any, Optional
|
||||
from typing import Dict, Any, Optional, Union
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ from dataclasses import dataclass
|
||||
class Item:
|
||||
"""Represents a game item"""
|
||||
id: str
|
||||
name: str
|
||||
description: str
|
||||
name: Union[str, Dict[str, str]]
|
||||
description: Union[str, Dict[str, str]]
|
||||
type: str
|
||||
image_path: str = ""
|
||||
emoji: str = "📦"
|
||||
|
||||
@@ -12,7 +12,7 @@ import logging
|
||||
|
||||
from ..core.security import get_current_user, security, verify_internal_key
|
||||
from ..services.models import *
|
||||
from ..services.helpers import calculate_distance, calculate_stamina_cost, calculate_player_capacity
|
||||
from ..services.helpers import calculate_distance, calculate_stamina_cost, calculate_player_capacity, get_locale_string
|
||||
from .. import database as db
|
||||
from ..items import ItemsManager
|
||||
from .. import game_logic
|
||||
@@ -226,6 +226,11 @@ async def get_game_state(current_user: dict = Depends(get_current_user)):
|
||||
"encumbrance": item_def.encumbrance,
|
||||
"weapon_effects": item_def.weapon_effects if hasattr(item_def, 'weapon_effects') else {}
|
||||
}
|
||||
else:
|
||||
logger.error(f"❌ Item definition not found for equipped item: {inv_item['item_id']} (slot: {slot})")
|
||||
else:
|
||||
logger.warning(f"⚠️ Inventory item not found for equipped slot: {slot} (ID: {item_data['item_id']})")
|
||||
|
||||
if slot not in equipment:
|
||||
equipment[slot] = None
|
||||
|
||||
|
||||
@@ -3,11 +3,18 @@ Helper utilities for game calculations and common operations.
|
||||
Contains distance calculations, stamina costs, capacity calculations, etc.
|
||||
"""
|
||||
import math
|
||||
from typing import Tuple, List, Dict, Any
|
||||
from typing import Tuple, List, Dict, Any, Union
|
||||
from .. import database as db
|
||||
from ..items import ItemsManager
|
||||
|
||||
|
||||
def get_locale_string(value: Union[str, Dict[str, str]], lang: str = 'en') -> str:
|
||||
"""Helper to safely get string from i18n object or string."""
|
||||
if isinstance(value, dict):
|
||||
return value.get(lang) or value.get('en') or str(value)
|
||||
return str(value)
|
||||
|
||||
|
||||
def calculate_distance(x1: float, y1: float, x2: float, y2: float) -> float:
|
||||
"""
|
||||
Calculate distance between two points using Euclidean distance.
|
||||
@@ -182,7 +189,7 @@ async def reduce_armor_durability(player_id: int, damage_taken: int, items_manag
|
||||
# which cascades to the inventory row.
|
||||
|
||||
broken_armor.append({
|
||||
'name': armor['item_def'].name,
|
||||
'name': get_locale_string(armor['item_def'].name),
|
||||
'emoji': getattr(armor['item_def'], 'emoji', '🛡️')
|
||||
})
|
||||
|
||||
@@ -214,7 +221,7 @@ async def consume_tool_durability(user_id: int, tools: list, inventory: list, it
|
||||
'unique_item_id': inv_item['unique_item_id'],
|
||||
'item_id': inv_item['item_id'],
|
||||
'durability': unique_item['durability'],
|
||||
'name': item_def.name,
|
||||
'name': get_locale_string(item_def.name),
|
||||
'emoji': getattr(item_def, 'emoji', '🔧')
|
||||
})
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@ Loads game data from JSON files without bot dependencies.
|
||||
"""
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Any, Optional
|
||||
from typing import Dict, List, Any, Optional, Union
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
|
||||
@dataclass
|
||||
class Outcome:
|
||||
"""Represents an outcome of an action"""
|
||||
text: str
|
||||
text: Union[str, Dict[str, str]]
|
||||
items_reward: Dict[str, int] = field(default_factory=dict)
|
||||
damage_taken: int = 0
|
||||
|
||||
@@ -20,7 +20,7 @@ class Outcome:
|
||||
class Action:
|
||||
"""Represents an action that can be performed on an interactable"""
|
||||
id: str
|
||||
label: str
|
||||
label: Union[str, Dict[str, str]]
|
||||
stamina_cost: int = 2
|
||||
outcomes: Dict[str, Outcome] = field(default_factory=dict)
|
||||
|
||||
@@ -32,7 +32,7 @@ class Action:
|
||||
class Interactable:
|
||||
"""Represents an interactable object"""
|
||||
id: str
|
||||
name: str
|
||||
name: Union[str, Dict[str, str]]
|
||||
image_path: str = ""
|
||||
actions: List[Action] = field(default_factory=list)
|
||||
|
||||
@@ -52,8 +52,8 @@ class Exit:
|
||||
class Location:
|
||||
"""Represents a location in the game world"""
|
||||
id: str
|
||||
name: str
|
||||
description: str
|
||||
name: Union[str, Dict[str, str]]
|
||||
description: Union[str, Dict[str, str]]
|
||||
image_path: str = ""
|
||||
exits: Dict[str, str] = field(default_factory=dict) # direction -> destination_id
|
||||
exit_stamina: Dict[str, int] = field(default_factory=dict) # direction -> stamina_cost
|
||||
|
||||
Reference in New Issue
Block a user