Example #1
0
        void AssertRoll(string spellName, Character player, int spellSlotLevel, DiceRollType expectedDiceRollType, string expectedDice)
        {
            DiceRoll roll = DiceRollHelper.GetSpellFrom(spellName, player, spellSlotLevel);

            Assert.AreEqual(expectedDiceRollType, roll.Type);
            Assert.AreEqual(expectedDice, roll.DamageHealthExtraDice);
        }
Example #2
0
 public void Set(DiceRollType rollType, Skills detail, string dieLabel, int offset)
 {
     RollType = rollType;
     Detail   = detail;
     DieLabel = dieLabel;
     Offset   = offset;
 }
Example #3
0
        public void AddCritFailMessages(DiceRollType type)
        {
            switch (type)
            {
            // TODO: Make this data-driven:
            case DiceRollType.SkillCheck:
                CritFailMessage    = "COMPLETE FAILURE!";
                CritSuccessMessage = "Nat 20!";
                SuccessMessage     = "Success!";
                FailMessage        = "Fail!";
                break;

            case DiceRollType.Attack:
            case DiceRollType.ChaosBolt:
                CritFailMessage    = "SPECTACULAR MISS!";
                CritSuccessMessage = "Critical Hit!";
                SuccessMessage     = "Hit!";
                FailMessage        = "Miss!";
                break;

            case DiceRollType.SavingThrow:
                CritFailMessage    = "COMPLETE FAILURE!";
                CritSuccessMessage = "Critical Success!";
                SuccessMessage     = "Success!";
                FailMessage        = "Fail!";
                break;

            case DiceRollType.DeathSavingThrow:
                CritFailMessage    = "COMPLETE FAILURE!";
                CritSuccessMessage = "Critical Success!";
                SuccessMessage     = "Success!";
                FailMessage        = "Fail!";
                break;
            }
        }
Example #4
0
 public void SetRollDetails(DiceRollType type, string descriptor)
 {
     descriptor = descriptor.ToLower();
     DamageType = DndUtils.ToDamage(descriptor);
     if (DamageType != DamageType.None)
     {
         DieCountsAs = DieCountsAs.damage;
     }
     else if (descriptor.Contains("health") || type == DiceRollType.HealthOnly)
     {
         DieCountsAs = DieCountsAs.health;
     }
     else if (descriptor.Contains("inspiration") || type == DiceRollType.InspirationOnly)
     {
         DieCountsAs = DieCountsAs.inspiration;
     }
     else if (descriptor.Contains("extra") || type == DiceRollType.ExtraOnly)
     {
         DieCountsAs = DieCountsAs.extra;
     }
     else if (descriptor.Contains("bent luck") || type == DiceRollType.BendLuckAdd || type == DiceRollType.BendLuckSubtract)
     {
         DieCountsAs = DieCountsAs.bentLuck;
     }
     else if (descriptor.Contains("bonus"))
     {
         DieCountsAs = DieCountsAs.bonus;
     }
     else
     {
         DieCountsAs = DieCountsAs.totalScore;
     }
 }
Example #5
0
        private DiceRoll PrepareRoll(DiceRollType type)
        {
            DiceRollKind diceRollKind;

            if (rbTestAdvantageDieRoll.IsChecked == true)
            {
                diceRollKind = DiceRollKind.Advantage;
            }
            else if (rbTestDisadvantageDieRoll.IsChecked == true)
            {
                diceRollKind = DiceRollKind.Disadvantage;
            }
            else
            {
                diceRollKind = DiceRollKind.Normal;
            }
            string damageDice = string.Empty;

            if (type == DiceRollType.Attack)
            {
                damageDice = tbxDamageDice.Text;
            }

            DiceRoll diceRoll = new DiceRoll(diceRollKind, damageDice);

            diceRoll.ThrowPower = new Random().Next() * 2;
            if (diceRoll.ThrowPower < 0.3)
            {
                diceRoll.ThrowPower = 0.3;
            }

            if (double.TryParse(tbxModifier.Text, out double modifierResult))
            {
                diceRoll.Modifier = modifierResult;
            }

            if (double.TryParse(tbxHiddenThreshold.Text, out double thresholdResult))
            {
                diceRoll.HiddenThreshold = thresholdResult;
            }

            diceRoll.IsMagic = ckbUseMagic.IsChecked == true && type == DiceRollType.Attack;
            diceRoll.Type    = type;
            return(diceRoll);
        }
Example #6
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));
        }
Example #7
0
 public DiceRoll(DiceRollType diceRollType, VantageKind kind = VantageKind.Normal, string damageDice = "")
 {
     Type = diceRollType;
     DamageHealthExtraDice = damageDice;
     VantageKind           = kind;
     ThrowPower            = 1.0;
     MinCrit = 20;              // Some feats allow for a 19 to crit.
     //SuccessMessage = "Success!";
     //FailMessage = "Fail!";
     //CritFailMessage = "Critical Fail!";
     //CritSuccessMessage = "Critical Success!";
     MinDamage          = 0;
     CritFailMessage    = "";
     CritSuccessMessage = "";
     SuccessMessage     = "";
     FailMessage        = "";
     SkillCheck         = Skills.none;
     SavingThrow        = Ability.none;
     SpellName          = "";
 }
Example #8
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);
         }
     }
 }
 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);
         }
     }
 }
Example #10
0
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Character player, Target target, CastedSpell spell, DiceStoppedRollingData dice = null)
        {
            CreaturePlusModId recipient = Expressions.GetCustomData <CreaturePlusModId>(evaluator.Variables);

            if (recipient == null)
            {
                throw new Exception($"CreaturePlusModId recipient must be specified before evaluating expressions containing AddPropertyMod.");
            }

            ExpectingArguments(args, 4);
            DiceRollType rollType = Expressions.Get <DiceRollType>(args[0], player, target, spell);
            Skills       skills   = Expressions.Get <Skills>(args[1].Trim(), player, target, spell);
            string       dieLabel = args[2].Trim();

            if (dieLabel.StartsWith("\""))
            {
                dieLabel = Expressions.GetStr(dieLabel, player, target, spell);
            }
            int vantageOffset = Expressions.GetInt(args[3], player, target, spell);

            recipient.Creature.AddVantageMod(recipient.ID, rollType, skills, dieLabel, vantageOffset);
            return(null);
        }
        public bool Matches(string message)
        {
            testAllPlayers = false;
            Match match = Regex.Match(message, @"^InstantRoll\s+(\w+)\s+([\w\.\[\]\(\)\{\}\:""\s]+)" + PlayerSpecifier);

            if (!match.Success)
            {
                testAllPlayers = true;
                match          = Regex.Match(message, @"^InstantRoll\s+(\w+)\s+([\w\.\[\]\(\)\{\}\:""\s]+)");
            }
            if (match.Success)
            {
                if (!testAllPlayers)
                {
                    SetTargetPlayer(match.Groups);
                }
                dieStr       = match.Groups[2].Value;
                diceRollType = DndUtils.ToDiceRollType(match.Groups[1].Value);
                return(true);
            }

            testAllPlayers = false;
            return(false);
        }
Example #12
0
        private DiceRoll PrepareRoll(DiceRollType type)
        {
            DiceRollKind diceRollKind = DiceRollKind.Normal;

            if (CanIncludeVantageDice(type))
            {
                if (rbTestAdvantageDieRoll.IsChecked == true)
                {
                    diceRollKind = DiceRollKind.Advantage;
                }
                else if (rbTestDisadvantageDieRoll.IsChecked == true)
                {
                    diceRollKind = DiceRollKind.Disadvantage;
                }
            }

            string damageDice = string.Empty;

            if (IsAttack(type) || type == DiceRollType.DamageOnly || type == DiceRollType.HealthOnly)
            {
                damageDice = tbxDamageDice.Text;
            }

            DiceRoll diceRoll = new DiceRoll(diceRollKind, damageDice);

            diceRoll.CritFailMessage    = "";
            diceRoll.CritSuccessMessage = "";
            diceRoll.SuccessMessage     = "";
            diceRoll.FailMessage        = "";

            switch (type)
            {
            case DiceRollType.SkillCheck:
                diceRoll.CritFailMessage    = "COMPLETE FAILURE!";
                diceRoll.CritSuccessMessage = "Nat 20!";
                diceRoll.SuccessMessage     = "Success!";
                diceRoll.FailMessage        = "Fail!";
                break;

            case DiceRollType.Attack:
            case DiceRollType.ChaosBolt:
                diceRoll.CritFailMessage    = "SPECTACULAR MISS!";
                diceRoll.CritSuccessMessage = "Critical Hit!";
                diceRoll.SuccessMessage     = "Hit!";
                diceRoll.FailMessage        = "Miss!";
                break;

            case DiceRollType.SavingThrow:
                diceRoll.CritFailMessage    = "COMPLETE FAILURE!";
                diceRoll.CritSuccessMessage = "Critical Success!";
                diceRoll.SuccessMessage     = "Success!";
                diceRoll.FailMessage        = "Fail!";
                break;

            case DiceRollType.DeathSavingThrow:
                diceRoll.CritFailMessage    = "COMPLETE FAILURE!";
                diceRoll.CritSuccessMessage = "Critical Success!";
                diceRoll.SuccessMessage     = "Success!";
                diceRoll.FailMessage        = "Fail!";
                break;
            }


            diceRoll.ThrowPower = new Random().Next() * 2;
            if (diceRoll.ThrowPower < 0.3)
            {
                diceRoll.ThrowPower = 0.3;
            }

            if (double.TryParse(tbxModifier.Text, out double modifierResult))
            {
                diceRoll.Modifier = modifierResult;
            }

            if (double.TryParse(tbxHiddenThreshold.Text, out double thresholdResult))
            {
                diceRoll.HiddenThreshold = thresholdResult;
            }

            diceRoll.IsMagic = ckbUseMagic.IsChecked == true && IsAttack(type);
            diceRoll.Type    = type;
            return(diceRoll);
        }
Example #13
0
 bool CanIncludeVantageDice(DiceRollType type)
 {
     return(type == DiceRollType.Attack || type == DiceRollType.ChaosBolt || type == DiceRollType.DeathSavingThrow || type == DiceRollType.FlatD20 || type == DiceRollType.SavingThrow || type == DiceRollType.SkillCheck);
 }
Example #14
0
 bool IsAttack(DiceRollType type)
 {
     return(type == DiceRollType.Attack || type == DiceRollType.ChaosBolt);
 }
Example #15
0
 public static string DiceRollTypeToStr(DiceRollType diceRollType)
 {
     return(Enum.GetName(typeof(DiceRollType), diceRollType));
 }
Example #16
0
 public static bool IsSavingThrow(DiceRollType diceRollType)
 {
     return(diceRollType == DiceRollType.SavingThrow || diceRollType == DiceRollType.DamagePlusSavingThrow || diceRollType == DiceRollType.OnlyTargetsSavingThrow);
 }
Example #17
0
 public VantageMod(DiceRollType rollType, Skills detail, string dieLabel, int offset)
 {
     Set(rollType, detail, dieLabel, offset);
 }
Example #18
0
        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);
                    }
                }
            }
        }
Example #19
0
 public static bool IsDamage(DiceRollType type)
 {
     return(type == DiceRollType.DamageOnly || type == DiceRollType.DamagePlusSavingThrow);
 }