def gameStub(self): print("Welcome to {} Engine Stub".format(self.getGame())) if not db.isConnected(): db.connectDB("../db/gamelog.db") playersOrder = [] validPlayers = db.getPlayerNicks() maxPlayers = self.getGameMaxPlayers() nplayers = readInput( "Number of players: ", int, lambda x: x >= 2 and x <= maxPlayers, "Sorry, number of players must be between 2 and {}.".format(self.getGameMaxPlayers()), ) for i in range(1, nplayers + 1): print("Player {} Info:".format(i)) nick = readInput("Nick: ", str, lambda x: x in validPlayers, "Sorry, player not found in DB") self.addPlayer(nick) playersOrder.append(nick) self.begin() option = readInput("Dealing policy[0:None/1:RoundRobin/2:Winner]: ", int, lambda x: x in [0, 1, 2]) if option == 0: self.setDealingPolicy(RoundGameEngine.NoDealer) elif option == 1: self.setDealingPolicy(RoundGameEngine.RRDealer) elif option == 2: self.setDealingPolicy(RoundGameEngine.WinnerDealer) self.extraStubConfig() self.runStubRoundLoop()
def __init__(self, parent=None): super(NewPlayerDialog, self).__init__(parent) self.initUI() self.setWindowTitle(i18n( "NewPlayerDialog", "New Player")) self.existingplayers = [str(nick).lower() for nick in db.getPlayerNicks()]