Exemplo n.º 1
0
        public static Hero enemyAttack(Hero hero, Enemy enemy, Random rand)
        {
            int enemyAttackChance = rand.Next(0, enemy.Accuracy * 2);
            int heroDodgeChance   = rand.Next(0, (int)Math.Round((double)hero.Dexterity / 2));

            if (enemyAttackChance > heroDodgeChance)
            {
                EquipmentBusiness eq = new EquipmentBusiness();
                HeroBusiness      hb = new HeroBusiness();

                int heroDefencePoints = 0;
                if (eq.GetEquipedByIdAndType(hero.Id, "Armor") != null)
                {
                    heroDefencePoints = (int)eq.GetEquipedByIdAndType(hero.Id, "Armor").Points;
                }

                if (enemy.Strength * 2 - heroDefencePoints > 0)
                {
                    hero.CurrentHealthPoints -= enemy.Strength * 2 - heroDefencePoints;
                    Console.WriteLine(enemy.Name.Trim() + " deals " + (enemy.Strength * 2 - heroDefencePoints) + " damage to " + hero.Name.Trim() + "!");
                    hb.Update(hero);
                }
                else
                {
                    Console.WriteLine(enemy.Name.Trim() + " can't penetrade " + hero.Name.Trim() + "'s armor!");
                }
            }
            else
            {
                Console.WriteLine(enemy.Name.Trim() + " misses!");
            }

            return(hero);
        }
Exemplo n.º 2
0
        public static void OpenInventory(Hero hero)
        {
            EquipmentBusiness eb = new EquipmentBusiness();

            Console.WriteLine("Inventory: ");
            List <Equipment> items = (eb.GetAllByOwnerId(hero.Id));

            if (items.Count == 0)
            {
                Console.WriteLine(" Empty");
            }

            for (int i = 0; i < items.Count; i++)
            {
                Console.Write(" " + (i + 1) + ") " + items[i].Name.Trim() + " " + items[i].Points);
                if (items[i].Is_equiped == true)
                {
                    Console.WriteLine(" -> Equiped");
                }
                else
                {
                    Console.WriteLine();
                }
            }
        }
Exemplo n.º 3
0
        public Equipment Add(Equipment equipment)
        {
            try
            {
                var equipmentBusiness = new EquipmentBusiness();
                return(equipmentBusiness.Add(equipment));
            }
            catch (Exception ex)
            {
                var httperror = new HttpResponseMessage()
                {
                    StatusCode   = (HttpStatusCode)422,
                    ReasonPhrase = ex.Message
                };

                throw new HttpResponseException(httperror);
            }
        }
Exemplo n.º 4
0
        public int CharacterSelectMenu()
        {
            HeroBusiness      heroBusiness      = new HeroBusiness();
            EquipmentBusiness equipmentBusiness = new EquipmentBusiness();
            List <HeroModel>  heros             = heroBusiness.GetAll();


            int i = 1;

            foreach (HeroModel hero in heros)
            {
                Console.WriteLine($"{i}: {hero.Name} / {hero.Char_level} level");
                i++;
            }

            Console.WriteLine("Please enter hero number to continue or (D)elete to delete hero");

            string command = Console.ReadLine();

            if (command == "d")
            {
                while (command == "d")
                {
                    Console.WriteLine("Which hero do you wish to delete? Input number.");
                    int deleteNumber = int.Parse(Console.ReadLine());
                    if (Utils.inArrayRange(heros.Count, (deleteNumber - 1)))
                    {
                        List <Equipment> itemsToDelete = equipmentBusiness.GetAllByOwnerId(heros[deleteNumber - 1].Id);
                        heroBusiness.Delete(heros[deleteNumber - 1].Id);
                        for (int j = 0; j < itemsToDelete.Count; j++)
                        {
                            equipmentBusiness.Delete(itemsToDelete[j].Id);
                        }
                    }
                    Console.WriteLine("Please enter hero number to continue or (D)elete to delete hero");
                    command = Console.ReadLine().ToLower();
                }
            }


            return(int.Parse(command));
        }
Exemplo n.º 5
0
        public List <Equipment> All()
        {
            try
            {
                var response          = new List <Equipment>();
                var equipmentBussines = new EquipmentBusiness();
                response = equipmentBussines.All();
                return(response);
            }
            catch (Exception ex)
            {
                var httperror = new HttpResponseMessage()
                {
                    StatusCode   = (HttpStatusCode)422,
                    ReasonPhrase = ex.Message
                };

                throw new HttpResponseException(httperror);
            }
        }
Exemplo n.º 6
0
        public EquipmentController(UserManager <ApplicationUser> userManager,
                                   IHttpContextAccessor httpContextAccessor,
                                   MardisContext mardisContext,
                                   ILogger <EquipmentController> logger,
                                   ILogger <ServicesFilterController> loggeFilter,
                                   IDataProtectionProvider protectorProvider,
                                   IMemoryCache memoryCache,
                                   RedisCache distributedCache, IHostingEnvironment envrnmt)
            : base(userManager, httpContextAccessor, mardisContext, logger)
        {
            _protector                        = protectorProvider.CreateProtector(GetType().FullName);
            _logger                           = logger;
            ControllerName                    = CTask.Controller;
            TableName                         = CTask.TableName;
            _taskCampaignBusiness             = new TaskCampaignBusiness(mardisContext, distributedCache);
            _statusTaskBusiness               = new StatusTaskBusiness(mardisContext, distributedCache);
            _taskNotImplementedReasonBusiness = new TaskNotImplementedReasonBusiness(mardisContext);
            _branchImageBusiness              = new BranchImageBusiness(mardisContext);
            _userBusiness                     = new UserBusiness(mardisContext);
            _questionBusiness                 = new QuestionBusiness(mardisContext);
            _questionDetailBusiness           = new QuestionDetailBusiness(mardisContext);
            _cache = memoryCache;

            _equipmentBusiness        = new EquipmentBusiness(mardisContext);
            _equipamentImagesBusiness = new EquipamentImagesBusiness(mardisContext);
            _equipament_timeBusiness  = new Equipament_timeBusiness(mardisContext);
            _Env = envrnmt;
            if (ApplicationUserCurrent.UserId != null)
            {
                _userId          = new Guid(ApplicationUserCurrent.UserId);
                Global.UserID    = _userId;
                Global.AccountId = ApplicationUserCurrent.AccountId;
                Global.ProfileId = ApplicationUserCurrent.ProfileId;
                Global.PersonId  = ApplicationUserCurrent.PersonId;
            }

            _idAccount = ApplicationUserCurrent.AccountId;
        }
Exemplo n.º 7
0
        private static Enemy heroAttack(Enemy enemy, Hero hero, Random rand)
        {
            int heroAttackChance = rand.Next(0, hero.Accuracy * 2);
            int enemyDodgeChance = rand.Next(0, (int)Math.Ceiling((double)enemy.Dexterity / 2));

            if (heroAttackChance > enemyDodgeChance)
            {
                EquipmentBusiness eq = new EquipmentBusiness();

                int heroAttackPoints = hero.Strength;
                if (eq.GetEquipedByIdAndType(hero.Id, "Weapon") != null)
                {
                    heroAttackPoints += (int)eq.GetEquipedByIdAndType(hero.Id, "Weapon").Points;
                }

                enemy.CurrentHealthPoints -= heroAttackPoints;
                Console.WriteLine(hero.Name.Trim() + " deals " + heroAttackPoints + " damage to " + enemy.Name.Trim() + "!");
            }
            else
            {
                Console.WriteLine(hero.Name.Trim() + " misses!");
            }
            return(enemy);
        }
Exemplo n.º 8
0
 /// <summary>
 /// 用户设备访问服务类
 /// </summary>
 public EquipmentService() : base(BusinessFactory <EquipmentBusiness> .Instance)
 {
     this.bl = this.baseBL as EquipmentBusiness;
 }
Exemplo n.º 9
0
 public Forge()
 {
     eb = new EquipmentBusiness();
     hb = new HeroBusiness();
 }