Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 8 additions & 24 deletions grimoire-runner/src/grimoire_runner/simple_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
"""
Minimal CLI tool for GRIMOIRE engine development and testing.

This is a development tool to test engine changes without the complexity
of the full Rich TUI interface. It provides simple command-line interaction
with event logging and user input prompting using blinker signals.

Phase 1, Step 4: Enhanced to use blinker signal-based event system.
This is a development tool to test engine changes and GRIMOIRE systems.
It provides simple command-line interaction with event logging and user
input prompting using event signals.
"""

import argparse
Expand Down Expand Up @@ -76,15 +74,6 @@ def __init__(self, debug: bool = False):
"generated_name", # Name generation results
}

# Step-type specific handling for "result" field
self.step_specific_result_handling = {
"dice_roll": False, # Use log_message templates instead
"player_input": True, # Show result field
"llm_generation": True, # Show result field
"name_generation": True, # Show result field
"player_choice": False, # Raw result objects, use display_value actions instead
}

def display_step_data(self, step, step_data):
"""Unified method to display step data, filtering internal fields appropriately."""
if not step_data:
Expand All @@ -102,13 +91,8 @@ def display_step_data(self, step, step_data):
filtered_data = step_data

for key, value in filtered_data.items():
# Handle "result" field based on step type
# Skip displaying "result" field based on step type
if key == "result":
should_show_result = self.step_specific_result_handling.get(
step.type, True
)
if should_show_result:
self._format_user_field(step, key, value)
continue

# Always show other user-facing fields
Expand All @@ -132,13 +116,13 @@ def _format_user_field(self, step, key, value):
if step.type == "dice_roll" and key == "result":
# For dice rolls, show a clean result without internal object details
if hasattr(value, "detail") and hasattr(value, "total"):
print(f" 🎲 Roll result: {value.detail}")
print(f"🎲 Roll result: {value.detail}")
else:
print(f" 🎲 Roll result: {value}")
print(f"🎲 Roll result: {value}")
elif step.type == "player_input" and key == "result":
print(f" 💬 Input received: {value}")
print(f"💬 Input received: {value}")
elif step.type == "llm_generation" and key == "result":
print(f" 🤖 Generated: {value}")
print(f"🤖 Generated: {value}")
else:
# Default formatting for other user fields
print(f" {key}: {value}")
Expand Down
2 changes: 1 addition & 1 deletion systems/knave_1e/flows/character_creation.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
id: character_creation
type: flow
kind: flow
name: "Character Creation"
description: "Character creation process for {{ system.name }}"
version: "1.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
id: choose_name_and_gender
type: flow
kind: flow
name: "Choose Character Name and Gender"
description: "Name and gender selection for character creation process for {{ system.name }}"
version: "1.0"
Expand All @@ -8,6 +8,7 @@ outputs:
- type: str
id: character_name
- type: str
enum: ["Female", "Male", "Non-binary"]
id: character_gender

steps:
Expand Down Expand Up @@ -47,7 +48,7 @@ steps:
path: "outputs.character_gender"
value: Non-binary
actions:
- display_value: "outputs.character_gender"
- display_message: "Character is {{ outputs.character_gender}}"
next_step: choose_name_method

- id: roll_gender
Expand All @@ -60,8 +61,8 @@ steps:
- set_value:
path: "outputs.character_gender"
value: "{{ result.entry }}"
- log_message: "Rolled {{ result.roll_result.detail }}"
- log_message: "Character is {{ result.entry }}"
- display_message: "Rolled {{ result.roll_result.detail }}"
- display_message: "Character is {{ result.entry }}"
- display_value: "outputs.character_gender"

next_step: choose_name_method
Expand Down Expand Up @@ -115,3 +116,5 @@ steps:
actions:
- display_value: "outputs.character_name"
- display_value: "outputs.character_gender"
- validate_value: "outputs.character_name"
- validate_value: "outputs.character_gender"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
id: choose_starting_weapon
type: flow
kind: flow
name: "Choose Starting Weapon for Character Creation"
description: "Starting weapon for character creation process for {{ system.name }}"
version: "1.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
id: determine_traits
type: flow
kind: flow
name: "Determine Character Traits"
description: "Determine the physical and personality traits for character creation process for {{ system.name }}"
version: "1.0"
Expand Down
5 changes: 3 additions & 2 deletions systems/knave_1e/flows/character_creation/roll_abilities.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
id: roll_abilities
type: flow
kind: flow
name: "Roll Abilities for a Character"
description: "Rolling abilities during Character Creation for {{ system.name }}"
version: "1.0"
Expand All @@ -19,6 +19,7 @@ steps:
type: dice_sequence
prompt: "Roll 3d6 for each ability. The lowest die becomes your bonus."
sequence:
#items: "{{ keys(outputs.abilities) }}"
items:
[
"strength",
Expand All @@ -33,7 +34,7 @@ steps:
- set_value:
path: "outputs.abilities.{{ item }}.bonus"
value: "{{ result.total }}"
- log_message:
- display_message:
message: "{{ item[0:3]|upper }}: bonus +{{ result.total }}, defense {{ result.total + 10 }} ({{ result.detail }})"

- id: ability_swap_choice
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
id: roll_hit_points
type: flow
kind: flow
name: "Roll Hit Points for a Character"
description: "Rolling hit points during Character Creation for {{ system.name }}"
version: "1.0"
Expand Down Expand Up @@ -43,5 +43,5 @@ steps:
- set_value:
path: "outputs.hit_points"
value: "{{ result.total }}"
- log_message: "Rolled {{ result.detail }}"
- log_message: "Hit Points are {{ result.total }}"
- display_message: "Rolled {{ result.detail }}"
- display_message: "Hit Points are {{ result.total }}"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
id: roll_starting_gear
type: "flow"
kind: flow
name: "Determine Starting Equipment"
description: "Determine the starting equipment for a Character"
version: "1.0"
Expand Down
18 changes: 9 additions & 9 deletions systems/knave_1e/flows/combat/perform_initiative.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
id: perform_initiative
type: flow
kind: flow
name: "Perform Initiative"
description: >-
Determines the who acts first in combat - Players or Enemies.
version: "1.0"
inputs: []

Determines who acts first in combat - Players or Enemies.
version: 1
outputs:
- type: str
id: side_with_initiative
Expand All @@ -16,12 +14,14 @@ steps:
- id: roll_initiative
name: "Roll Initiative"
type: dice_roll
prompt: "Rolling for initiative..."
roll: 1d6
pre_actions:
- display_message:
message: "Rolling initiative..."
actions:
- display_message:
message: "Rolled {{ result.detail }}"
- set_value:
path: "outputs.side_with_initiative"
value: "{% if result.total > 3 %}Players{% else %}Enemies{% endif %}"
- log_message:
message: "Rolled {{ result.detail }}"
result_message: "{{ outputs.side_with_initiative }} have initiative"
- display_message: "{{ outputs.side_with_initiative }} have initiative"
2 changes: 1 addition & 1 deletion systems/knave_1e/flows/determine_npc_reaction.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
id: determine_npc_reaction
type: flow
kind: flow
name: "Determine NPC Reaction"
description: >-
Determines the NPC's reaction based on the context provided.
Expand Down
4 changes: 2 additions & 2 deletions systems/knave_1e/flows/inventory/add_item_to_character.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
id: "add_item_to_character"
type: "flow"
id: add_item_to_character
kind: flow
name: "Add Item to Character"
description: "Add an item to a character's inventory"
version: "1.0"
Expand Down
4 changes: 2 additions & 2 deletions systems/knave_1e/flows/inventory/add_items_to_character.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
id: "add_items_to_character"
type: "flow"
id: add_items_to_character
kind: flow
name: "Add Items to Character"
description: "Add multiple items to a character's inventory"
version: "1.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
id: perform_saving_throw
type: flow
kind: flow
name: "Perform Saving Throw"
description: >-
Determines the saving throw required from a given context and performs it.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
id: roll_opposed_save
type: flow
kind: flow
name: "Roll Opposed Save"
description: "Roll a saving throw vs an opponent's defense DC"
version: "1.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
id: roll_saving_throw
type: flow
kind: flow
name: "Roll Saving Throw"
description: "Roll a saving throw versus a fixed DC (usually 15)"
version: "1.0"
Expand Down
15 changes: 6 additions & 9 deletions systems/knave_1e/models/character.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ attributes:

hit_points:
max: { type: int }
current: { type: int, range: "0..{{ this.hit_points.max }}" } # track current
current: { type: int, range: "0..{{ hit_points.max }}" } # track current

armor:
bonus: { type: int, range: "0..10" }
defense: { type: int, derived: "{{ 10 + this.bonus }}" }
defense: { type: int, derived: "{{ 10 + bonus }}" }

exploration_speed: { type: int, default: 120, range: "0..240" } # in feet
combat_speed: { type: int, default: 40, range: "0..160" } # in feet
Expand All @@ -31,16 +31,13 @@ attributes:

# --- inventory system ---
inventory_capacity:
{ type: int, derived: "{{ this.abilities.constitution.defense }}" }
{ type: int, derived: "{{ abilities.constitution.defense }}" }
inventory: { type: list, of: item, default: [] }
slots_used:
{
type: int,
derived: "{{ this.inventory | map(attribute='slot_cost') | sum }}",
}
{ type: int, derived: "{{ inventory | map(attribute='slot_cost') | sum }}" }

validations:
- expression: "{{ this.hit_points.current <= this.hit_points.max }}"
- expression: "{{ hit_points.current <= hit_points.max }}"
message: "Current HP cannot exceed maximum HP"
- expression: "{{ this.slots_used <= this.inventory_capacity }}"
- expression: "{{ slots_used <= inventory_capacity }}"
message: "Item slots used cannot exceed inventory capacity"
Loading