// This seems to be the problem - we are adding effects to the PlayerActionShortcutDto instead of passing in an ItemEffect. public void AddEffect(PlayerActionShortcutDto shortcutDto, string windupPrefix, Character player, int slotLevel = 0, bool isWindup = false) { return; //if (isWindup) //{ // if (!windupPrefix.StartsWith("Windup.")) // windupPrefix = "Windup." + windupPrefix; //} // //lastPrefix = windupPrefix; //int minSlotLevel = MathUtils.GetInt(shortcutDto.minSlotLevel); //if (slotLevel < minSlotLevel) // return; //WindupDto windup = WindupDto.From(shortcutDto, player); //if (windup == null) // return; //string shortcutName = shortcutDto.name; //if (string.IsNullOrWhiteSpace(shortcutName)) // shortcutName = this.Name; //windup.Name = windupPrefix + shortcutName; //if (Spell?.Duration.HasValue() == true) // windup.Lifespan = 0; //Windups.Add(windup); }
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); }
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); }
public static List <PlayerActionShortcut> FromItemSpellEffect(string spellName, ItemEffect spellEffect, Character player) { List <PlayerActionShortcut> results = new List <PlayerActionShortcut>(); List <Spell> spells = AllSpells.GetAll(spellName); foreach (Spell spell in spells) { PlayerActionShortcutDto dto = new PlayerActionShortcutDto(); dto.name = spell.Name; dto.player = player.name; //dto.effectAvailableWhen = weaponEffect.effectAvailableWhen; SetDtoFromEffect(dto, spellEffect); if (spell.SpellType == SpellType.RangedSpell || spell.SpellType == SpellType.MeleeSpell) { if (spell.Name == "Chaos Bolt") { dto.type = DndUtils.DiceRollTypeToStr(DiceRollType.ChaosBolt); } else { dto.type = DndUtils.DiceRollTypeToStr(DiceRollType.Attack); } } else if (spell.SpellType == SpellType.SavingThrowSpell) { dto.type = DndUtils.DiceRollTypeToStr(DiceRollType.DamageOnly); } else if (spell.SpellType == SpellType.OtherSpell) { dto.type = DndUtils.DiceRollTypeToStr(DiceRollType.None); } else if (spell.SpellType == SpellType.HpCapacitySpell) { dto.type = DndUtils.DiceRollTypeToStr(DiceRollType.ExtraOnly); } else { dto.type = DndUtils.DiceRollTypeToStr(DiceRollType.None); } SetSpellCastingTime(dto, spell); List <Spell> oneSpell = new List <Spell>(); oneSpell.Add(spell); AddSpellShortcuts(dto, results, player, oneSpell); } AddItemEffect(results, spellEffect); return(results); }
private static void AddSpellShortcuts(PlayerActionShortcutDto shortcutDto, List <PlayerActionShortcut> results, Character player, List <Spell> spells) { foreach (Spell spell in spells) { if (spell.MorePowerfulWhenCastAtHigherLevels) { int[] spellSlotLevels = player.GetSpellSlotLevels(); int availableSlots = 0; if (spell.Level >= 0) { availableSlots = spellSlotLevels[spell.Level]; } if (availableSlots > 0) { bool needToDisambiguateMultipleSpells = spell.Level < 9 && spellSlotLevels[spell.Level + 1] > 0; for (int slotLevel = spell.Level; slotLevel <= 9; slotLevel++) { if (spellSlotLevels[slotLevel] == 0) { break; } string suffix = string.Empty; if (needToDisambiguateMultipleSpells) { suffix = $" [{slotLevel}]"; } results.Add(FromSpell(shortcutDto, player, spell, slotLevel, null, suffix)); } } else { results.Add(FromSpell(shortcutDto, player, spell, spell.Level)); } } else { results.Add(FromSpell(shortcutDto, player, spell, spell.Level)); } } }
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); }
public static PlayerActionShortcut FromAction(PlayerActionShortcutDto shortcutDto, string weaponDamage = "", string suffix = "", int slotLevel = 0, Character player = null) { PlayerActionShortcut result = new PlayerActionShortcut(); result.WeaponDamage = weaponDamage; 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.DisplayText = shortcutDto.name + suffix; result.Part = GetTurnPart(shortcutDto.time); if (player != null) { result.PlayerId = player.playerID; } else { result.PlayerId = AllPlayers.GetPlayerIdFromName(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; result.TrailingEffects = shortcutDto.trailingEffects; result.DieRollEffects = shortcutDto.dieRollEffects; return(result); }