Skip to content

Commit

Permalink
Prototyped equipment buy screen
Browse files Browse the repository at this point in the history
  • Loading branch information
RPINerd committed Sep 5, 2024
1 parent 6789fef commit e88a494
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
32 changes: 30 additions & 2 deletions src/screens/gamescreens.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class BuyCargo(Screen):
def __init__(self, parent, screen_title, manager) -> None:
super().__init__(parent, screen_title, manager)

def create_widgets(self):
def create_widgets(self) -> None:
self.table_frame = ttk.Frame(self)
for i, value in enumerate(actions.get_ware_list()):
ttk.Button(self.table_frame, text=randint(0, 42)).grid(row=i, column=0)
Expand All @@ -106,7 +106,7 @@ class SellCargo(Screen):
def __init__(self, parent, screen_title, manager) -> None:
super().__init__(parent, screen_title, manager)

def create_widgets(self):
def create_widgets(self) -> None:
self.table_frame = ttk.Frame(self)
for i, value in enumerate(actions.get_ware_list()):
ttk.Button(self.table_frame, text="0").grid(row=i, column=0)
Expand All @@ -129,6 +129,34 @@ class BuyEquipment(Screen):
def __init__(self, parent, screen_title, manager) -> None:
super().__init__(parent, screen_title, manager)

def create_widgets(self) -> None:
self.table_frame = ttk.Frame(self)

sold_equipment = actions.get_equip_sold()
for i, value in enumerate(sold_equipment):

sold = value[0] == ""
# First column are Buy buttons for each equipment
if sold:
ttk.Button(self.table_frame, text="Buy", command=actions.buy_equipment).grid(row=i, column=0)
else:
ttk.Label(self.table_frame, text=" ").grid(
row=i,
column=0,
)

# Second column is the equipment name
ttk.Label(self.table_frame, text=value[1]).grid(row=i, column=1, sticky="w")

# Third column is the cost for each equipment
ttk.Label(self.table_frame, text=value[2]).grid(row=i, column=2)

self.table_frame.pack(fill="x", expand=True)

# Current credits
self.credits_label = ttk.Label(self, text=actions.get_credits())
self.credits_label.place(relx=1, rely=1, anchor="se")


class SellEquipment(Screen):

Expand Down
15 changes: 15 additions & 0 deletions src/ui_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,21 @@ def buy_ship():
pass


def get_equip_sold() -> list[str]:
# Make an list of equipment sold by the current system, with 'x' for ones not sold
current_system_tech = c.GAME["universe"].planets[c.GAME["commander"].currentSystem].tech_level
sold_equipment: list[tuple[str, str, str]] = []
for equips in [e.WEAPONS, e.SHIELDS, e.GADGETS]:
for _, equip in equips.items():
if equip.tech_level == e.TechLevel.UNAVAILABLE:
continue
elif equip.tech_level <= current_system_tech:
sold_equipment.append(("", equip.name, f"{equip.price} cr."))
else:
sold_equipment.append(("x", equip.name, "not sold"))
return sold_equipment


def buy_equipment():
pass

Expand Down

0 comments on commit e88a494

Please sign in to comment.