コード例 #1
0
        public CombatValues CalculateCombatValues(CombatValues currentRun, double Aim, double Graze, double CritChance, double TargetDodge)
        {
            Aim         = Aim / 100;
            Graze       = Graze / 100;
            CritChance  = CritChance / 100;
            TargetDodge = TargetDodge / 100;
            double MissChance = (1 - Aim + (Graze / 2));
            double HitChance  = Aim - (Graze / 2);

            currentRun.currentCritChance = HitChance * (CritChance * (1 - TargetDodge));
            currentRun.currentHitChance  = (HitChance * CritChance * TargetDodge) + ((HitChance * (1 - CritChance)) * (1 - TargetDodge)) + (Graze * (CritChance * (1 - TargetDodge)));
            currentRun.currentGraze      = HitChance * TargetDodge * (1 - CritChance) + (Graze * CritChance * TargetDodge) + (Graze * (1 - CritChance) * (1 - TargetDodge));
            currentRun.currentMiss       = MissChance + (Graze * TargetDodge * (1 - CritChance));

            return(currentRun);
        }
コード例 #2
0
        public CombatValues CrunchDamage(CombatValues currentRun, double hitChance, double critChance, double grazeChance, int lowDamage, int highDamage, int accuracy, int plusOneChance, int critDamage, int critRate)
        {
            int i = 0;

            currentRun.damageRolls = new List <float>();
            while (i < 50000)
            {
                Random rrr = new Random();

                float currentDamage = rrr.Next(lowDamage, highDamage);
                int   hr            = rrr.Next(1, 100);
                int   pr            = rrr.Next(1, 100);
                float hitRoll       = (float)((float)hr / 100);
                float plusRoll      = (float)((float)pr / 100);
                if (plusRoll <= plusOneChance)
                {
                    currentDamage = currentDamage + 1;
                }
                if (hitRoll < grazeChance)
                {
                    currentRun.damageRolls.Add(currentDamage / 2);
                }
                else if (hitRoll > grazeChance && hitRoll < (grazeChance + hitChance))
                {
                    currentRun.damageRolls.Add(currentDamage);
                }
                else if (hitRoll > (grazeChance + hitChance) && hitRoll < ((grazeChance + hitChance + critChance)))
                {
                    float x = currentDamage + critDamage;
                    currentRun.damageRolls.Add(x);
                }
                else
                {
                    currentRun.damageRolls.Add(0);
                }
                i++;
            }
            currentRun.damageRolls.Sort();
            var result = currentRun.damageRolls.GroupBy(n => n)
                         .Select(c => new { Key = c.Key, total = c.Count() });

            return(currentRun);
        }
コード例 #3
0
        private void CalcButton_Click(object sender, RoutedEventArgs e)
        {
            Calculator cs = new Calculator();
            double     AimDubs, GrazeDub, CritDubs, DodgeDubs;
            int        LowDamageInt, HighDamageInt, PlusOneInt, CritDamageInt, CritBonusInt, AccuracyInt;

            double.TryParse(Aim.Text, out AimDubs);
            double.TryParse(Graze.Text, out GrazeDub);
            int.TryParse(LowDamage.Text, out LowDamageInt);
            int.TryParse(HighDamage.Text, out HighDamageInt);
            int.TryParse(PlusOne.Text, out PlusOneInt);
            int.TryParse(CritDamage.Text, out CritDamageInt);
            int.TryParse(CritRate.Text, out CritBonusInt);
            int.TryParse(Accuracy.Text, out AccuracyInt);
            double.TryParse(Crit.Text, out CritDubs);
            double.TryParse(Dodge.Text, out DodgeDubs);
            CombatValues currentCV = cs.CalculateCombatValues(new CombatValues(), AimDubs, GrazeDub, CritDubs, DodgeDubs);

            currentCV        = cs.CrunchDamage(currentCV, currentCV.currentHitChance, currentCV.currentCritChance, currentCV.currentGraze, LowDamageInt, HighDamageInt, AccuracyInt, PlusOneInt, CritDamageInt, CritBonusInt);
            ToHitChance.Text = (currentCV.currentHitChance * 100).ToString();
            CritChance.Text  = (currentCV.currentCritChance * 100).ToString();
            GrazeChance.Text = (currentCV.currentGraze * 100).ToString();
            MissChance.Text  = (currentCV.currentMiss * 100).ToString();
        }