menu tree mockup
This commit is contained in:
parent
57543e139a
commit
02e7221149
7 changed files with 145 additions and 23 deletions
38
cli/app.py
Normal file
38
cli/app.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
from cli.war_menu import war_menu
|
||||
from cli.utils import choose_from_list
|
||||
|
||||
def app_menu(data):
|
||||
while True:
|
||||
print("\n=== Warmachron ===")
|
||||
print("1. Select war")
|
||||
print("2. Create war")
|
||||
print("3. Manage players")
|
||||
print("0. Exit")
|
||||
|
||||
choice = input("> ").strip()
|
||||
|
||||
if choice == "1":
|
||||
war = select_war(data)
|
||||
if war:
|
||||
war_menu(data, war)
|
||||
|
||||
elif choice == "2":
|
||||
create_war(data)
|
||||
|
||||
elif choice == "3":
|
||||
manage_players(data)
|
||||
|
||||
elif choice == "0":
|
||||
return
|
||||
|
||||
def select_war(data):
|
||||
wars = data["wars"]
|
||||
if not wars:
|
||||
print("No wars available.")
|
||||
return None
|
||||
|
||||
return choose_from_list(
|
||||
wars,
|
||||
lambda w: f"{w['name']} ({w['year']})"
|
||||
)
|
||||
|
||||
23
cli/campaign_menu.py
Normal file
23
cli/campaign_menu.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
from cli.round_menu import round_menu
|
||||
|
||||
def campaign_menu(data, war, campaign):
|
||||
while True:
|
||||
print(f"\n=== Campaign: {campaign['name']} ===")
|
||||
print("1. Select round")
|
||||
print("2. Append round")
|
||||
print("3. Finish campaign")
|
||||
print("4. Edit/Delete campaign")
|
||||
print("0. Back")
|
||||
|
||||
choice = input("> ").strip()
|
||||
|
||||
if choice == "1":
|
||||
rnd = select_round(campaign)
|
||||
if rnd:
|
||||
round_menu(data, war, campaign, rnd)
|
||||
|
||||
elif choice == "2":
|
||||
append_round(campaign)
|
||||
|
||||
elif choice == "0":
|
||||
return
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
def main_menu():
|
||||
print("\n=== Wargame Campaign App ===")
|
||||
print("1. List wars")
|
||||
print("2. Start new campaign")
|
||||
print("3. Start new round")
|
||||
print("4. Enter battle results")
|
||||
print("5. Save & exit")
|
||||
|
||||
return input("> ")
|
||||
34
cli/round_menu.py
Normal file
34
cli/round_menu.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
def round_menu(data, war, campaign, rnd):
|
||||
while True:
|
||||
print(f"\n=== Round {rnd['number']} ===")
|
||||
print("1. Enter choices and pairing")
|
||||
print("2. Enter battle results")
|
||||
print("3. Finish round")
|
||||
print("4. Edit/Delete round")
|
||||
print("0. Back")
|
||||
|
||||
choice = input("> ").strip()
|
||||
|
||||
if choice == "1":
|
||||
enter_choices(data, war, campaign, rnd)
|
||||
|
||||
elif choice == "2":
|
||||
enter_battle_results(data, war, campaign, rnd)
|
||||
|
||||
elif choice == "0":
|
||||
return
|
||||
|
||||
def enter_choices(data, war, campaign, rnd):
|
||||
print("Entering choices (placeholder)")
|
||||
# later:
|
||||
# - list campaign participants
|
||||
# - input primary / secondary sector
|
||||
# - store in rnd["choices"]
|
||||
|
||||
def enter_battle_results(data, war, campaign, rnd):
|
||||
print("Entering battle results (placeholder)")
|
||||
# later:
|
||||
# - list battles
|
||||
# - select winner
|
||||
# - apply scoring
|
||||
|
||||
14
cli/utils.py
Normal file
14
cli/utils.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
def choose_from_list(items, label_fn):
|
||||
for i, item in enumerate(items, start=1):
|
||||
print(f"{i}. {label_fn(item)}")
|
||||
print("0. Back")
|
||||
|
||||
choice = input("> ").strip()
|
||||
if choice == "0":
|
||||
return None
|
||||
|
||||
try:
|
||||
return items[int(choice) - 1]
|
||||
except (ValueError, IndexError):
|
||||
print("Invalid choice")
|
||||
return None
|
||||
33
cli/war_menu.py
Normal file
33
cli/war_menu.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
from cli.campaign_menu import campaign_menu
|
||||
from storage.repository import save_data
|
||||
|
||||
def war_menu(data, war):
|
||||
while True:
|
||||
print(f"\n=== War: {war['name']} ===")
|
||||
print("1. Select campaign")
|
||||
print("2. Append campaign")
|
||||
print("3. Finish war")
|
||||
print("4. Edit/Delete war")
|
||||
print("0. Back")
|
||||
|
||||
choice = input("> ").strip()
|
||||
|
||||
if choice == "1":
|
||||
campaign = select_campaign(war)
|
||||
if campaign:
|
||||
campaign_menu(data, war, campaign)
|
||||
|
||||
elif choice == "2":
|
||||
append_campaign(war)
|
||||
|
||||
elif choice == "0":
|
||||
return
|
||||
|
||||
def append_campaign(war, data):
|
||||
name = input("Campaign name: ")
|
||||
war["campaigns"].append({
|
||||
"name": name,
|
||||
"rounds": [],
|
||||
"completed": False
|
||||
})
|
||||
save_data(data)
|
||||
17
main.py
17
main.py
|
|
@ -1,21 +1,10 @@
|
|||
from storage.repository import load_data, save_data
|
||||
from cli.menu import main_menu
|
||||
from cli.app import app_menu
|
||||
|
||||
def main():
|
||||
data = load_data()
|
||||
|
||||
while True:
|
||||
choice = main_menu()
|
||||
|
||||
if choice == "1":
|
||||
print("Wars:")
|
||||
for war in data["wars"]:
|
||||
print(f"- {war['name']}")
|
||||
|
||||
elif choice == "5":
|
||||
save_data(data)
|
||||
print("Goodbye.")
|
||||
break
|
||||
app_menu(data)
|
||||
save_data(data)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue