protected void ValidateAlive(IMilitantGroup group) { if (group.Health <= 0) { throw new MilitanGroupsException(Messages.GroupDestroyed); } }
private void ProcessAttack(IMilitantGroup attacker, IMilitantGroup target) { this.ValidateAlive(attacker); this.ValidateAlive(target); var attack = attacker.Attack; if (attack.GetType().Name == "SU24") { attacker.Health -= attacker.Health / 2; if (attacker.Health <= 0) { attacker.Health = 0; } } target.RespondToAttack(attack); Console.WriteLine(Messages.AttackGroup, attacker.Name, target.Name); //Group Petya toggled Jihad if (target.Health <= 0) { target.Health = 0; Console.WriteLine(Messages.GroupDestroyed, target.Name); //Group Petya was killed } }
public virtual void Attack(IMilitantGroup group) { if (group == null) { throw new ArgumentNullException(nameof(group), "Invalid target!"); } if (group.Name == this.Name) { throw new ArgumentException(nameof(this.Name), "Cannot attack itself!"); } int damage = this.Damage; if (this.AttackType == AttackType.SU24) { damage *= SU24AttackMultiplier; this.Health = (int)Math.Ceiling((double)this.Health / SU24SelfHealthDevisor); } int attackedGroupHP = group.Health; if (attackedGroupHP - damage <= 0 && group.WarEffectHasTriggered == false) { group.Health = 0; group.Update(); group.HasUpdated = true; } else { group.Health -= damage; } if (group.Health < 0) { group.IsAlive = false; } }
public abstract void Hit(IMilitantGroup targetGroup);
//protected WarEffect(IMilitantGroup group) //{ // this.Group = group; //} //public IMilitantGroup Group { get; set; } public abstract void TriggerEffect(IMilitantGroup group);
public override void Hit(IMilitantGroup targetGroup) { //this.Group.Health -= this.Group.Health/2; targetGroup.Health -= this.Damage * 2; }
public override void Hit(IMilitantGroup targetGroup) { targetGroup.Health -= this.Damage; }
//public Jihad(IMilitantGroup group) : base(group) //{ //} //public override void TriggerEffect() //{ // this.Group.Damage *= 2; //} public override void TriggerEffect(IMilitantGroup group) { group.Damage *= 2; }
//public Kamikaze(IMilitantGroup group) : base(group) //{ //} //public override void TriggerEffect() //{ // this.Group.Health += 50; //} public override void TriggerEffect(IMilitantGroup group) { group.Health += 50; }