public int throwPotion(Creature target) { int result = 0; try { result = this.effect.activate(target); return result; } catch (EffectException e) { return result; } }
public int drinkPotion(Creature drinker) { int result = 0; try { result = this.effect.activate(drinker); return result; } catch (EffectException e) { return result; } }
public override int activate(Creature target) { if (this.duration > 0) this.duration--; if (target.health != 0) { int initialHealth = target.health; int health = initialHealth - this.magnitude; target.health = Math.Max(health, 0); int diff = initialHealth - health; return diff; } else return 0; }
public override int activate(Creature target) { if (this.duration > 0) this.duration--; if (target.health < target.maxHealth) { int initialHealth = target.health; target.health = Math.Min((initialHealth + magnitude), target.maxHealth); int diff = target.health - initialHealth; return diff; } else throw new EffectException("Target has full health already!"); }
public virtual int activate(Creature target) { //dummy method that should never be called return -5; }