int GetCreatureId(string targetName) { if (targetName == null) { return(int.MinValue); } string trimmedName = targetName.Trim(); if (string.IsNullOrWhiteSpace(trimmedName)) { return(int.MinValue); } int playerIdFromName = AllPlayers.GetPlayerIdFromName(trimmedName); if (playerIdFromName >= 0) { return(playerIdFromName); } InGameCreature creatureByName = AllInGameCreatures.GetCreatureByName(trimmedName); if (creatureByName != null) { return(-creatureByName.Index); } return(int.MinValue); }
static string GetDieTextColor(Creature targetCreature, string dieBackColor) { if (targetCreature is Character player) { return(player.dieFontColor); } InGameCreature inGameCreature = AllInGameCreatures.GetByCreature(targetCreature); if (inGameCreature != null) { return(inGameCreature.ForegroundHex); } return(DndViewer.GetDieTextColor(dieBackColor)); }
static string GetDieBackColor(Creature targetCreature) { if (targetCreature is Character player) { return(player.dieBackColor); } InGameCreature inGameCreature = AllInGameCreatures.GetByCreature(targetCreature); if (inGameCreature != null) { return(inGameCreature.BackgroundHex); } return("#ffffff"); }
private static void SavingThrowForTargetsRequested(object sender, SavingThrowRollEventArgs ea) { // TODO: Get all the targets. if (Targeting.ActualKind.HasFlag(TargetKind.Volume)) { CharacterPositions allTargetsInVolume = TargetManager.GetAllCreaturesInVolume(); if (allTargetsInVolume == null) { return; } DiceRoll diceRoll = new DiceRoll(DiceRollType.SavingThrow, VantageKind.Normal, ea.DamageDieStr); diceRoll.SavingThrow = ea.Ability; diceRoll.SuppressLegacyRoll = true; diceRoll.Conditions = ea.Condition; if (ea.CastedSpell?.SpellCaster is Character spellCaster) { diceRoll.HiddenThreshold = spellCaster.SpellSaveDC; } foreach (CharacterPosition characterPosition in allTargetsInVolume.Characters) { Creature creature = CreatureManager.GetCreatureFromTaleSpireId(characterPosition.ID); DiceDto diceDto = null; if (creature is Character player) { diceDto = DiceDto.AddD20ForCharacter(player, $"{player.Name}'s Save", player.GetSavingThrowModifier(ea.Ability), DieCountsAs.savingThrow); } else { InGameCreature inGameCreature = AllInGameCreatures.GetByCreature(creature); if (inGameCreature != null) { diceDto = DiceDto.D20FromInGameCreature(inGameCreature, DiceRollType.SavingThrow, diceRoll.SavingThrow); } } if (diceDto == null) { continue; } diceRoll.DiceDtos.Add(diceDto); diceRoll.SpellID = ea.CastedSpell.ID; // Add ea.SpellGuid so we can undo the effect after the spell dispels. } SeriouslyRollTheDice(diceRoll); } }
public static List <Creature> GetTargets() { List <Creature> creatures = new List <Creature>(); foreach (CreatureStats creatureStats in PlayerStatManager.Players) { if (creatureStats.IsTargeted) { creatures.Add(AllPlayers.GetFromId(creatureStats.CreatureId)); } } creatures.AddRange(AllInGameCreatures.GetTargeted()); return(creatures); }
public static Creature GetCreatureFromId(int creatureId) { if (creatureId >= 0) { return(AllPlayers.GetFromId(creatureId)); } else { InGameCreature inGameCreature = AllInGameCreatures.GetByIndex(-creatureId); if (inGameCreature != null) { return(inGameCreature.Creature); } } return(null); }
public static int GetHueShift(int creatureId) { if (creatureId < 0) { InGameCreature creature = AllInGameCreatures.GetByIndex(-creatureId); if (creature == null) { return(0); } Color color = (Color)ColorConverter.ConvertFromString(creature.BackgroundHex); return((int)color.GetHue()); } else { Character player = AllPlayers.GetFromId(creatureId); if (player == null) { return(0); } return(player.hueShift); } }