public override ISpell GenerateAttack() { int damage = this.Unit.AttackPoints; int energyCost = 0; if (this.Unit.HealthPoints <= 80) { damage += (this.Unit.HealthPoints * 2); } if (this.Unit.HealthPoints > 50) { energyCost = 15; } ISpell spell = new Cleave(damage, energyCost); if (this.Unit.EnergyPoints < spell.EnergyCost) { throw new NotEnoughEnergyException(this.Unit.Name + " does not have enough energy to cast Cleave"); } else { this.Unit.EnergyPoints -= spell.EnergyCost; } return spell; }
public override ISpell GenerateAttack() { Spell spell = new Cleave(this.Unit); if (this.Unit.EnergyPoints - spell.EnergyCost < 0) { throw new NotEnoughEnergyException(string.Format(GlobalMessages.NotEnoughEnergy, this.Unit.Name, spell.GetType().Name)); } this.Unit.EnergyPoints -= spell.EnergyCost; return spell; }
public override ISpell GenerateAttack() { int damage = this.Unit.AttackPoints; if (this.Unit.HealthPoints <= DefaultHealthPoints) { damage += (this.Unit.HealthPoints*2); } var spell = new Cleave(damage); this.IsThereEnoughEnergy(spell); this.RemoveEnergyOnCast(spell); return spell; }
public override ISpell GenerateAttack() { int damage = this.Unit.AttackPoints; if (this.Unit.HealthPoints <= 80) { damage += this.Unit.HealthPoints * 2; } var attack = new Cleave(damage); if (this.Unit.HealthPoints > 50) { this.ValidateEnergy(attack); this.Unit.EnergyPoints -= attack.EnergyCost; } return attack; }
public override ISpell GenerateAttack() { var attack = new Cleave(this.AttackDamage); if (this.Unit.HealthPoints > 50) { if (this.Unit.EnergyPoints < attack.EnergyCost) { throw new NotEnoughEnergyException(string.Format( GlobalMessages.NotEnoughEnergy, this.Unit.Name, attack.GetType().Name)); } this.Unit.EnergyPoints -= attack.EnergyCost; } return attack; }
public override ISpell GenerateAttack() { var damage = this.Unit.AttackPoints; var health = this.Unit.HealthPoints; if (health <= 80) { damage += health * 2; } var spell = new Cleave(damage); if (this.Unit.EnergyPoints < spell.EnergyCost) { throw new NotEnoughEnergyException(string.Format(GlobalMessages.NotEnoughEnergy, this.Unit.Name, "Cleave")); } this.Unit.EnergyPoints -= spell.EnergyCost; return spell; }
public override ISpell GenerateAttack() { /////Cleave damage: Equals the warrior's attack points. /////If the warrior's health is equal or below 80, his health * 2 is added to the damage. //// If the warrior's health is greater than 50, it costs him energy - otherwise it doesn't. var damage = this.Unit.AttackPoints; if (this.Unit.HealthPoints <= 80) { damage += 2 * this.Unit.HealthPoints; } var spell = new Cleave(damage); this.ValidateEnergyPoints(this.Unit, spell); if (this.Unit.HealthPoints > 50) { this.Unit.EnergyPoints -= spell.EnergyCost; } return spell; }
public ISpell GenerateAttack() { var damage = this.Unit.AttackPoints; if (this.Unit.HealthPoints <= 80) { damage += 2 * this.Unit.HealthPoints; } var spell = new Cleave() {Damage = damage}; if (this.Unit.EnergyPoints < spell.EnergyCost) { throw new NotEnoughEnergyException( $"{this.Unit.Name} does not have enough energy to cast {this.GetType().Name}"); } if (this.Unit.HealthPoints > 50) { this.Unit.EnergyPoints -= spell.EnergyCost; } return spell; }
public override ISpell GenerateAttack() { ISpell spell = null; if (this.Unit.HealthPoints <= 80) { spell = new Cleave(this.Unit.AttackPoints + (this.Unit.HealthPoints*2)); } else { spell= new Cleave(this.Unit.AttackPoints); } if (this.Unit.HealthPoints > 50 && spell.EnergyCost > this.Unit.EnergyPoints) { throw new NotEnoughEnergyException(string.Format("{0} does not have enough energy to cast {1}", this.Unit.Name, spell.GetType().Name)); } if (this.Unit.HealthPoints > 50) { this.Unit.EnergyPoints -= spell.EnergyCost; } return spell; }
public override ISpell GenerateAttack() { int damage = this.Unit.AttackPoints; if (this.Unit.HealthPoints <= 80) { damage += 2 * this.Unit.HealthPoints; } ISpell attack = new Cleave(damage); if (this.Unit.EnergyPoints < attack.EnergyCost) { throw new NotEnoughEnergyException( string.Format(string.Format("{0}", GlobalMessages.NotEnoughEnergy) , this.Unit.Name, attack.GetType().Name)); } if (this.Unit.EnergyPoints > 50) { this.Unit.EnergyPoints -= attack.EnergyCost; } return attack; }
public override ISpell GenerateAttack() { int damege = this.Unit.AttackPoints; ISpell spell = null; if (this.Unit.HealthPoints <= 80) { spell = new Cleave((damege + (2 * this.Unit.HealthPoints))); } else { spell = new Cleave(damege); } if (this.Unit.HealthPoints > 50 && this.Unit.EnergyPoints >= spell.EnergyCost) { this.Unit.EnergyPoints -= spell.EnergyCost; return spell; } else if (this.Unit.HealthPoints < 50) { return spell; } throw new NotEnoughEnergyException(string.Format(Messages.NotEnoughEnergyException, this.Unit.Name, spell.GetType().Name)); }