heal.lua 529 B

12345678910111213141516171819202122232425
  1. local heal = lib.object:new():include(lib.ability)
  2. heal.cost = 1
  3. heal.amount = 1
  4. function heal:canCast(owner)
  5. return owner == app.context.objects.muju and owner.juju >= self.cost
  6. end
  7. function heal:cast(owner, x, y)
  8. local entity = lib.target.objectAtPosition(x, y)
  9. if entity and entity.isMinion and entity.health < entity.config.maxHealth then
  10. if owner.juju < self.cost then return false end
  11. owner:spendJuju(self.cost)
  12. entity:heal(self.amount, owner)
  13. return true
  14. end
  15. return false
  16. end
  17. return heal