Esempio n. 1
0
 private static DiceDto AddD20ForCreature(InGameCreature inGameCreature, string label, double modifier, DieCountsAs dieCountsAs)
 {
     return(new DiceDto()
     {
         PlayerName = inGameCreature.Name,
         CreatureId = -inGameCreature.Index,
         Sides = 20,
         Quantity = 1,
         Label = label,
         Modifier = modifier,
         DamageType = DamageType.None,
         BackColor = inGameCreature.BackgroundHex,
         FontColor = inGameCreature.ForegroundHex,
         DieCountsAs = dieCountsAs
     });
 }
Esempio n. 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);
 }
Esempio n. 3
0
        public static DiceDto D20FromInGameCreature(InGameCreature inGameCreature, DiceRollType diceRollType)
        {
            DieCountsAs dieCountsAs = DieCountsAs.totalScore;
            double      modifier    = 0;
            string      label;

            if (IsSavingThrow(diceRollType))
            {
                dieCountsAs = DieCountsAs.savingThrow;
                label       = $"{inGameCreature.Name}'s Save";
            }
            else
            {
                label = inGameCreature.Name;
            }

            return(AddD20ForCreature(inGameCreature, label, modifier, dieCountsAs));
        }
Esempio n. 4
0
        public static List <InGameCreature> ToggleTalking(InGameCreature inGameCreature)
        {
            List <InGameCreature> changedCreatures = new List <InGameCreature>();

            foreach (InGameCreature creature in Creatures)
            {
                if (creature == inGameCreature)
                {
                    creature.IsTalking = !creature.IsTalking;
                    changedCreatures.Add(creature);
                }
                else if (creature.IsTalking)
                {
                    changedCreatures.Add(creature);
                    creature.IsTalking = false;
                }
            }

            return(changedCreatures);
        }
Esempio n. 5
0
 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);
         }
     }
 }
Esempio n. 6
0
        public static List <InGameCreature> ToggleSelected(InGameCreature inGameCreature)
        {
            List <InGameCreature> changedCreatures = new List <InGameCreature>();

            foreach (InGameCreature creature in Creatures)
            {
                if (creature == inGameCreature)
                {
                    creature.IsSelected = !creature.IsSelected;
                    changedCreatures.Add(creature);
                }
                else if (creature.IsSelected)
                {
                    changedCreatures.Add(creature);
                    creature.IsSelected = false;
                }
            }

            return(changedCreatures);
        }
        public static object ApplyDamage(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target, double multiplier = 1)
        {
            Dictionary <DamageType, int> latestDamage = Expressions.GetCustomData <Dictionary <DamageType, int> >(evaluator.Variables);

            if (latestDamage == null)
            {
                return(null);
            }

            foreach (Creature creature in target.Creatures)
            {
                InGameCreature inGameCreature = AllInGameCreatures.GetByCreature(creature);
                if (inGameCreature != null)
                {
                    inGameCreature.StartTakingDamage();
                    if (inGameCreature != null)
                    {
                        foreach (DamageType damageType in latestDamage.Keys)
                        {
                            // TODO: pass in AttackKind with the custom data
                            ReportOnVulnerabilitiesAndResistance(player?.Game, creature, inGameCreature.Name, damageType);
                            inGameCreature.TakeSomeDamage(player?.Game, damageType, AttackKind.Magical, (int)Math.Floor(latestDamage[damageType] * multiplier));
                        }
                    }
                    inGameCreature.FinishTakingDamage();
                }
                else
                {
                    if (creature is Character thisPlayer)
                    {
                        foreach (DamageType damageType in latestDamage.Keys)
                        {
                            // TODO: pass in AttackKind with the custom data
                            thisPlayer.TakeDamage(damageType, AttackKind.Any, latestDamage[damageType]);
                            ReportOnVulnerabilitiesAndResistance(thisPlayer.Game, creature, thisPlayer.firstName, damageType);
                        }
                    }
                }
            }
            return(null);
        }
Esempio n. 8
0
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Character player, Target target = null, CastedSpell spell = null, DiceStoppedRollingData dice = null)
        {
            ExpectingArguments(args, 0);
            Dictionary <DamageType, int> latestDamage = Expressions.GetCustomData <Dictionary <DamageType, int> >(evaluator.Variables);

            if (latestDamage == null)
            {
                return(null);
            }

            foreach (Creature creature in target.Creatures)
            {
                InGameCreature inGameCreature = AllInGameCreatures.GetByCreature(creature);
                if (inGameCreature != null)
                {
                    inGameCreature.TakeHalfDamage(player, latestDamage, AttackKind.Magical);
                }
                // TODO: Also get players from the target and work with them.
            }
            return(null);
        }
Esempio n. 9
0
        public static InGameCreature GetCreatureByName(string name)
        {
            if (name == null)
            {
                return(null);
            }
            string         lowerName      = name.ToLower();
            InGameCreature inGameCreature = Creatures.FirstOrDefault(x => x.Name.ToLower() == lowerName);

            if (inGameCreature != null)
            {
                return(inGameCreature);
            }
            inGameCreature = Creatures.FirstOrDefault(x => x.Name.ToLower().StartsWith(lowerName));
            if (inGameCreature != null)
            {
                return(inGameCreature);
            }
            inGameCreature = Creatures.FirstOrDefault(x => x.Name.ToLower().EndsWith(lowerName));
            return(inGameCreature);
        }
 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);
         }
     }
 }