def is_attackable(self, from_tile, from_pos, to_tile, to_pos): """ Returns whether the given tile is attackable. Override this for subclasses, perhaps using this as a default value. """ # We can only attack within the unit's range. if not self.is_tile_in_range(from_tile, from_pos, to_pos): return False # Get the unit we're going to attack. u = BaseUnit.get_unit_at_pos(to_pos) # We can't attack if there's no unit there, if it's on our team, # if we can't hit this particular unit, or if the damage is 0 if (not u): return False if (u and u.team == self.team and self.can_hit(u) and from_pos != to_pos): return True return False
def is_passable(self, tile, pos): """ Returns whether or not this unit can move over a certain tile. """ # Return default if not super().is_passable(tile, pos): return False # We can't pass through enemy air units. u = BaseUnit.get_unit_at_pos(pos) if u and u.team != self.team and isinstance(u, AirUnit): return False # Air units can pass over everything else return True
def is_passable(self, tile, pos): """ Returns whether or not this unit can move over a certain tile. """ # Return default if not super().is_passable(tile, pos): return False # We can't pass through enemy units. u = BaseUnit.get_unit_at_pos(pos) if u and u.team != self.team and isinstance(u, WaterUnit): return False # ground units can't travel over water. if tile.type != "water": return False return True
def is_passable(self, tile, pos): """ Returns whether or not this unit can move over a certain tile. """ # Return default if not super().is_passable(tile, pos): return False # We can't pass through enemy units. u = BaseUnit.get_unit_at_pos(pos) if u and u.team != self.team and isinstance(u, GroundUnit): return False #ground units can't travel over water or through walls if (tile.type == 'water' or tile.type == 'wall'): return False return True