Ejemplo n.º 1
0
    private Hit ComputeActualDamage(FightParameters parameters)
    {
        var crit         = false;
        var glance       = false;
        var missed       = false;
        var actualDamage = parameters.Damage;
        var didHit       = RollDice() < parameters.HitChance;

        if (!didHit)
        {
            actualDamage = 0;
            missed       = true;
        }
        else
        {
            var didCrit   = RollDice() < parameters.CritChance;
            var didGlance = RollDice() < parameters.GlanceChance;

            // Crits cannot also glance.
            if (didCrit)
            {
                crit          = true;
                actualDamage *= 2;
            }
            else if (didGlance)
            {
                glance        = true;
                actualDamage /= 2;
            }
        }

        return(new Hit(actualDamage, glance, crit, missed));
    }
Ejemplo n.º 2
0
 public FightPhaseResult(Participants participants, FightParameters attackerParams, FightParameters counterParams,
                         List <Hit> attackerHits, List <Hit> defenderHits)
 {
     Participants   = participants;
     AttackerParams = attackerParams;
     CounterParams  = counterParams;
     AttackerHits   = attackerHits;
     DefenderHits   = defenderHits;
 }
Ejemplo n.º 3
0
    private List <Hit> SimulateParams(FightParameters parameters)
    {
        var firstHit = ComputeActualDamage(parameters);
        var result   = new List <Hit>();

        result.Add(firstHit);

        if (parameters.Hits == 2)
        {
            result.Add(ComputeActualDamage(parameters));
        }

        return(result);
    }