QOL improvements to BYOG roster edit mode, allow for viewing roster members without editing them

This commit is contained in:
markmental 2026-11-02 15:58:02 -05:00
commit 5f71ce8e6b
3 changed files with 69 additions and 3 deletions

View file

@ -49,6 +49,9 @@ federation, not just the built-in WWF games:
editable profile; the built-in games themselves stay unchanged.
- **Edit a custom game** — reopen any saved profile.
The Edit roster menu offers a read-only **View roster** option that prints the
full roster alphabetically without prompting for changes.
Show names are WWE branding, so custom federations name their own three shows
during creation (or later via **Show names** in the BYOG editor). The three
slots match the season cycle — the first weekly show, the second weekly show,

View file

@ -560,12 +560,23 @@ def default_custom_match_types(roster_size: int) -> list[dict[str, Any]]:
]
def show_roster(config: dict[str, Any]) -> None:
names = sorted(config["roster"], key=str.casefold)
if not names:
print("The roster is empty.")
return
print(f"\nRoster ({len(names)} wrestlers):")
for position, name in enumerate(names, 1):
print(f" {position}. {name}")
def edit_custom_roster(config: dict[str, Any]) -> None:
while True:
choices = ["Add wrestler", "Remove wrestler", "Done"]
labels = ["Add a wrestler", "Remove a wrestler", f"Done ({len(config['roster'])} listed)"]
choices = ["Add wrestler", "Remove wrestler", "View roster", "Done"]
labels = ["Add a wrestler", "Remove a wrestler", "View roster (read-only)",
f"Done ({len(config['roster'])} listed)"]
action = ask_choice("Edit roster", choices, labels=labels)
if action == 2:
if action == 3:
break
if action == 0:
name = ask("Wrestler name").strip()
@ -575,6 +586,8 @@ def edit_custom_roster(config: dict[str, Any]) -> None:
print("That wrestler is already in this roster.")
else:
config["roster"].append(name)
elif action == 2:
show_roster(config)
elif not config["roster"]:
print("The roster is empty.")
else:

View file

@ -1083,6 +1083,56 @@ class BYOGTests(unittest.TestCase):
app.edit_custom_shows(config)
self.assertEqual(config["shows"]["SmackDown"], "Fantasy Zoom")
def test_view_roster_lists_names_read_only(self):
config = {"roster": ["Zulu Viper", "Ava Crusher", "Ben Brawler"],
"women_roster": ["Ava Crusher"]}
captured = io.StringIO()
with contextlib.redirect_stdout(captured), \
patch.object(app, "ask_choice", side_effect=[2, 3]):
app.edit_custom_roster(config)
text = captured.getvalue()
self.assertIn("Roster (3 wrestlers):", text)
self.assertIn(" 1. Ava Crusher", text)
self.assertIn(" 2. Ben Brawler", text)
self.assertIn(" 3. Zulu Viper", text)
self.assertEqual(config["roster"], ["Zulu Viper", "Ava Crusher", "Ben Brawler"])
self.assertEqual(config["women_roster"], ["Ava Crusher"])
def test_view_roster_on_empty_roster(self):
config = {"roster": [], "women_roster": []}
captured = io.StringIO()
with contextlib.redirect_stdout(captured), \
patch.object(app, "ask_choice", side_effect=[2, 3]):
app.edit_custom_roster(config)
self.assertIn("The roster is empty.", captured.getvalue())
def test_view_roster_dumps_large_roster_completely(self):
config = {"roster": [f"Wrestler {index:02d}" for index in range(65)],
"women_roster": []}
captured = io.StringIO()
with contextlib.redirect_stdout(captured), \
patch.object(app, "ask_choice", side_effect=[2, 3]):
app.edit_custom_roster(config)
text = captured.getvalue()
self.assertIn("Roster (65 wrestlers):", text)
self.assertIn(" 1. Wrestler 00", text)
self.assertIn(" 65. Wrestler 64", text)
def test_roster_menu_ordering_adds_view_between_remove_and_done(self):
seen = {}
config = {"roster": ["Ava Crusher"], "women_roster": []}
def capturing_choice(prompt, choices, default=None, labels=None):
if prompt == "Edit roster":
seen["labels"] = labels
return len(choices) - 1
with contextlib.redirect_stdout(io.StringIO()), \
patch.object(app, "ask_choice", side_effect=capturing_choice):
app.edit_custom_roster(config)
self.assertEqual(seen["labels"], ["Add a wrestler", "Remove a wrestler",
"View roster (read-only)", "Done (1 listed)"])
class FlashRenderingTests(unittest.TestCase):
def test_flash_updates_only_changed_rows_not_static_header(self):