示例#1
0
        public async Task <IActionResult> HitAsync(int dragonId)
        {
            int    heroIdClaim = 0;
            bool   isHeroId    = GetAuthHeroId(ref heroIdClaim);
            Dragon dragon      = await _dragonService.GetDragonById(dragonId);

            Hero hero = await _heroService.GetHeroByIdAsync(heroIdClaim);

            if (hero == null || !isHeroId || dragon == null)
            {
                return(BadRequest(new { errorText = "Couldnt find a hero or a dragon" }));
            }
            //--------------------------
            int dragonHealtPointNow = await _hitService.HeroHitDragon(dragon, hero);

            return(Ok(dragonHealtPointNow));
        }