Beispiel #1
0
        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);
        }
Beispiel #2
0
 /// <summary>
 /// Returns the player or the in game creature based on the specified creatureId.
 /// </summary>
 /// <param name="creatureId">The id of the player (non-negative) or in game creature (negative).</param>
 public static Creature GetCreatureById(int creatureId)
 {
     if (creatureId >= 0)
     {
         return(AllPlayers.GetFromId(creatureId));
     }
     else
     {
         InGameCreature inGameCreature = AllInGameCreatures.GetByIndex(-creatureId);
         if (inGameCreature != null)
         {
             return(inGameCreature.Creature);
         }
     }
     return(null);
 }