def validMoves(self, position): """returns positions of valid moves for a regular red gamepiece on an empty board""" moves = [] if Engine.isOnTopRow(position): moves = [] elif Engine.isOnRightEdge(position) or Engine.isOnLeftEdge(position): # Edges only have one valid move moves = [position - 4] elif Engine.isOnOddRow(position): # diagonals above pieces on odd rows are always 4 and 5 pieces after moves = [position - 4, position - 3] elif Engine.isOnEvenRow(position): # diagonals below pieces on even rows are always 3 and 4 piececs after moves = [position - 5, position - 4] return moves
def canBePromoted(self, position): return Engine.isOnTopRow(position) """Red Pieces can be promoted when they're on the top row"""
def test_isOnTopRow_returnsFalse_forNonTopsRows(self, value): self.assertFalse(Engine.isOnTopRow(value))
def test_isOnTopRow_returnsTrue_forTopRow(self, value): self.assertTrue(Engine.isOnTopRow(value))