public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Character player, Creature target, CastedSpell spell) { ExpectingArguments(args, 4); string tableName = evaluator.Evaluate <string>(args[0]); string fieldLookup = evaluator.Evaluate <string>(args[1]); string matchColumn = evaluator.Evaluate <string>(args[2]); object matchValue = evaluator.Evaluate(Expressions.Clean(args[3])); return(AllTables.GetData(tableName, fieldLookup, matchColumn, matchValue)); }
public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Character player, Creature target, CastedSpell spell) { ExpectingArguments(args, 1); string characterClassName = evaluator.Evaluate <string>(args[0]); return(player.GetLevel(characterClassName)); }
public override object GetValue(string variableName, ExpressionEvaluator evaluator, Character player) { if (Enum.TryParse(variableName, out CreatureKinds result)) return result; return null; }
public override bool Handles(string tokenName, Character player, CastedSpell castedSpell) { return Enum.TryParse(tokenName, out CreatureKinds result); }
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 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); }
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; SetSpellCastingTime(dto, spell); //dto.effectAvailableWhen = weaponEffect.effectAvailableWhen; SetDtoFromEffect(dto, spellEffect); dto.type = GetDiceRollTypeStr(spell); List <Spell> oneSpell = new List <Spell>(); oneSpell.Add(spell); AddSpellShortcuts(dto, results, player, oneSpell); } AddItemEffect(results, spellEffect); return(results); }
public static List <PlayerActionShortcut> FromWeapon(CarriedWeapon carriedWeapon, ItemEffect weaponEffect, Character player) { List <PlayerActionShortcut> results = new List <PlayerActionShortcut>(); //Weapon weapon = AllWeapons.Get(weaponEffect.name); Weapon weapon = AllWeapons.Get(carriedWeapon.Weapon.Name); PlayerActionShortcutDto dto = new PlayerActionShortcutDto(); if (!string.IsNullOrWhiteSpace(carriedWeapon.Name)) { dto.name = carriedWeapon.Name; } else { dto.name = weapon.Name; } //dto.effectAvailableWhen = weaponEffect.effectAvailableWhen; dto.player = player.name; SetDtoFromEffect(dto, weaponEffect); dto.type = DndUtils.DiceRollTypeToStr(DiceRollType.Attack); SetWeaponHitTime(dto, weapon); dto.plusModifier = carriedWeapon.HitPlusModifier.ToString(); AddWeaponShortcuts(dto, results, weapon, player); foreach (PlayerActionShortcut playerActionShortcut in results) { playerActionShortcut.CarriedWeapon = carriedWeapon; playerActionShortcut.PlusModifier = carriedWeapon.HitPlusModifier; playerActionShortcut.DamageDieBonus = carriedWeapon.DamageDieBonus; playerActionShortcut.UsesMagic = carriedWeapon.HitPlusModifier > 0; playerActionShortcut.ProcessDieStr(dto, playerActionShortcut.WeaponDamage); } AddItemEffect(results, weaponEffect); return(results); }
private static void AddWeaponShortcuts(PlayerActionShortcutDto shortcutDto, List <PlayerActionShortcut> results, Weapon weapon, Character player) { if ((weapon.weaponProperties & WeaponProperties.Versatile) == WeaponProperties.Versatile) { if ((weapon.weaponProperties & WeaponProperties.Melee) == WeaponProperties.Melee && (weapon.weaponProperties & WeaponProperties.Ranged) == WeaponProperties.Ranged) { results.Add(FromWeapon(weapon.Name, shortcutDto, HandsOnWeapon.One, player, weapon.damageOneHanded, " (1H Stabbed)", weapon.weaponProperties, AttackType.Melee)); results.Add(FromWeapon(weapon.Name, shortcutDto, HandsOnWeapon.Two, player, weapon.damageTwoHanded, " (2H Slice)", weapon.weaponProperties, AttackType.Melee)); results.Add(FromWeapon(weapon.Name, shortcutDto, HandsOnWeapon.One, player, weapon.damageOneHanded, " (1H Thrown)", weapon.weaponProperties, AttackType.Range)); } else { results.Add(FromWeapon(weapon.Name, shortcutDto, HandsOnWeapon.One, player, weapon.damageOneHanded, " (1H)", weapon.weaponProperties)); results.Add(FromWeapon(weapon.Name, shortcutDto, HandsOnWeapon.Two, player, weapon.damageTwoHanded, " (2H)", weapon.weaponProperties)); } } else if ((weapon.weaponProperties & WeaponProperties.TwoHanded) == WeaponProperties.TwoHanded) { results.Add(FromWeapon(weapon.Name, shortcutDto, HandsOnWeapon.Two, player, weapon.damageTwoHanded, "", weapon.weaponProperties)); } else { results.Add(FromWeapon(weapon.Name, shortcutDto, HandsOnWeapon.One, player, weapon.damageOneHanded, "", weapon.weaponProperties)); } }
private static PlayerActionShortcut FromWeapon(string weaponName, PlayerActionShortcutDto shortcutDto, HandsOnWeapon handsOnWeapon, Character player, string weaponDamage = null, string suffix = "", WeaponProperties weaponProperties = WeaponProperties.None, AttackType attackType = AttackType.None) { PlayerActionShortcut result = FromAction(shortcutDto, weaponDamage, suffix, 0, player); result.HandsOnWeapon = handsOnWeapon; 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, false); result.AddEffect(shortcutDto, WeaponWindupPrefix, player); return(result); }
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)); } } }
// 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); }
void AddSpell(int spellSlotLevel, Character player, Spell spell) { Spell = spell.Clone(player, spellSlotLevel); Dice = Spell.DieStr; Part = DndUtils.ToTurnPart(Spell.CastingTime); }
public override bool Handles(string tokenName, Character player, CastedSpell castedSpell) { return(Enum.TryParse(tokenName, out SpellRangeType result)); }
public override object GetValue(string variableName, ExpressionEvaluator evaluator, Character player) { if (Enum.TryParse(variableName, out SpellRangeType result)) { return(result); } return(null); }