mirror of
https://github.com/rr-/pq-cli.git
synced 2026-09-29 14:54:00 -06:00
build: add Docker builds
Co-authored-by: Jakub Stastka <jakub@stastka.org>
This commit is contained in:
co-authored by
Jakub Stastka
parent
7426924170
commit
696fad78b3
@@ -66,6 +66,21 @@ def list_players(roster: Roster, file: T.Optional[T.Any] = None) -> None:
|
||||
print(f"{i}. {player.name}", file=file)
|
||||
|
||||
|
||||
def bootstrap_first_run(roster: Roster, args: argparse.Namespace) -> None:
|
||||
if roster.players or args.list_saves or args.load_save:
|
||||
return
|
||||
|
||||
print("No saved characters found. Starting first-run character creation.")
|
||||
ui = BasicUserInterface(roster, None, args)
|
||||
while not roster.players:
|
||||
player = ui.create_player(auto_play=False)
|
||||
if player:
|
||||
return
|
||||
if not ui.confirm("No character created. Do you want to try again?"):
|
||||
print("A character is required for first run.", file=sys.stderr)
|
||||
raise SystemExit(1)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
args = parse_args()
|
||||
roster = Roster.load(SAVE_PATH)
|
||||
@@ -83,6 +98,8 @@ def main() -> None:
|
||||
list_players(roster, file=sys.stderr)
|
||||
exit(1)
|
||||
|
||||
bootstrap_first_run(roster, args)
|
||||
|
||||
try:
|
||||
ui = args.ui(roster, player, args)
|
||||
ui.run()
|
||||
|
||||
@@ -101,7 +101,7 @@ class BasicUserInterface(BaseUserInterface):
|
||||
self.quit()
|
||||
break
|
||||
|
||||
def create_player(self) -> T.Optional[Player]:
|
||||
def create_player(self, *, auto_play: bool = True) -> T.Optional[Player]:
|
||||
name = input("Name your new character: ")
|
||||
if not name:
|
||||
print("Cancelled.")
|
||||
@@ -123,7 +123,9 @@ class BasicUserInterface(BaseUserInterface):
|
||||
name=name, race=race, class_=class_, stats=stats
|
||||
)
|
||||
self.roster.players.append(player)
|
||||
if self.confirm("Do you want to play as your new character?"):
|
||||
if auto_play and self.confirm(
|
||||
"Do you want to play as your new character?"
|
||||
):
|
||||
self.play(player)
|
||||
return player
|
||||
|
||||
|
||||
Reference in New Issue
Block a user