Exemple #1
0
 def isValid( self, grid, point ):
     """ A brick cannot be placed adjacent to any piece. """
     if not super( Brick, self ).isValid( grid, point ):
         return False
     if( grid.isAnyTokenAtPointInList( adjacentPoints( point ) ) ):
         return False
     return True 
Exemple #2
0
 def isValid( self, grid, point ):
     if not super( Glob, self ).isValid( grid, point ):
         return False
     if not self.existsOnTheBoard( grid ): 
         return True
     if self.atPointInList( grid, adjacentPoints( point ) ):
         return True
Exemple #3
0
 def isValid( self, grid, point ):
     """ A king cannot be placed adjacent to any other piece, nor can any other piece be placed adjacent to a king."""
     if not super( King, self ).isValid( grid, point ):
         return False
     if( grid.isAnyTokenAtPointInList( adjacentPoints( point ) ) ):
         return False
     return True 
Exemple #4
0
    def afterPlacement( self, grid, point ):
        """ Called after the token is placed at a point. """
        super( Bomb, self ).afterPlacement( grid, point ) 
        points = adjacentPoints( point )
        for point in points:
            grid.clearToken( point )

        return self
Exemple #5
0
    def isValid( self, grid, point ):
        """ Takes a grid object and a tuple point (x, y) """
        
        # No token may be placed next to a King
        adjacent_points = adjacentPoints( point )
        if( grid.isTokenAtPointInList( King(), adjacent_points) ):
            return False

        return True
Exemple #6
0
    def afterPlacement( self, grid, point ):
        """ Called after the token is placed at a point. """
        super(Brick, self).afterPlacement( grid, point ) 
       
        points = adjacentPoints( point )
        for brick_point in points:
            x,y = brick_point
            grid.setToken( Brick(), (x,y) )

        return self
Exemple #7
0
    def isValid( self, grid, point ):
        """ A parasite can be adjacent to any token but not another parasite. """
        if not super( Parasite, self ).isValid( grid, point ):
            return False
        
        if not self.existsOnTheBoard( grid ): 
            return True
        
        adjacent_points = adjacentPoints( point ) 

        if grid.isAnyTokenAtPointInList( adjacent_points ) and not self.atPointInList( grid, adjacent_points ):
            return True
        else:
            return False
Exemple #8
0
    def isValid( self, grid, point ):
        """ A crowd must be placed adjacent to 5 or more pieces. """
        if not super( Crowd, self ).isValid( grid, point ):
            return False
        
        points = adjacentPoints( point )
        
        counter = 0 
        for adjacentPoint in points:
            if grid.isAnyTokenAtPoint( adjacentPoint ):
                counter += 1

        if counter < 5: 
            return False
        return True