public static DiceDto FromCreatureId(int creatureId, double mod) { DiceDto diceDto = new DiceDto(); if (creatureId < 0) { InGameCreature inGameCreature = AllInGameCreatures.GetByIndex(-creatureId); if (inGameCreature != null) { diceDto.BackColor = inGameCreature.BackgroundHex; diceDto.FontColor = inGameCreature.ForegroundHex; diceDto.Label = DndUtils.GetFirstName(inGameCreature.Name); } } else { Character player = AllPlayers.GetFromId(creatureId); if (player != null) { diceDto.BackColor = player.dieBackColor; diceDto.FontColor = player.dieFontColor; diceDto.Label = player.firstName; } } diceDto.IsMagic = false; diceDto.CreatureId = creatureId; diceDto.Sides = 20; diceDto.DieCountsAs = DieCountsAs.totalScore; diceDto.DamageType = DamageType.None; diceDto.Modifier = mod; return(diceDto); }
private static void SetDiceFromCreature(InGameCreature inGameCreature, DiceDto npcMonsterDice) { npcMonsterDice.CreatureId = InGameCreature.GetUniversalIndex(inGameCreature.Index); npcMonsterDice.Label = inGameCreature.Name; npcMonsterDice.PlayerName = inGameCreature.Name; npcMonsterDice.BackColor = inGameCreature.BackgroundHex; npcMonsterDice.FontColor = inGameCreature.ForegroundHex; }
static DiceDto FromRoll(Roll roll, string dieBackColor, string dieFontColor, int creatureId, string playerName) { // TODO: Set color for creature, set label, set player name. DiceDto result = new DiceDto(); result.DamageType = DndUtils.ToDamage(roll.Descriptor); result.Quantity = (int)roll.Count; result.BackColor = dieBackColor; result.FontColor = dieFontColor; result.Label = roll.Label; result.PlayerName = playerName; result.CreatureId = creatureId; result.Sides = roll.Sides; result.ScoreMultiplier = roll.ScoreMultiplier; return(result); }
public static void AddDiceForCreature(List <DiceDto> diceDtos, string dieStr, int creatureIndex, DiceRollType type) { DieRollDetails dieRollDetails = DieRollDetails.From(dieStr); foreach (InGameCreature inGameCreature in Creatures) { if (inGameCreature.Index == creatureIndex) { foreach (Roll roll in dieRollDetails.Rolls) { DiceDto npcMonsterDice = new DiceDto(); npcMonsterDice.Sides = roll.Sides; npcMonsterDice.Quantity = (int)Math.Round(roll.Count); npcMonsterDice.SetRollDetails(type, roll.Descriptor); SetDiceFromCreature(inGameCreature, npcMonsterDice); diceDtos.Add(npcMonsterDice); } } } }
public static void AddD20sForSelected(List <DiceDto> diceDtos, DiceRollType rollType) { foreach (InGameCreature inGameCreature in Creatures) { if (inGameCreature.OnScreen) { DiceDto npcMonsterDice = new DiceDto(); npcMonsterDice.Sides = 20; npcMonsterDice.CreatureId = InGameCreature.GetUniversalIndex(inGameCreature.Index); npcMonsterDice.Quantity = 1; SetDiceFromCreature(inGameCreature, npcMonsterDice); npcMonsterDice.Label = null; // Backwards compatibility. May be able to change after reworking code in DieRoller.ts if (rollType == DiceRollType.Initiative) { // TODO: Get initiative vantage for NPC/Monster } diceDtos.Add(npcMonsterDice); } } }
public static void AddDiceForTargeted(List <DiceDto> diceDtos, string dieStr) { DieRollDetails dieRollDetails = DieRollDetails.From(dieStr); foreach (InGameCreature inGameCreature in Creatures) { if (inGameCreature.IsTargeted) { foreach (Roll roll in dieRollDetails.Rolls) { DiceDto npcMonsterDice = new DiceDto { Sides = roll.Sides, Quantity = (int)Math.Round(roll.Count), }; npcMonsterDice.SetRollDetails(DiceRollType.None, roll.Descriptor); SetDiceFromCreature(inGameCreature, npcMonsterDice); diceDtos.Add(npcMonsterDice); } } } }
public static void AddD20sForSelected(List <DiceDto> diceDtos, DiceRollType rollType) { foreach (InGameCreature inGameCreature in AllInGameCreatures.Creatures) { if (inGameCreature.OnScreen) { DiceDto npcMonsterDice = new DiceDto(); npcMonsterDice.Sides = 20; npcMonsterDice.CreatureId = InGameCreature.GetUniversalIndex(inGameCreature.Index); npcMonsterDice.Quantity = 1; //npcMonsterDice.Label = inGameCreature.Name; npcMonsterDice.PlayerName = inGameCreature.Name; npcMonsterDice.BackColor = inGameCreature.BackgroundHex; npcMonsterDice.FontColor = inGameCreature.ForegroundHex; if (rollType == DiceRollType.Initiative) { // TODO: Get initiative vantage for NPC/Monster } diceDtos.Add(npcMonsterDice); } } }