Esempio n. 1
0
        // TODO: I'm dumb when it comes to probability calculations, so I'm doing
        // this the brute force way. Gotta be a cleaner method, I just don't know it.
        public float ChanceToBlockHeroRun(DWHero hero, bool isBackAttackCheck = false)
        {
            float runFactor = isBackAttackCheck ? 0.25f : runGroupFactor;

            int[] heroArray = Enumerable
                              .Range(0, 255)
                              .Select(x => x * hero.Agility.Value)
                              .ToArray();
            int[] enemyArray = Enumerable
                               .Range(0, 255)
                               .Select(x => (int)Math.Floor(x * Agility * runFactor))
                               .ToArray();

            int enemyWin = 0;

            for (int i = 0; i < heroArray.Length; i++)
            {
                for (int j = 0; j < enemyArray.Length; j++)
                {
                    if (heroArray[i] < enemyArray[j])
                    {
                        enemyWin++;
                    }
                }
            }
            return(enemyWin / (float)(heroArray.Length * enemyArray.Length));
        }
Esempio n. 2
0
 public int[] DamageTakenRange(DWHero hero)
 {
     return(new int[2]
     {
         (hero.AttackPower.Value - (Agility / 2)) / 4,
         (hero.AttackPower.Value - (Agility / 2)) / 2
     });
 }
Esempio n. 3
0
 public int[] DamageDealtRange(DWHero hero)
 {
     if (IsDefenseBroken(hero))
     {
         return(new int[2]
         {
             0,
             (Strength + 4) / 6
         });
     }
     else
     {
         return(new int[2]
         {
             (Strength - (hero.DefensePower.Value / 2)) / 4,
             (Strength - (hero.DefensePower.Value / 2)) / 2
         });
     }
 }
Esempio n. 4
0
        public string[,] GetBattleInfo(DWHero hero)
        {
            int[] damageDealt = DamageDealtRange(hero);
            int[] damageTaken = DamageTakenRange(hero);

            return(new string[20, 2]
            {
                // info
                { Name, "" },
                { "HP", HP[0] == HP[1] ? HP[0].ToString() : HP[0] + "-" + HP[1] },
                { "ST", Strength.ToString() },
                { "AG", Agility.ToString() },
                { "E", XP.ToString() },
                { "G", Gold.ToString() },

                // attack
                { "MELEE:", "" },
                { "enemy dmg", damageDealt[0] + "-" + damageDealt[1] },
                { "hero dmg", damageTaken[0] + "-" + damageTaken[1] },
                { "", "" },

                // skills
                { "SKILLS:", "" },
                { Skill1, Math.Floor(Skill1Chance * 100).ToString() + "%" },
                { Skill2, Math.Floor(Skill2Chance * 100).ToString() + "%" },
                { "", "" },

                // defense
                { "CHANCE:", "" },
                { "HURT", Math.Floor((1f - HurtResist) * 100).ToString() + "%" },
                { "SLEEP", Math.Floor((1f - SleepResist) * 100).ToString() + "%" },
                { "STOPSPELL", Math.Floor((1f - StopspellResist) * 100).ToString() + "%" },
                { "dodge", Math.Floor(Evasion * 100).ToString() + "%" },
                { "run", Math.Floor((1f - ChanceToBlockHeroRun(hero)) * 100).ToString() + "%" },
            });
        }
Esempio n. 5
0
 public bool IsDefenseBroken(DWHero hero)
 {
     return(hero.DefensePower.Value >= Strength);
 }
Esempio n. 6
0
 public float ChanceToBackAttack(DWHero hero)
 {
     return(ChanceToBlockHeroRun(hero, true));
 }
Esempio n. 7
0
 public bool Run25DueToHeroStrength(DWHero hero)
 {
     return(Strength * 2 <= hero.Strength.Value);
 }