def randomizePosition(self,maxlimit): self.cells = [] self.startCell = Utils.getRandomPosition(maxlimit) self.orientation = Utils.getRandomOrientation() for i in range(self.size): relativePosition = self.startCell.getRelativePosition(i, self.orientation) cell = BoardCell.BoardCell(relativePosition.getRow(), relativePosition.getColumn(), True) self.cells.append(cell)
def testGameLogic(self): userA = User.User("testUserA") userB = User.User("testUserB") while(1): rocketPositionA=Utils.getRandomPosition(Utils.BOARDSIZE) userA.sendRocket(rocketPositionA, userB) if(userB.isDefeated()): break rocketPositionB=Utils.getRandomPosition(Utils.BOARDSIZE) userB.sendRocket(rocketPositionB, userA) if(userA.isDefeated()): break self.assertTrue(userA.isDefeated() or userB.isDefeated(), 'Game should have finished now')