Add first elements for main input
This commit is contained in:
parent
4fd0987cda
commit
0000c38cee
56
main.py
56
main.py
@ -106,9 +106,14 @@ class Player:
|
|||||||
class Game:
|
class Game:
|
||||||
|
|
||||||
# initGame() is used to generate all data for a campaign and initialize status variables
|
# initGame() is used to generate all data for a campaign and initialize status variables
|
||||||
def initGame(self, playersNb):
|
def initGame(self):
|
||||||
self.years = 1865, 1868, 1871, 1874, 1877, 1880, 1883, 1886, 1889, 1892, 1895, 1898
|
self.years = 1865, 1868, 1871, 1874, 1877, 1880, 1883, 1886, 1889, 1892, 1895, 1898
|
||||||
|
|
||||||
|
playersNb = input("Enter the number of players (2-5): ")
|
||||||
|
while not playersNb.isdigit() or int(playersNb) not in range(2, 6):
|
||||||
|
playersNb = input("OUT OF RANGE! Enter the number of players (2-5): ")
|
||||||
|
playersNb = int(playersNb)
|
||||||
|
|
||||||
# Game status
|
# Game status
|
||||||
self.yearId = 0
|
self.yearId = 0
|
||||||
self.concession = False
|
self.concession = False
|
||||||
@ -146,23 +151,38 @@ class Game:
|
|||||||
savefile.write(jsonpickle.encode(self))
|
savefile.write(jsonpickle.encode(self))
|
||||||
savefile.close()
|
savefile.close()
|
||||||
|
|
||||||
def loadData():
|
def loadData(path):
|
||||||
with open('./savefile.json', 'r') as savefile:
|
with open('./' + path, 'r') as savefile:
|
||||||
content = savefile.read()
|
content = savefile.read()
|
||||||
data = jsonpickle.decode(content)
|
data = jsonpickle.decode(content)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
print("")
|
||||||
|
print("Ticket to Ride Legacy: Legends of the West")
|
||||||
|
print("")
|
||||||
|
choice = input("What do you want to do (new/load)? ")
|
||||||
|
while choice not in ("new", "load"):
|
||||||
|
choice = input("UNDEFINED! What do you want to do (new/load)? ")
|
||||||
|
if choice == "new":
|
||||||
|
myGame = Game()
|
||||||
|
myGame.initGame()
|
||||||
|
elif choice == "load":
|
||||||
|
path = input("Path to save file (defaults to savefile.json)? ")
|
||||||
|
if path == "":
|
||||||
|
path = "savefile.json"
|
||||||
|
myGame = loadData(path)
|
||||||
|
myGame.printStatus()
|
||||||
|
|
||||||
# TESTS
|
# TESTS
|
||||||
playersNb = 2
|
|
||||||
|
|
||||||
# Test of data generation
|
# Test of data generation
|
||||||
# myGame = Game()
|
# myGame = Game()
|
||||||
# myGame.initGame(playersNb)
|
# myGame.initGame()
|
||||||
# myGame.saveData()
|
# myGame.saveData()
|
||||||
|
|
||||||
# Test of data loading
|
# Test of data loading
|
||||||
# myGame = loadData()
|
# myGame = loadData('savefile.json')
|
||||||
# myGame.printStatus()
|
# myGame.printStatus()
|
||||||
|
|
||||||
# Test of ConcessionCard
|
# Test of ConcessionCard
|
||||||
@ -179,15 +199,15 @@ playersNb = 2
|
|||||||
# print("Remaining: " + str(cc.getRemainingPepites()))
|
# print("Remaining: " + str(cc.getRemainingPepites()))
|
||||||
|
|
||||||
# Test of Player
|
# Test of Player
|
||||||
myGame = Game()
|
# myGame = Game()
|
||||||
myGame.initGame(playersNb)
|
# myGame.initGame()
|
||||||
myGame.printStatus()
|
# myGame.printStatus()
|
||||||
myGame.treasure.enable()
|
# myGame.treasure.enable()
|
||||||
myGame.printStatus()
|
# myGame.printStatus()
|
||||||
myGame.treasure.takeTreasure()
|
# myGame.treasure.takeTreasure()
|
||||||
myGame.treasure.takeTreasure()
|
# myGame.treasure.takeTreasure()
|
||||||
myGame.treasure.takeTreasure()
|
# myGame.treasure.takeTreasure()
|
||||||
myGame.treasure.takeTreasure()
|
# myGame.treasure.takeTreasure()
|
||||||
myGame.printStatus()
|
# myGame.printStatus()
|
||||||
myGame.treasure.takeTreasure()
|
# myGame.treasure.takeTreasure()
|
||||||
myGame.printStatus()
|
# myGame.printStatus()
|
||||||
|
Loading…
Reference in New Issue
Block a user