Skip to content

Commit

Permalink
Drafted the commander info page
Browse files Browse the repository at this point in the history
  • Loading branch information
RPINerd committed Aug 24, 2024
1 parent 8dc1420 commit 5bfe544
Show file tree
Hide file tree
Showing 3 changed files with 198 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/commander.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@ class CriminalRecord:
HERO = 9
ERRNO = 10

NAMES = {
PSYCHOPATH: "Psychopath",
VILLAIN: "Villain",
CRIMINAL: "Criminal",
CROOK: "Crook",
DUBIOUS: "Dubious",
CLEAN: "Clean",
LAWFUL: "Lawful",
TRUSTED: "Trusted",
LIKED: "Liked",
HERO: "Hero",
ERRNO: "ERRNO",
}

@staticmethod
def get_record_string(record: int) -> str:
return CriminalRecord.NAMES[record]


class CombatReputation:
HARMLESS = 0
Expand All @@ -37,6 +55,23 @@ class CombatReputation:
ELITE = 8
BORG = 9

NAMES = {
HARMLESS: "Harmless",
MOSTLY_HARMLESS: "Mostly Harmless",
POOR: "Poor",
AVERAGE: "Average",
ABOVE_AVERAGE: "Above Average",
COMPETENT: "Competent",
DANGEROUS: "Dangerous",
DEADLY: "Deadly",
ELITE: "Elite",
BORG: "Borg",
}

@staticmethod
def get_reputation_string(reputation: int) -> str:
return CombatReputation.NAMES[reputation]


class Commander:

Expand Down Expand Up @@ -74,6 +109,12 @@ def get_net_worth(self):
# TODO include moon value eventually
return self.credits + self.ship.get_value() - self.debt

def get_reputation(self) -> str:
return CombatReputation.get_reputation_string(self.reputation)

def get_police_record(self):
return CriminalRecord.get_record_string(self.policeRecord)

def pay_interest(self):

debt_interest = 0
Expand Down
135 changes: 135 additions & 0 deletions src/screens/commander_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import tkinter as tk
from tkinter import ttk

import src.ui_actions as actions

# from ..constants import BKG_COLOR, GameStateID
from .screens import Screen

Expand All @@ -20,6 +22,139 @@ class CommanderInfo(Screen):
def __init__(self, parent, screen_title, manager) -> None:
super().__init__(parent, screen_title, manager)

def create_widgets(self):

# Pull the data for the current commander's info
commander_info = actions.get_commander_info()

# First frame is the Name: {name}
self.name_frame = ttk.Frame(self)
self.name_title = ttk.Label(self.name_frame, text="Name:")
self.name_label = ttk.Label(self.name_frame, text=commander_info["name"])
self.name_title.pack(side="left")
self.name_label.pack(side="left")
self.name_frame.pack()

# Divides the remainder stats down the middle
self.halfway_frame = ttk.Frame(self)
self.left_half = ttk.Frame(self.halfway_frame)
self.right_half = ttk.Frame(self.halfway_frame)

# Top grid of the left half is the skills
self.skill_grid = ttk.Frame(self.left_half)
self.skill_grid.rowconfigure(0, weight=1)
self.skill_grid.rowconfigure(1, weight=1)
self.skill_grid.rowconfigure(2, weight=1)
self.skill_grid.rowconfigure(3, weight=1)
self.skill_grid.columnconfigure(0, weight=1)
self.skill_grid.columnconfigure(1, weight=1)

self.pilot_title = ttk.Label(self.skill_grid, text="Pilot:")
self.pilot_label = ttk.Label(self.skill_grid, text=commander_info["pilot"])
self.fighter_title = ttk.Label(self.skill_grid, text="Fighter:")
self.fighter_label = ttk.Label(self.skill_grid, text=commander_info["fighter"])
self.trader_title = ttk.Label(self.skill_grid, text="Trader:")
self.trader_label = ttk.Label(self.skill_grid, text=commander_info["trader"])
self.engineer_title = ttk.Label(self.skill_grid, text="Engineer:")
self.engineer_label = ttk.Label(self.skill_grid, text=commander_info["engineer"])

self.pilot_title.grid(row=0, column=0)
self.pilot_label.grid(row=0, column=1)
self.fighter_title.grid(row=1, column=0)
self.fighter_label.grid(row=1, column=1)
self.trader_title.grid(row=2, column=0)
self.trader_label.grid(row=2, column=1)
self.engineer_title.grid(row=3, column=0)
self.engineer_label.grid(row=3, column=1)

self.skill_grid.pack()

# Bottom half for the left side is a few titles
self.lower_left_frame = ttk.Frame(self.left_half)
self.networth_title = ttk.Label(self.lower_left_frame, text="Net Worth:")
self.rep_label = ttk.Label(self.lower_left_frame, text="Reputation:")
self.record_label = ttk.Label(self.lower_left_frame, text="Police Record:")
self.difficulty_label = ttk.Label(self.lower_left_frame, text="Difficulty:")

self.networth_title.pack()
self.rep_label.pack()
self.record_label.pack()
self.difficulty_label.pack()

self.lower_left_frame.pack()
self.left_half.pack(side="left")

# Right top grid is kills, time played, cash, debt
self.right_top_grid = ttk.Frame(self.right_half)
self.right_top_grid.rowconfigure(0, weight=1)
self.right_top_grid.rowconfigure(1, weight=1)
self.right_top_grid.rowconfigure(2, weight=1)
self.right_top_grid.rowconfigure(3, weight=1)
self.right_top_grid.columnconfigure(0, weight=1)
self.right_top_grid.columnconfigure(1, weight=1)

self.kills_title = ttk.Label(self.right_top_grid, text="Kills:")
self.kills_label = ttk.Label(self.right_top_grid, text=commander_info["kills"])
self.time_title = ttk.Label(self.right_top_grid, text="Time Played:")
self.time_label = ttk.Label(self.right_top_grid, text=commander_info["time"])
self.cash_title = ttk.Label(self.right_top_grid, text="Cash:")
self.cash_label = ttk.Label(self.right_top_grid, text=commander_info["cash"])
self.debt_title = ttk.Label(self.right_top_grid, text="Debt:")
self.debt_label = ttk.Label(self.right_top_grid, text=commander_info["debt"])

self.kills_title.grid(row=0, column=0)
self.kills_label.grid(row=0, column=1)
self.time_title.grid(row=1, column=0)
self.time_label.grid(row=1, column=1)
self.cash_title.grid(row=2, column=0)
self.cash_label.grid(row=2, column=1)
self.debt_title.grid(row=3, column=0)
self.debt_label.grid(row=3, column=1)

self.right_top_grid.pack()

# Bottom right is the net worth, reputation, police record, and difficulty values
self.lower_right_frame = ttk.Frame(self.right_half)

self.networth_label = ttk.Label(self.lower_right_frame, text=commander_info["net_worth"])
self.rep_label = ttk.Label(self.lower_right_frame, text=commander_info["rep"])
self.record_label = ttk.Label(self.lower_right_frame, text=commander_info["record"])
self.difficulty_label = ttk.Label(self.lower_right_frame, text=commander_info["difficulty"])

self.networth_label.pack()
self.rep_label.pack()
self.record_label.pack()
self.difficulty_label.pack()

self.lower_right_frame.pack()
self.right_half.pack(side="right")

self.halfway_frame.pack()

# Bottom of the screen has context buttons to switch to questlog, ship info, and special cargo
self.context_buttons_frame = ttk.Frame(self)
self.quest_button = ttk.Button(
self.context_buttons_frame,
text="Quests",
command=lambda: self.manager.go_to_screen("L"),
)
self.ship_info_button = ttk.Button(
self.context_buttons_frame,
text="Ship",
command=lambda: self.manager.go_to_screen("A"),
)
self.special_cargo_button = ttk.Button(
self.context_buttons_frame,
text="Special Cargo",
command=lambda: self.manager.go_to_screen("U"),
)

self.quest_button.pack(side="left")
self.ship_info_button.pack(side="left")
self.special_cargo_button.pack(side="left")

self.context_buttons_frame.pack(side="bottom", expand=True)


class ShipInfo(Screen):

Expand Down
22 changes: 22 additions & 0 deletions src/ui_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,28 @@ def get_system_info() -> tuple[list[str], str]:
return sys_info, pressure_str


def get_commander_info() -> dict:
"""
Returns a dictionary of the commander's information
"""
commander = c.GAME["commander"]
return {
"name": commander.name,
"pilot": (commander.pilotSkill, commander.pilotSkill),
"fighter": (commander.fighterSkill, commander.fighterSkill),
"trader": (commander.traderSkill, commander.traderSkill),
"engineer": (commander.engineerSkill, commander.engineerSkill),
"kills": commander.kills,
"time": commander.timePlayed,
"cash": commander.credits,
"debt": commander.debt,
"net_worth": commander.get_net_worth(),
"rep": commander.get_reputation(),
"record": commander.get_police_record(),
"difficulty": c.GAME["difficulty"],
}


def buy_fuel():
pass

Expand Down

0 comments on commit 5bfe544

Please sign in to comment.