def validMoves( self, squares ): moves = [] for i in DIRECTIONS: newmoves = square.line( squares, self.pos, i , False ) if( len(newmoves) > 1 ): if not self._isOppositeSide( squares[newmoves[-1]] ): # remove last square becaues it is an allie newmoves = newmoves[0:-1] elif( len(newmoves) == 1 ): if not self._isOppositeSide( squares[newmoves[0]] ): newmoves = [] moves.extend( newmoves ) return moves
def validMoves( self, squares ): moves = [] for i in STRAIGHT_DIR: newmoves = square.line( squares, self.pos, i , False ) if( len(newmoves) > 1 ): if not self._isOppositeSide( squares[newmoves[-1]] ): # remove last square becaues it is an allie newmoves = newmoves[0:-1] elif( len(newmoves) == 1 ): if not self._isOppositeSide( squares[newmoves[0]] ): # the only move is to a square containing an allie newmoves = [] moves.extend( newmoves ) return moves
def squaresAttacked( self, squares ): attackedSquares = [] for i in DIRECTIONS: newSqrs = square.line( squares, self.pos, i , True ) attackedSquares.extend( newSqrs ) return attackedSquares
def squaresAttacked( self, squares ): attackedSquares = [] for i in STRAIGHT_DIR: newSqrs = square.line( squares, self.pos, i , True ) attackedSquares.extend( newSqrs ) return attackedSquares