Compare commits
2 Commits
13eb7979e9
...
c58efad369
Author | SHA1 | Date | |
---|---|---|---|
c58efad369 | |||
d183c57d18 |
35
main.py
35
main.py
@ -1,6 +1,6 @@
|
||||
import os
|
||||
|
||||
PLAYER_INIT_LOCATION = "BoB"
|
||||
PLAYER_INIT_LOCATION = "Luna"
|
||||
|
||||
class Player:
|
||||
|
||||
@ -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,9 +72,10 @@ class TradeHub:
|
||||
def getItems(self):
|
||||
return self.items
|
||||
def printItems(self):
|
||||
print(f"{'Name' : <15}{'- - - - - | - - - - -' : ^10}{'Cost' : >6}")
|
||||
print()
|
||||
for item in self.items.values():
|
||||
print("Name:", item.getName())
|
||||
print("Cost:",item.getPrice())
|
||||
print(f"{item.getName() : <15}{'* * * * * | * * * * *' : ^10}{str(item.getPrice()) : >5}")
|
||||
print()
|
||||
|
||||
class Item:
|
||||
@ -82,7 +89,6 @@ class Item:
|
||||
def getPrice(self):
|
||||
return self.price
|
||||
|
||||
|
||||
def clearScreen():
|
||||
os.system('clear')
|
||||
|
||||
@ -90,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
|
||||
@ -99,6 +105,7 @@ def titleScreen():
|
||||
mainGame()
|
||||
|
||||
def mainGame():
|
||||
clearScreen()
|
||||
tradeableItems = {
|
||||
"flour" : Item("flour", 0.5),
|
||||
"Rice Cakes" : Item("Rice Cakes", 1),
|
||||
@ -124,9 +131,8 @@ def mainGame():
|
||||
"Luna" : Planet("Luna")
|
||||
}
|
||||
planets["BoB"].addTradeHub(tradeHubs["Star Crapper"])
|
||||
planets["Luna"].addTradeHub(tradeHubs["The Jackel"])
|
||||
|
||||
planetLuna = Planet("Luna")
|
||||
planetLuna.addTradeHub(tradeHubs["The Jackel"])
|
||||
|
||||
# Create user
|
||||
userInput = ""
|
||||
@ -142,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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user