Esempio n. 1
0
        public void UnitAttack(int totalUnitAttack, BattleUnitDTO defendingUnit)
        {
            defendingUnit.Count = (defendingUnit.TotalUnitHealth - totalUnitAttack) / defendingUnit.SingleUnitHealth;

            if (totalUnitAttack - totalUnitAttack <= 0)
            {
                defendingUnit.Count = 0;
            }
        }
Esempio n. 2
0
        private static BattleUnitDTO SelectDefendingUnit(List <UnitType> attackPriority, BattleArmyDTO defenderArmy)
        {
            BattleUnitDTO defendingUnit = null;

            for (int i = 0; i < 4; i++)
            {
                defendingUnit = defenderArmy.Army.FirstOrDefault(x => x.Type == attackPriority[i] && x.Count > 0);
                if (defendingUnit != null)
                {
                    break;
                }
            }

            return(defendingUnit);
        }
Esempio n. 3
0
 private static void UpdateBattleReport(List <string> battleReport, BattleUnitDTO attackingUnit, BattleUnitDTO defendingUnit, ApplicationUser attacker, ApplicationUser defender)
 {
     battleReport.Add($"{attacker.Name}'s {attackingUnit.Type} attacked {defender.Name}'s {defendingUnit.Type} and did {attackingUnit.TotalUnitAttack} dmg!");
 }