// Map 4, 3, 2, 1, 2, 3, 4 => 0 -> 6
 int GetOddsIndex(OddsCalculation Odds)
 {
     if (Odds.TotalAttack > 36)
     {
         return(6);
     }
     if (Odds.TotalAttack > 26)
     {
         return(5);
     }
     if (Odds.TotalAttack > 20)
     {
         return(4);
     }
     if (Odds.TotalAttack > 16)
     {
         return(3);
     }
     if (Odds.TotalAttack > 12)
     {
         return(2);
     }
     if (Odds.TotalAttack > 8)
     {
         return(1);
     }
     return(0);
 }
 // Map 4, 3, 2, 1, 2, 3, 4 => 0 -> 6
 int GetOddsIndex(OddsCalculation Odds)
 {
     if (Odds.OddsAgainst)
     {
         return(4 - Odds.Odds);
     }
     return(2 + Odds.Odds);
 }
 public double[] GetCombatResultProbabilities(OddsCalculation Odds)
 {
     double[] p = new double[Enum.GetValues(typeof(CombatResult)).Length];
     for (int i = 0; i < 6; ++i)
     {
         p[(int)GetCombatResult(Odds, i)] += 1f / 6;
     }
     return(p);
 }
Esempio n. 4
0
        string OddsString(OddsCalculation OddsCalculation)
        {
            var dieModifier =
                string.Format(
                    "{0} {1}", OddsCalculation.DieModifier < 0 ? "-" : "+", Math.Abs(OddsCalculation.DieModifier));

            if (OddsCalculation.OddsAgainst)
            {
                return(string.Format("Attack at 1-{0} {1} against", OddsCalculation.Odds, dieModifier));
            }
            return(string.Format("Attack at {0}-1 {1} for", OddsCalculation.Odds, dieModifier));
        }
Esempio n. 5
0
        void DescribeOddsCalculation(OddsCalculation OddsCalculation)
        {
            _Description.Add(new Button("attack-odds-box")
            {
                DisplayedString = OddsString(OddsCalculation)
            });

            var p = Attack.CombatResultsTable.GetCombatResultProbabilities(OddsCalculation);

            for (int i = 0; i < p.Length; ++i)
            {
                if (p[i] > 0)
                {
                    _Description.Add(new Button("attack-factor-box")
                    {
                        DisplayedString = string.Format(
                            "{0} - {1}%", ObjectDescriber.Describe((CombatResult)i), Math.Round(p[i] * 100))
                    });
                }
            }

            _Description.Add(new Button("attack-odds-section")
            {
                DisplayedString = string.Format("{0} Total Attack Factor", OddsCalculation.TotalAttack)
            });
            foreach (var a in OddsCalculation.AttackFactorCalculations)
            {
                DescribeAttackFactorCalculation(a.Item1, a.Item2);
            }
            _Description.Add(new Button("attack-odds-section")
            {
                DisplayedString = string.Format("{0} Total Defense Factor", OddsCalculation.TotalDefense)
            });
            foreach (Unit d in OddsCalculation.Defenders)
            {
                _Description.Add(new Button("attack-part-box")
                {
                    DisplayedString = string.Format("+{0} {1}", d.Configuration.Defense, d.Configuration.Name)
                });
            }
            _Description.Add(new Button("odds-factor-box")
            {
                DisplayedString = OddsCalculation.StackArmored ? "Armored Target" : "Unarmored Target"
            });
            foreach (OddsCalculationFactor o in OddsCalculation.OddsCalculationFactors)
            {
                _Description.Add(new Button("odds-factor-box")
                {
                    DisplayedString = ObjectDescriber.Describe(o)
                });
            }
        }
 public override CombatResult GetCombatResult(OddsCalculation Odds, int Roll)
 {
     return(STANDARD_CRT_RESULTS[GetOddsIndex(Odds), Roll + Odds.DieModifier + 2]);
 }
 public abstract CombatResult GetCombatResult(OddsCalculation Odds, int Roll);
 public override CombatResult GetCombatResult(OddsCalculation Odds, int Roll)
 {
     return(AA_CRT_RESULTS[GetOddsIndex(Odds), Roll]);
 }