Pretty up the menus a bit

This commit is contained in:
Logen Kain 2021-05-10 19:27:43 -04:00
parent d183c57d18
commit c58efad369

27
main.py
View File

@ -32,19 +32,25 @@ class GameManager:
self.gameIsRunning = False
def printPlayerStats(self):
clearScreen()
print("Name: ", self.player.getName())
print("Location: ", self.player.getLocation())
print()
def enterTradeHub(self):
clearScreen()
while True:
userInput = input("(l)ist items (e)xit\n>> ").lower()
userInput = input("(e)xit\n\n(l)ist items\n>> ").lower()
if userInput == 'e':
clearScreen()
break;
if userInput == 'l':
elif userInput == 'l':
clearScreen()
self.planets[self.player.getLocation()].getTradeHub().printItems()
else:
clearScreen()
class Planet:
'Contains trade hub'
@ -66,7 +72,8 @@ class TradeHub:
def getItems(self):
return self.items
def printItems(self):
print(f"{'Name' : <15}{'* * * * * | * * * * *' : ^10}{'Cost' : >6}")
print(f"{'Name' : <15}{'- - - - - | - - - - -' : ^10}{'Cost' : >6}")
print()
for item in self.items.values():
print(f"{item.getName() : <15}{'* * * * * | * * * * *' : ^10}{str(item.getPrice()) : >5}")
print()
@ -89,7 +96,7 @@ def titleScreen():
while(True):
clearScreen()
print("Space Game Title To Be Disclosed!!!")
userInput = input("(n)ew game (q)uit:\n>> ").lower()
userInput = input("(n)ew game\n(q)uit:\n>> ").lower()
if userInput == "q":
break
@ -98,6 +105,7 @@ def titleScreen():
mainGame()
def mainGame():
clearScreen()
tradeableItems = {
"flour" : Item("flour", 0.5),
"Rice Cakes" : Item("Rice Cakes", 1),
@ -140,18 +148,21 @@ def mainGame():
clearScreen()
while Game.isGameRunning():
userInput = input("(q)uit (p)layer stats (e)nter trade hub (c)lear screen:\n>> ").lower()
userInput = ""
userInput = input("(q)uit\n\n(p)layer stats\n(e)nter trade hub\n(c)lear screen:\n>> ").lower()
if userInput == "q":
Game.stopGame()
if userInput == "p":
elif userInput == "p":
Game.printPlayerStats()
if userInput == "c":
elif userInput == "c":
clearScreen()
if userInput == "e":
elif userInput == "e":
Game.enterTradeHub()
else:
clearScreen()
def main():
titleScreen()