commit entity-modify-player-inventory
This commit is contained in:
11
server.py
11
server.py
@@ -100,16 +100,15 @@ async def throw_a_dice(n_faces: int) -> Any:
|
||||
n_faces: Number of faces of the dice
|
||||
"""
|
||||
logging.info(f"Throwing a dice with {n_faces} faces")
|
||||
dice = Dice(n_faces)
|
||||
|
||||
if n_faces < 1:
|
||||
raise ValueError("Number of faces must be at least 1")
|
||||
elif n_faces == 1:
|
||||
return 1
|
||||
elif n_faces == 2:
|
||||
return dice.head_or_tails()
|
||||
return Dice.head_or_tails()
|
||||
else:
|
||||
return dice.roll()
|
||||
return Dice.roll(n_faces)
|
||||
|
||||
|
||||
|
||||
@@ -133,7 +132,7 @@ async def create_player(name: str, strength: int, dexterity: int, intelligence:
|
||||
logging.info(f"Creating player with name={name}")
|
||||
player = Player(name, strength, dexterity, intelligence, wisdom, charisma, hp, armor, speed)
|
||||
logging.info(f"Created player: {player}")
|
||||
game.players.append(player)
|
||||
game.active_players.append(player)
|
||||
return player.serialize_dict()
|
||||
|
||||
@mcp.tool()
|
||||
@@ -156,7 +155,7 @@ async def create_npc(name: str, strength: int, dexterity: int, intelligence: int
|
||||
logging.info(f"Creating NPC with name={name}")
|
||||
npc = NPC(name, strength, dexterity, intelligence, wisdom, charisma, hp, armor, speed)
|
||||
logging.info(f"Created NPC: {npc}")
|
||||
game.npcs.append(npc)
|
||||
game.active_npcs.append(npc)
|
||||
return npc.serialize_dict()
|
||||
|
||||
@mcp.tool()
|
||||
@@ -171,7 +170,7 @@ async def create_item(name: str, description: str, bonus: str) -> Dict[str, Any]
|
||||
logging.info(f"Creating item with name={name}")
|
||||
item = Item(name, description, bonus)
|
||||
logging.info(f"Created item: {item}")
|
||||
game.items.append(item)
|
||||
game.active_items.append(item)
|
||||
return item.serialize_dict()
|
||||
|
||||
@mcp.tool()
|
||||
|
||||
Reference in New Issue
Block a user