Implements and audits gameplay rules in robot-pokemon — badge-gated paths, one-time event guards, item use restrictions, and movement constraints. Use when adding a blocked exit, a story flag gate, or any conditional behaviour that depends on player progress.
Adds and validates gameplay rules: badge gates, story flag checks, item restrictions, and one-time event guards.
game-logic.agent.md
In locations.py, add a blocking condition to the exit:
# In can_move_to() in locations.py or exploration.py
if destination == "Route 24":
if "cascade" not in game_data.get("badges", []):
return False, "[yellow]The path is blocked. Earn the Cascade Badge first.[/yellow]"
Or via exit_data on the Location:
# locations.py
connected_to=["Cerulean City"], # Route 24 exit
# exploration.py checks game_data["badges"] before allowing movement
# texts/en/exploration.py:
# MOON_STONE_FOUND: list[str] = [
# "[bold yellow]★ You found a MOON STONE![/bold yellow]",
# "[italic]You picked up a Moon Stone![/italic]",
# ]
# exploration.py — in show_arrival or explore_area callback
from pytemon.texts.en import exploration as T
from pytemon.ui.formatters import write_lines
flags = game_state.game_data["story_flags"]
if location_name == "Mt. Moon" and not flags.get("received_moon_stone"):
flags["received_moon_stone"] = True
bag = game_state.game_data["bag"]
bag["Moon Stone"] = bag.get("Moon Stone", 0) + 1
write_lines(output, T.MOON_STONE_FOUND)
# Second visit: flag is True, block skips, no duplicate item
from pytemon.texts.en import items as T
from pytemon.ui.formatters import write_lines_fmt
# items.py
if item_name == "Thunder Stone":
valid_species = {"PIKACHU", "EEVEE"} # only these can use it
if pokemon["species"] not in valid_species:
write_lines_fmt(
output,
T.CANNOT_USE_ITEM_ON_POKEMON,
name=pokemon["name"],
item="Thunder Stone",
)
return
"rival_cerulean_beaten")if not flags.get("flag_name")game_state.cheat_mode if it's a movement gateInput: "Block Route 24 until player has Cascade Badge."
Output:
# texts/en/exploration.py:
# ROUTE24_BLOCKED: list[str] = [
# "[yellow]A trainer blocks the way: 'You need the Cascade Badge!'[/yellow]",
# ]
from pytemon.texts.en import exploration as T
from pytemon.ui.formatters import write_lines
# exploration.py — in move_to_location, after resolving destination
if destination.lower() == "route 24":
if "cascade" not in game_state.game_data.get("badges", []):
if not game_state.cheat_mode:
write_lines(output, T.ROUTE24_BLOCKED)
return
pytemon/exploration.py — movement and arrival logicpytemon/items.py — item use restrictionspytemon/game_state.py — game_data["story_flags"], game_data["badges"], cheat_modeif not game_state.cheat_mode