Event modifs and README update

This commit is contained in:
KuMiShi
2026-01-31 23:13:26 +01:00
parent a6391f961d
commit 74f0df49bd
7 changed files with 57 additions and 25 deletions

View File

@@ -304,7 +304,7 @@ async def toss_coin():
}
@mcp.tool()
async def create_player(name: str, strength: int, dexterity: int, intelligence: int, wisdom: int, charisma: int, hp: int, armor: int, speed: int, item_id:str):
async def create_player(name: str, strength: int, dexterity: int, intelligence: int, wisdom: int, charisma: int, hp: int, armor: int, speed: int, item_id:str, add_to_event:bool=True):
"""Create a new player. Need all the stats to function properly. Throw a d20 for every stats you don't have,
and a d50 for the armor and a d100 for speed.
@@ -319,22 +319,18 @@ async def create_player(name: str, strength: int, dexterity: int, intelligence:
armor: Armor class of the player
speed: Speed of the player
item: Item carried by the player
add_to_event: Boolean deciding whether or not to add the entity to the current event
"""
logging.info(f"Creating player named {name}")
try:
player_id = game.create_player(name=name,
strength=strength,
dexterity=dexterity,
intelligence=intelligence,
wisdom=wisdom,
charisma=charisma,
hp=20 + hp,
armor=50 + armor,
speed= speed,
equipped_item=game.get_item(item_id)) # Check if item exists
item = game.get_item(item_id) # Check if item exists
player_id = game.create_player(name=name, strength=strength, dexterity=dexterity, intelligence=intelligence, wisdom=wisdom, charisma=charisma, hp=20 + hp, armor=50 + armor, speed=speed, equipped_item=item)
game.add_item_to_entity(item_id=item_id, entity_id=player_id)
player_dict = game.get_player(player_id=player_id).serialize()
logging.info(f"Creation of player successful")
if add_to_event:
game.add_entity_to_event(player_id)
logging.info(f"Player #{player_id} added to current event!")
return {
"success": True,
"player_properties": player_dict
@@ -347,7 +343,7 @@ async def create_player(name: str, strength: int, dexterity: int, intelligence:
}
@mcp.tool()
async def create_npc(name: str, strength: int, dexterity: int, intelligence: int, wisdom: int, charisma: int, hp: int, armor: int, speed: int, item_id:str):
async def create_npc(name: str, strength: int, dexterity: int, intelligence: int, wisdom: int, charisma: int, hp: int, armor: int, speed: int, item_id:str, add_to_event:bool=True):
"""Create a new NPC. Need all the stats to function properly. Throw a d20 for every stats you don't have,
and a d50 for the armor and a d100 for speed.
@@ -362,14 +358,18 @@ async def create_npc(name: str, strength: int, dexterity: int, intelligence: int
armor: Armor class of the NPC
speed: Speed of the NPC
item: Item carried by the NPC
add_to_event: Boolean deciding whether or not to add the entity to the current event
"""
logging.info(f"Creating NPC named {name}")
try:
item = game.get_item(item_id) # Check if item exists
npc_id = game.create_npc(name=name, strength=strength, dexterity=dexterity, intelligence=intelligence, wisdom=wisdom, charisma=charisma, hp=20 + hp, armor=50 + armor, speed= speed, equipped_item=item)
npc_id = game.create_npc(name=name, strength=strength, dexterity=dexterity, intelligence=intelligence, wisdom=wisdom, charisma=charisma, hp=20 + hp, armor=50 + armor, speed=speed, equipped_item=item)
game.add_item_to_entity(item_id=item_id, entity_id=npc_id)
npc_dict = game.get_npc(npc_id=npc_id).serialize()
logging.info(f"Creation of NPC successful")
if add_to_event:
game.add_entity_to_event(npc_id)
logging.info(f"Player #{npc_id} added to current event!")
return {
"success": True,
"npc_properties": npc_dict