fix some todos
This commit is contained in:
parent
3d833c683f
commit
d04af601ef
|
@ -42,6 +42,7 @@ def action_examine(target: str) -> str:
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# TODO: allow "the room" as a target
|
||||||
if normalize_name(target) == normalize_name(action_room.name):
|
if normalize_name(target) == normalize_name(action_room.name):
|
||||||
broadcast(
|
broadcast(
|
||||||
format_prompt(
|
format_prompt(
|
||||||
|
@ -52,6 +53,7 @@ def action_examine(target: str) -> str:
|
||||||
)
|
)
|
||||||
return format_prompt("action_examine_result_room", target_room=action_room)
|
return format_prompt("action_examine_result_room", target_room=action_room)
|
||||||
|
|
||||||
|
# TODO: allow "self" and "myself" as a target
|
||||||
target_character = find_character_in_room(action_room, target)
|
target_character = find_character_in_room(action_room, target)
|
||||||
if target_character:
|
if target_character:
|
||||||
broadcast(
|
broadcast(
|
||||||
|
|
|
@ -453,7 +453,7 @@ def embed_from_prompt(event: PromptEvent):
|
||||||
)
|
)
|
||||||
|
|
||||||
if user:
|
if user:
|
||||||
# TODO: use Discord user.mention to ping the user
|
# use Discord user.mention to ping the user
|
||||||
if user in player_mentions:
|
if user in player_mentions:
|
||||||
user = player_mentions[user]
|
user = player_mentions[user]
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,6 @@ AttributeEffectPattern = (
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class EffectPattern:
|
class EffectPattern:
|
||||||
"""
|
|
||||||
TODO: should this be an EffectTemplate?
|
|
||||||
"""
|
|
||||||
|
|
||||||
name: str
|
name: str
|
||||||
description: str
|
description: str
|
||||||
application: Literal["permanent", "temporary"]
|
application: Literal["permanent", "temporary"]
|
||||||
|
|
|
@ -346,6 +346,9 @@ async def server_main():
|
||||||
|
|
||||||
|
|
||||||
def server_system(world: World, turn: int, data: Any | None = None):
|
def server_system(world: World, turn: int, data: Any | None = None):
|
||||||
|
"""
|
||||||
|
TODO: this should be replaced with a snapshot event listener
|
||||||
|
"""
|
||||||
global last_snapshot
|
global last_snapshot
|
||||||
id = uuid4().hex # TODO: should a server be allowed to generate event IDs?
|
id = uuid4().hex # TODO: should a server be allowed to generate event IDs?
|
||||||
json_state = {
|
json_state = {
|
||||||
|
|
|
@ -101,12 +101,13 @@ def prompt_character_action(
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = world_result_parser(value, **kwargs)
|
|
||||||
|
|
||||||
# TODO: try to avoid parsing the JSON twice
|
# TODO: try to avoid parsing the JSON twice
|
||||||
event = ActionEvent.from_json(value, room, character)
|
event = ActionEvent.from_json(value, room, character)
|
||||||
|
# TODO: decide if invalid actions should be broadcast
|
||||||
broadcast(event)
|
broadcast(event)
|
||||||
|
|
||||||
|
result = world_result_parser(value, **kwargs)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
except ToolError as e:
|
except ToolError as e:
|
||||||
e_str = str(e)
|
e_str = str(e)
|
||||||
|
|
|
@ -170,9 +170,9 @@ def format_logic(
|
||||||
return " ".join(labels)
|
return " ".join(labels)
|
||||||
|
|
||||||
|
|
||||||
def load_logic(filename: str):
|
def load_logic(filename: str, name_prefix: str = "logic") -> GameSystem:
|
||||||
basename = path.splitext(path.basename(filename))[0]
|
basename = path.splitext(path.basename(filename))[0]
|
||||||
system_name = f"logic_{basename}"
|
system_name = f"{name_prefix}_{basename}"
|
||||||
logger.info("loading logic from file %s as system %s", filename, system_name)
|
logger.info("loading logic from file %s as system %s", filename, system_name)
|
||||||
|
|
||||||
with open(filename) as file:
|
with open(filename) as file:
|
||||||
|
|
|
@ -183,7 +183,7 @@ def simulate_planning(world: World, turn: int, data: Any | None = None):
|
||||||
set_current_character(character)
|
set_current_character(character)
|
||||||
|
|
||||||
# decrement effects on the character and remove any that have expired
|
# decrement effects on the character and remove any that have expired
|
||||||
expire_events(character, turn) # TODO: move to planning
|
expire_events(character, turn)
|
||||||
|
|
||||||
# give the character a chance to think and check their planner
|
# give the character a chance to think and check their planner
|
||||||
if agent.memory and len(agent.memory) > 0:
|
if agent.memory and len(agent.memory) > 0:
|
||||||
|
|
|
@ -62,7 +62,6 @@ def find_portal_in_room(room: Room, portal_name: str) -> Portal | None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
# TODO: allow item or str
|
|
||||||
def find_item(
|
def find_item(
|
||||||
world: World,
|
world: World,
|
||||||
item: Item | str,
|
item: Item | str,
|
||||||
|
|
|
@ -59,6 +59,10 @@ def format_prompt(prompt_key: str, **kwargs) -> str:
|
||||||
|
|
||||||
|
|
||||||
def format_str(template_str: str, **kwargs) -> str:
|
def format_str(template_str: str, **kwargs) -> str:
|
||||||
# TODO: cache templates
|
"""
|
||||||
|
Render a template string with the given keyword arguments.
|
||||||
|
|
||||||
|
Jinja will cache the template for future use.
|
||||||
|
"""
|
||||||
template = jinja_env.from_string(template_str)
|
template = jinja_env.from_string(template_str)
|
||||||
return template.render(**kwargs)
|
return template.render(**kwargs)
|
||||||
|
|
Loading…
Reference in New Issue