* When you teleport to a room, the teleport auto-triggers fire. * Rooms have auto-triggers. None by default. They are run every time you teleport to a room, and when the game starts. Gate behavior behind a variable. * PlayerInputAction waits for player input (and potentially write it into a variable) Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
44 lines
882 B
Python
44 lines
882 B
Python
import argparse
|
|
import importlib.util
|
|
from pathlib import Path
|
|
import sys
|
|
from agame.color import colorize
|
|
|
|
|
|
# Parse args
|
|
parser = argparse.ArgumentParser(
|
|
description="Run a game",
|
|
)
|
|
parser.add_argument(
|
|
"PACKAGE", type=str, help="The Python package that contains the game to run."
|
|
)
|
|
args = parser.parse_args()
|
|
|
|
# Get package to run
|
|
package = args.PACKAGE
|
|
|
|
# Load game module
|
|
game_module = importlib.import_module(package)
|
|
game = game_module.game # type: ignore
|
|
|
|
# Run
|
|
game.say("=" * 70)
|
|
game.say("Type ((help)) for help, or ((quit)) to exit.")
|
|
game.say("=" * 70)
|
|
game.say()
|
|
|
|
game.do_teleport_actions()
|
|
while True:
|
|
try:
|
|
game.say()
|
|
line = input(colorize("{{>}} "))
|
|
if line.lower() == "quit":
|
|
break
|
|
game.say()
|
|
game.run_command(line)
|
|
except (KeyboardInterrupt, EOFError):
|
|
break
|
|
|
|
game.say()
|
|
game.say("Bye.")
|