public void AttackPlayerUnit(WarUnit defender, int damage, WarUnit attacker, int counterDamage) { int unitsToRemoveFromDefender = damage / defender.GetDefaultHeаlth(); int remainingDamageToDefender = damage - (defender.GetDefaultHeаlth() * unitsToRemoveFromDefender); unitsToRemoveFromDefender += defender.DecreaseHealth(remainingDamageToDefender); this.supportRemoveKilledUnitsFromPlayerArmy.Enqueue(new KeyValuePair <WarUnit, decimal>(defender, unitsToRemoveFromDefender)); // counter-attack if (!attacker.AmIArcherOrMage) { int unitsToRemoveFromAttacker = counterDamage / attacker.GetDefaultHeаlth(); int remainingDamageToAttacker = counterDamage - (unitsToRemoveFromAttacker * attacker.GetDefaultHeаlth()); unitsToRemoveFromAttacker += attacker.DecreaseHealth(remainingDamageToAttacker); this.supportRemoveKilledUnitsFromEnemyArmy.Enqueue(new KeyValuePair <WarUnit, decimal>(attacker, unitsToRemoveFromAttacker)); } }
private void AttackEnemyUnit(WarUnit player, int playerDamage, WarUnit enemy, int enemyDamage) { int unitsToRemoveFromDefender = playerDamage / enemy.GetDefaultHeаlth(); int remainingDamageToDefender = playerDamage - (enemy.GetDefaultHeаlth() * unitsToRemoveFromDefender); unitsToRemoveFromDefender += enemy.DecreaseHealth(remainingDamageToDefender); this.supportRemoveKilledUnitsFromEnemyArmy.Enqueue(new KeyValuePair <WarUnit, decimal>(enemy, unitsToRemoveFromDefender)); // counter-attack if (!player.AmIArcherOrMage) { int unitsToRemoveFromAttacker = enemyDamage / player.GetDefaultHeаlth(); int remainingDamageToAttacker = enemyDamage - (unitsToRemoveFromAttacker * player.GetDefaultHeаlth()); unitsToRemoveFromAttacker += player.DecreaseHealth(remainingDamageToAttacker); this.supportRemoveKilledUnitsFromPlayerArmy.Enqueue(new KeyValuePair <WarUnit, decimal>(player, unitsToRemoveFromAttacker)); } }