Esempio n. 1
0
    public static void CancelHitsByDefenceDice()
    {
        if (SkipAttackDiceRollsAndHit)
        {
            return;
        }

        int crits = DiceRollAttack.CriticalSuccesses;

        DiceRollAttack.CancelHitsByDefence(DiceRollDefence.Successes);
        if (crits > DiceRollAttack.CriticalSuccesses)
        {
            Attacker.CallOnAtLeastOneCritWasCancelledByDefender();
            Triggers.ResolveTriggers(
                TriggerTypes.OnAtLeastOneCritWasCancelledByDefender,
                delegate
            {
                CalculateAttackResults();
            });
        }
        else
        {
            CalculateAttackResults();
        }
    }
Esempio n. 2
0
    public void ShowCancelled(DiceRoll defenceDiceRoll)
    {
        DiceRoll diceRollForTesting = new DiceRoll(DiceKind.Attack, 0, DiceRollCheckType.Virtual);

        foreach (Die realDie in AttackDiceroll.DiceList)
        {
            Die newDie = diceRollForTesting.AddDice(realDie.Side);
            newDie.IsUncancelable = realDie.IsUncancelable;
        }
        ;

        Dictionary <string, int> results = diceRollForTesting.CancelHitsByDefence(defenceDiceRoll.Successes, true); //Dry run to calculate results
        int cancelledRegularHits         = results["hits"];
        int cancelledCriticalHits        = results["crits"];

        List <GameObject> reversedDiceIcons = new List <GameObject>(diceIcons);

        reversedDiceIcons.Reverse();

        foreach (var diceIcon in reversedDiceIcons)
        {
            ToggleDisableDice(diceIcon, true);
        }

        foreach (var diceIcon in reversedDiceIcons)
        {
            switch (diceIcon.name)
            {
            case "Hit":
                if (cancelledRegularHits > 0)
                {
                    ToggleDisableDice(diceIcon, false);
                    cancelledRegularHits--;
                }
                ;
                break;

            case "Crit":
                if (cancelledCriticalHits > 0)
                {
                    ToggleDisableDice(diceIcon, false);
                    cancelledCriticalHits--;
                }
                ;
                break;

            default:
                break;
            }
        }
    }