class GridManager: # Constructor def __init__(self): self.__grid = Grid() self.__gamePlayer = GamePlayer() self.__userPlayer = UserPlayer() # Start Game def startGame(self): # Will continue toggling between # Game and User turns until the # Grid is Full (which is a loss) # or a 2048 tile is encountered # (which is a win) while (not self.__grid.gridContains(2048)): self.__gamePlayer.makeMove(self.__grid) self.__grid.printGrid() if (not self.__userPlayer.makeMove(self.__grid)): print "User Lost!" break if (self.__grid.gridContains(2048)): print "User Won!"
def __init__(self): self.__grid = Grid() self.__gamePlayer = GamePlayer() self.__userPlayer = UserPlayer()
def testValidUserInput(self): for s in ('s','p','r','S','P','R'): with mock.patch('builtins.input',return_value=s): r = UserPlayer().askInput() self.assertEqual(r,s.lower())
def initGame(self): self.player = UserPlayer().askInput() self.aI = ComputerPlayer().generateInput() print('Your Input is: %s' %self.player) print("Computer's input is: %s" %self.aI) self.checkWinner()