def can_use(self, target=None, **kwargs): if not super(RepairAbility, self).can_use(target, **kwargs): return False if vectors.distance(self.actor.pos, target.pos) > self.max_range: return False if self.min_range > 0: if vectors.distance(self.actor.pos, target.pos) < self.min_range: return False if self.actor.team != target.team: return False # Is the ally still under construction? if target.completion < 100: return False # Is the ally hurt? if target.hp >= target.max_hp: return False # Finally, can we afford it? cost = teams.multiply_cost(target._part_repair_cost, self.repair_rate) if not self.actor.team_obj.can_afford(cost): return False return True
def use(self, target): target.hp += (self.repair_rate * target.repair_rate) self.generate_effect(target) cost = teams.multiply_cost(target._part_repair_cost, self.repair_rate) if target.hp > target.max_hp: # TODO Give back any leftover cost to the parent team target.hp = target.max_hp self.actor.team_obj.spend(cost) self.charge = 0
def use(self, target): # Just incase there are multiple sources building it # we don't want to run "next_order" several times if target.completion >= 100: return target.completion += (self.construction_rate * target.construction_rate) target.hp += (self.construction_rate * target.construction_heal_rate) self.generate_effect(target) cost = teams.multiply_cost(target._part_construction_cost, self.construction_rate) if target.completion >= 100: if target.current_order == ["stop", -1, -1]: target.next_order() # TODO Give back any leftover cost to the parent team self.actor.team_obj.spend(cost) self.charge = 0