def capture_building(self, b): pos = b.position self.destination = pos for p in self.positions: unit = getattr(self, p) if unit: if unit.position == pos: unit.capture(b) return else: unit.move(pos)
def capture_target(self, unit, building): if unit.is_capturing: return True for friend in self.my_units: if friend != unit: if friend.is_capturing and friend.position == building.position: return False if unit.position == building.position: unit.capture(building) else: unit.move(building.position) return True
def capture(self, unit): if unit.is_capturing: return True for building in unit.visible_buildings: if building.team == self.team: continue friend_capturing = False for friend in self.my_units: if friend != unit: if friend.is_capturing and friend.position == building.position: friend_capturing = True if friend_capturing: continue if unit.position == building.position: unit.capture(building) else: unit.move(building.position) return True