示例#1
0
    public Attack PerformMainHandAttack(int targetArmorClass)
    {
        //Отметим, что действие в этот ход уже совершалось
        actionAvailable = false;

        DamageDieRoll   damageDice                = null;
        DamageType      damageType                = DamageType.Bludgeoning; // Если оружия в руках нет - тип урона рукопашной атаки по умолчанию дробящий
        List <DieRoll>  additionalDamageRolls     = null;
        List <Modifier> additionalDamageModifiers = null;

        if (onMainHand != null)
        {
            damageDice = new DamageDieRoll(onMainHand.DamageDice, onMainHand.DamageType);
        }
        else
        {
            //Рукопашная атака наносит 1 повреждение + бонус Силы
            damageDice = new DamageDieRoll(DiceSet.GetByName("none"), damageType);

            additionalDamageModifiers = new List <Modifier>
            {
                new DamageModifier("Unarmed strike", 1, damageType),
                new DamageModifier(Ability.Strenght.Shortcut, Ability.GetAbilityModifier(currentStrenght), damageType)
            };
        }

        AttackCheckBuilder attackBuilder = new AttackCheckBuilder(
            Ability.Strenght,
            currentStrenght,
            targetArmorClass,
            masteryBonus,
            new RollWithCriticals());

        ValueDefinitionDirector.ConstructValueDefinition(attackBuilder);
        AttackCheck attackCheck = attackBuilder.GetResult() as AttackCheck;

        DamageValueBuilder damageValueBuilder = new DamageValueBuilder(
            damageDice,
            Ability.Strenght,
            currentStrenght,
            false,
            additionalDamageRolls,
            additionalDamageModifiers);

        ValueDefinitionDirector.ConstructValueDefinition(damageValueBuilder);
        DamageValueDefinition damageValueDefinition = damageValueBuilder.GetResult() as DamageValueDefinition;

        return(new Attack(attackCheck, damageValueDefinition));
    }
示例#2
0
    private void CalculateInitiative()
    {
        //В будущем здесь должен рассчитываться модификатор инициативы, например от черты или особенности класса
        int initiativeModifier = 0;

        InitiativeCheckBuilder initiativeCheckBuilder = new InitiativeCheckBuilder(currentDexterity);

        ValueDefinitionDirector.ConstructValueDefinition(initiativeCheckBuilder);

        InitiativeCheck initiativeCheck = initiativeCheckBuilder.GetResult() as InitiativeCheck;

        initiativeCheck.CalculateResult();

        logEvent.Invoke($"{name} {initiativeCheck}");

        initiative = initiativeCheck.Result.Value;
    }