Add Planets, Items, TradeHubs, tradehubs menu
This commit is contained in:
parent
74244d953e
commit
13eb7979e9
91
main.py
91
main.py
@ -1,6 +1,7 @@
|
||||
import os
|
||||
|
||||
PLAYER_INIT_LOCATION = "1"
|
||||
PLAYER_INIT_LOCATION = "BoB"
|
||||
|
||||
class Player:
|
||||
|
||||
def __init__(self, name, location):
|
||||
@ -19,9 +20,10 @@ class Player:
|
||||
class GameManager:
|
||||
'Manage the game'
|
||||
|
||||
def __init__(self, userInput):
|
||||
def __init__(self, userInput, planets):
|
||||
self.gameIsRunning = True
|
||||
self.player = Player(userInput, PLAYER_INIT_LOCATION)
|
||||
self.planets = planets
|
||||
|
||||
def isGameRunning(self):
|
||||
return self.gameIsRunning
|
||||
@ -34,6 +36,52 @@ class GameManager:
|
||||
print("Location: ", self.player.getLocation())
|
||||
print()
|
||||
|
||||
def enterTradeHub(self):
|
||||
while True:
|
||||
userInput = input("(l)ist items (e)xit\n>> ").lower()
|
||||
|
||||
if userInput == 'e':
|
||||
break;
|
||||
|
||||
if userInput == 'l':
|
||||
self.planets[self.player.getLocation()].getTradeHub().printItems()
|
||||
|
||||
class Planet:
|
||||
'Contains trade hub'
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
def addTradeHub(self, tradeHub):
|
||||
self.tradeHub = tradeHub
|
||||
def getTradeHub(self):
|
||||
return self.tradeHub
|
||||
def getName(self):
|
||||
return self.name
|
||||
|
||||
class TradeHub:
|
||||
'Contains items to sell'
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
def addItems(self, items):
|
||||
self.items = items
|
||||
def getItems(self):
|
||||
return self.items
|
||||
def printItems(self):
|
||||
for item in self.items.values():
|
||||
print("Name:", item.getName())
|
||||
print("Cost:",item.getPrice())
|
||||
print()
|
||||
|
||||
class Item:
|
||||
'items to buy/sell'
|
||||
def __init__(self, name, price):
|
||||
self.name = name
|
||||
self.price = price
|
||||
|
||||
def getName(self):
|
||||
return self.name
|
||||
def getPrice(self):
|
||||
return self.price
|
||||
|
||||
|
||||
def clearScreen():
|
||||
os.system('clear')
|
||||
@ -51,19 +99,50 @@ def titleScreen():
|
||||
mainGame()
|
||||
|
||||
def mainGame():
|
||||
tradeableItems = {
|
||||
"flour" : Item("flour", 0.5),
|
||||
"Rice Cakes" : Item("Rice Cakes", 1),
|
||||
"Water" : Item("Water", 25)
|
||||
}
|
||||
|
||||
#Create TradeHubs
|
||||
tradeHubs = {
|
||||
"The Jackel" : TradeHub("The Jackel"),
|
||||
"Star Crapper" : TradeHub("Star Crapper")
|
||||
}
|
||||
|
||||
tradeHubs["The Jackel"].addItems(tradeableItems)
|
||||
|
||||
|
||||
tradeableItems.pop("flour")
|
||||
|
||||
tradeHubs["Star Crapper"].addItems(tradeableItems)
|
||||
|
||||
# Create Planets
|
||||
planets = {
|
||||
"BoB" : Planet("BoB"),
|
||||
"Luna" : Planet("Luna")
|
||||
}
|
||||
planets["BoB"].addTradeHub(tradeHubs["Star Crapper"])
|
||||
|
||||
planetLuna = Planet("Luna")
|
||||
planetLuna.addTradeHub(tradeHubs["The Jackel"])
|
||||
|
||||
# Create user
|
||||
userInput = ""
|
||||
|
||||
userInput = input("What is your name... peasant?")
|
||||
userInput = input("What is your name... peasant?\n>> ")
|
||||
|
||||
if userInput == "":
|
||||
userInput = "(none)"
|
||||
|
||||
Game = GameManager(userInput)
|
||||
# Start Game
|
||||
Game = GameManager(userInput, planets)
|
||||
|
||||
clearScreen()
|
||||
|
||||
while Game.isGameRunning():
|
||||
userInput = input("(q)uit (p)layer stats (c)lear screen:\n>> ").lower()
|
||||
userInput = input("(q)uit (p)layer stats (e)nter trade hub (c)lear screen:\n>> ").lower()
|
||||
|
||||
if userInput == "q":
|
||||
Game.stopGame()
|
||||
@ -73,6 +152,8 @@ def mainGame():
|
||||
|
||||
if userInput == "c":
|
||||
clearScreen()
|
||||
if userInput == "e":
|
||||
Game.enterTradeHub()
|
||||
|
||||
def main():
|
||||
titleScreen()
|
||||
|
Loading…
x
Reference in New Issue
Block a user