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); }
private static PlayerActionShortcut FromAction(PlayerActionShortcutDto shortcutDto, string damageStr = "", string suffix = "", int slotLevel = 0) { PlayerActionShortcut result = new PlayerActionShortcut(); result.Description = shortcutDto.description; result.AddDice = shortcutDto.addDice; result.AddDiceOnHit = shortcutDto.addDiceOnHit; result.AddDiceOnHitMessage = shortcutDto.addDiceOnHitMessage; result.AdditionalRollTitle = shortcutDto.addDiceTitle; result.MinDamage = MathUtils.GetInt(shortcutDto.minDamage); result.PlusModifier = MathUtils.GetInt(shortcutDto.plusModifier); result.Name = shortcutDto.name + suffix; result.Part = GetTurnPart(shortcutDto.time); result.PlayerId = PlayerID.FromName(shortcutDto.player); result.Type = GetDiceRollType(shortcutDto.type); result.VantageMod = DndUtils.ToVantage(shortcutDto.vantageMod); result.ModifiesExistingRoll = MathUtils.IsChecked(shortcutDto.rollMod); result.UsesMagic = MathUtils.IsChecked(shortcutDto.magic); result.Commands = shortcutDto.commands; result.SpellSlotLevel = slotLevel; //player.ResetPlayerTurnBasedState(); result.ProcessDieStr(shortcutDto, damageStr); result.TrailingEffects = shortcutDto.trailingEffects; result.DieRollEffects = shortcutDto.dieRollEffects; return(result); }
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); }
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); }
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.GetFromName(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); shortcut.ProcessDieStr(shortcutDto); results.Add(shortcut); shortcut.AddEffect(shortcutDto, "", player); } } return(results); }