Beispiel #1
0
        public static List <PlayerActionShortcut> From(PlayerActionShortcutDto shortcutDto)
        {
            List <PlayerActionShortcut> results = new List <PlayerActionShortcut>();
            string cleanName = DndUtils.GetCleanItemName(shortcutDto.name);
            Weapon weapon    = AllWeapons.Get(cleanName);

            if (weapon == null && cleanName.IndexOf(" of ") > 0)
            {
                // Try again with the weapon...
                cleanName = cleanName.EverythingBefore(" of ");
                weapon    = AllWeapons.Get(cleanName);
            }
            Character player = AllPlayers.GetFromId(PlayerID.FromName(shortcutDto.player));

            if (weapon != null)
            {
                AddWeaponShortcuts(shortcutDto, results, weapon, player);
            }
            else
            {
                List <Spell> spells = AllSpells.GetAll(cleanName, player);
                if (spells != null && spells.Count > 0)
                {
                    AddSpellShortcuts(shortcutDto, results, player, spells);
                }
                else                 // Not a weapon or a spell.
                {
                    PlayerActionShortcut shortcut = FromAction(shortcutDto);
                    results.Add(shortcut);
                    shortcut.AddEffect(shortcutDto, "", player);
                }
            }

            return(results);
        }
Beispiel #2
0
        public static PlayerActionShortcut FromSpell(PlayerActionShortcutDto shortcutDto, Character player, Spell spell, int slotLevelOverride = 0, string damageStr = null, string suffix = "")
        {
            PlayerActionShortcut result = FromAction(shortcutDto, damageStr, suffix, slotLevelOverride, player);

            result.ProficiencyBonus = (int)Math.Round(player.proficiencyBonus);
            result.ProcessDieStr(shortcutDto, damageStr);
            result.Type      = GetDiceRollType(GetDiceRollTypeStr(spell));
            result.UsesMagic = true;
            int spellSlotLevel = spell.Level;

            if (slotLevelOverride > 0)
            {
                spellSlotLevel = slotLevelOverride;
            }
            result.AddSpell(spellSlotLevel, player, spell);
            result.Description      = spell.Description;
            result.AttackingAbility = player == null ? Ability.none : player.spellCastingAbility;
            result.ProcessDieStr(shortcutDto, damageStr);
            bool mustRollDiceToCast = result.Spell.MustRollDiceToCast();
            bool isWindup           = result.Spell != null && !result.Spell.Duration.HasValue() && mustRollDiceToCast;

            result.AddEffect(shortcutDto, SpellWindupPrefix, player, spellSlotLevel, isWindup);
            if (!mustRollDiceToCast)
            {
                result.Type = DiceRollType.CastSimpleSpell;
            }

            if (player != null)
            {
                result.AttackingAbilityModifier = player.GetSpellcastingAbilityModifier();
            }

            return(result);
        }
Beispiel #3
0
        private static PlayerActionShortcut FromSpell(PlayerActionShortcutDto shortcutDto, Character player, Spell spell, int slotLevelOverride = 0, string damageStr = null, string suffix = "")
        {
            PlayerActionShortcut result = FromAction(shortcutDto, damageStr, suffix, slotLevelOverride);

            result.UsesMagic = true;
            int spellSlotLevel = spell.Level;

            if (slotLevelOverride > 0)
            {
                spellSlotLevel = slotLevelOverride;
            }
            result.AddSpell(spellSlotLevel, player, spell);
            result.Description      = spell.Description;
            result.AttackingAbility = player == null ? Ability.none : player.spellCastingAbility;
            result.ProcessDieStr(shortcutDto, damageStr);
            bool isWindup = result.Spell != null && !result.Spell.Duration.HasValue() && result.Spell.MustRollDiceToCast();

            result.AddEffect(shortcutDto, SpellWindupPrefix, player, spellSlotLevel, isWindup);
            return(result);
        }
Beispiel #4
0
        private static PlayerActionShortcut FromWeapon(string weaponName, PlayerActionShortcutDto shortcutDto, Character player, string damageStr = null, string suffix = "", WeaponProperties weaponProperties = WeaponProperties.None, AttackType attackType = AttackType.None)
        {
            PlayerActionShortcut result = FromAction(shortcutDto, damageStr, suffix);

            result.WeaponProperties = weaponProperties;

            if (attackType == AttackType.None && weaponProperties != WeaponProperties.None)
            {
                if ((weaponProperties & WeaponProperties.Melee) == WeaponProperties.Melee)
                {
                    attackType = AttackType.Melee;
                }
                else if ((weaponProperties & WeaponProperties.Ranged) == WeaponProperties.Ranged)
                {
                    attackType = AttackType.Range;
                }
            }
            result.AttackingType = attackType;

            if ((attackType & AttackType.Range) == AttackType.Range ||
                (attackType & AttackType.MartialRange) == AttackType.MartialRange ||
                (attackType & AttackType.Melee) == AttackType.Melee ||
                (attackType & AttackType.MartialMelee) == AttackType.MartialMelee)
            {
                if (player.IsProficientWith(weaponName))
                {
                    result.ProficiencyBonus = (int)Math.Round(player.proficiencyBonus);
                }
            }
            result.UpdatePlayerAttackingAbility(player);

            result.ProcessDieStr(shortcutDto, damageStr);

            result.AddEffect(shortcutDto, WeaponWindupPrefix, player);

            return(result);
        }