示例#1
0
        public bool HasDamage(DamageType damage)
        {
            if (DamageHealthExtraDice != null)
            {
                DieRollDetails dieRollDetails = DieRollDetails.From(DamageHealthExtraDice);
                foreach (Roll roll in dieRollDetails.Rolls)
                {
                    if (DndUtils.ToDamage(roll.Descriptor) == damage)
                    {
                        return(true);
                    }
                }
            }

            if (DiceDtos?.Any() == true)
            {
                foreach (DiceDto diceDto in DiceDtos)
                {
                    if (diceDto.DamageType == damage)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
示例#2
0
        void ProcessDieStr(PlayerActionShortcutDto shortcutDto, string damageStr)
        {
            string dieStr = shortcutDto.dieStr;

            if (!string.IsNullOrWhiteSpace(damageStr))
            {
                dieStr = damageStr;
            }

            bool isInstantDice = dieStr.StartsWith("!");

            if (isInstantDice)
            {
                dieStr = dieStr.Substring(1);
            }

            DieRollDetails dieRollDetails = DieRollDetails.From(dieStr);

            if (dieRollDetails?.Rolls.Count > 0)
            {
                dieRollDetails.Rolls[0].Offset += DamageModifier;
                dieStr = dieRollDetails.ToString();
            }

            if (isInstantDice)
            {
                InstantDice = dieStr;
            }
            else
            {
                Dice = dieStr;
            }
        }
示例#3
0
        public static void AddDtosFromDieStr(List <DiceDto> diceDtos, string diceStr, string dieBackColor, string dieFontColor, int creatureId, string playerName)
        {
            DieRollDetails dieRollDetails = DieRollDetails.From(diceStr);

            foreach (Roll roll in dieRollDetails.Rolls)
            {
                diceDtos.Add(FromRoll(roll, dieBackColor, dieFontColor, creatureId, playerName));
            }
        }
示例#4
0
        string GetDieStr(int spellSlotLevel, int spellCasterLevel, int spellcastingAbilityModifier)
        {
            string bonusThreshold = BonusThreshold.ToLower();

            DieRollDetails details = DieRollDetails.From(OriginalDieStr, spellcastingAbilityModifier);

            string dieStr = details.ToString();

            if (string.IsNullOrWhiteSpace(bonusThreshold))
            {
                return(dieStr);
            }

            int compareLevel = spellSlotLevel;

            if (bonusThreshold.StartsWith("c"))
            {
                compareLevel = spellCasterLevel;
            }

            int    minThreshold = bonusThreshold.GetFirstInt();
            double multiplier   = compareLevel - minThreshold;

            string bonusPerLevelStr = BonusPerLevel;

            if (PerLevelBonus == 0)
            {
                return(dieStr);
            }

            int totalBonus = (int)Math.Floor(PerLevelBonus * multiplier);

            if (totalBonus <= 0)
            {
                return(dieStr);
            }

            DieRollDetails bonusDetails = DieRollDetails.From(bonusPerLevelStr, spellcastingAbilityModifier);

            foreach (Roll bonusRoll in bonusDetails.Rolls)
            {
                Roll matchingRoll = details.GetRoll(bonusRoll.Sides);
                if (matchingRoll == null)
                {
                    details.AddRoll(bonusRoll.ToString());
                }
                else if (multiplier != 0)
                {
                    matchingRoll.Count  += (int)Math.Floor(bonusRoll.Count * multiplier);
                    matchingRoll.Offset += (int)Math.Floor(bonusRoll.Offset * multiplier);
                }
            }

            return(details.ToString());
        }
示例#5
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);
                    }
                }
            }
        }
示例#6
0
        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);
                    }
                }
            }
        }
示例#7
0
        string GetDieStr(int spellSlotLevel, int spellCasterLevel, int spellcastingAbilityModifier)
        {
            DieRollDetails details = DieRollDetails.From(OriginalDieStr, spellcastingAbilityModifier);

            string dieStr = details.ToString();

            if (string.IsNullOrWhiteSpace(BonusThreshold))
            {
                return(dieStr);
            }

            if (!GetMultiplier(spellSlotLevel, spellCasterLevel, out double multiplier))
            {
                return(dieStr);
            }

            DieRollDetails bonusDetails = DieRollDetails.From(BonusPerLevel, spellcastingAbilityModifier);

            foreach (Roll bonusRoll in bonusDetails.Rolls)
            {
                Roll matchingRoll = details.GetRoll(bonusRoll.Sides);
                if (matchingRoll == null)
                {
                    details.AddRoll(bonusRoll.ToString());
                }
                else if (multiplier != 0)
                {
                    matchingRoll.Count += (int)Math.Floor(bonusRoll.Count * multiplier);
                    if (BonusMax > 0 && matchingRoll.Count > BonusMax)
                    {
                        matchingRoll.Count = BonusMax;
                    }
                    matchingRoll.Offset += (int)Math.Floor(bonusRoll.Offset * multiplier);
                }
            }

            return(details.ToString());
        }
示例#8
0
        // TODO: Put DiceRollType as a property on actionShortcut
        public static DiceRoll GetFrom(PlayerActionShortcut actionShortcut, Character player = null)
        {
            DieRollDetails bonusDie = DieRollDetails.From("");

            if (actionShortcut.CarriedWeapon != null)
            {
                if (actionShortcut.CarriedWeapon.Weapon.RequiresAmmunition() && player != null && player.ReadiedAmmunition != null)
                {
                    if (!string.IsNullOrEmpty(player.ReadiedAmmunition.DamageBonusStr))
                    {
                        bonusDie.AddRoll(player.ReadiedAmmunition.DamageBonusStr);
                    }
                }
            }

            DiceRoll diceRoll = new DiceRoll(actionShortcut.Type);

            if (player != null)
            {
                diceRoll.SingleOwnerId = player.playerID;
            }
            diceRoll.AdditionalDiceOnHit        = actionShortcut.AddDiceOnHit;
            diceRoll.AdditionalDiceOnHitMessage = actionShortcut.AddDiceOnHitMessage;
            diceRoll.AddCritFailMessages(actionShortcut.Type);
            string dieToRoll;

            if (actionShortcut.HasInstantDice())
            {
                dieToRoll = actionShortcut.InstantDice;
            }
            else
            {
                dieToRoll = actionShortcut.Dice;
            }

            if (bonusDie.DieCount > 0)
            {
                DieRollDetails tempDiceRoll = DieRollDetails.From(dieToRoll);
                tempDiceRoll.AddDetails(bonusDie);
                diceRoll.DamageHealthExtraDice = tempDiceRoll.ToString();
            }
            else
            {
                diceRoll.DamageHealthExtraDice = dieToRoll;
            }

            string overrideReplaceDamageDice = null;

            if (player != null)
            {
                overrideReplaceDamageDice = player.overrideReplaceDamageDice;
            }
            if (!string.IsNullOrEmpty(overrideReplaceDamageDice))
            {
                DieRollDetails originalRoll    = DieRollDetails.From(diceRoll.DamageHealthExtraDice);
                DieRollDetails replacementRoll = DieRollDetails.From(overrideReplaceDamageDice);
                if (replacementRoll.FirstDescriptor == "()")
                {
                    replacementRoll.FirstDescriptor = originalRoll.FirstDescriptor;
                }

                if (replacementRoll.FirstOffset == 0)
                {
                    replacementRoll.FirstOffset = originalRoll.FirstOffset;
                }

                overrideReplaceDamageDice      = replacementRoll.ToString();
                diceRoll.DamageHealthExtraDice = overrideReplaceDamageDice;
            }

            diceRoll.DamageType      = DamageType.None;         // Consider deprecating.
            diceRoll.IsMagic         = actionShortcut.UsesMagic || actionShortcut.Type == DiceRollType.WildMagicD20Check || player.usesMagicThisRoll || player.usesMagicAmmunitionThisRoll;
            diceRoll.MinDamage       = actionShortcut.MinDamage;
            diceRoll.Modifier        = actionShortcut.ToHitModifier;
            diceRoll.SecondRollTitle = actionShortcut.AdditionalRollTitle;
            if (actionShortcut.Spell != null)
            {
                diceRoll.Modifier  = player.SpellAttackBonus;
                diceRoll.SpellName = actionShortcut.Spell.Name;
                if (actionShortcut.Spell.MustRollDiceToCast())
                {
                    diceRoll.DamageHealthExtraDice = actionShortcut.Spell.DieStr;
                }
            }

            return(diceRoll);
        }