Beispiel #1
0
        private Unit unitFight(Unit unitAttack, Unit unitDeff)
        {
            unitSizeDownNow = 0;
            hpDoneNow       = 0;
            MockUnitType unitEnum   = new MockUnitType();
            List <Unit>  unitList   = (List <Unit>)unitEnum.getUnitsType();
            double       totalMaxHP = unitList.Find(u => u.name == unitDeff.name).hp;

            for (int i = 0; i < unitAttack.size; i++)
            {
                if (unitDeff.hp - unitAttack.dmg <= 0)
                {
                    double hpLeft = unitAttack.dmg - unitDeff.hp;
                    unitDeff.sizeDown(1);
                    unitSizeDownNow++;
                    unitDeff.hp = totalMaxHP - hpLeft;
                }
                else
                {
                    unitDeff.hp = unitDeff.hp - unitAttack.dmg;
                }
            }
            hpDoneNow = totalMaxHP - unitDeff.hp;
            return(unitDeff);
        }
Beispiel #2
0
        public async Task <IActionResult> addUnitToHeroT(int heroId, int unitTypeId, int unitSize)
        {
            MockUnitType mockUnitType = new MockUnitType();
            Unit         unitTemp     = mockUnitType.getUnitTypeById(unitTypeId);
            var          heroItem     = await _context.heroList.FindAsync(heroId);

            List <Unit> heroUnits = new List <Unit>();

            heroUnits.Add(new Unit
            {
                size  = unitSize,
                name  = unitTemp.name,
                race  = unitTemp.race,
                hp    = unitTemp.hp,
                mana  = unitTemp.mana,
                dmg   = unitTemp.dmg,
                range = unitTemp.range
            });
            heroItem.units = heroUnits;

            await _context.SaveChangesAsync();

            return(NoContent());
        }
Beispiel #3
0
 public MockUnitTypeController(ILogger <MockUnitTypeController> logger, MockUnitType context)
 {
     _logger  = logger;
     _context = context;
 }