Exemple #1
0
        public bool Matches(string message)
        {
            applyToTargetedCreatures = false;
            applyToOnScreenCreatures = false;
            applyToSelectedCreature  = false;
            applyToAllPlayers        = false;
            if (message == "Apply LastHealth [TargetedCreatures]")
            {
                applyToTargetedCreatures = true;
                applyCommand             = "LastHealth";
                return(true);
            }
            if (message == "Apply LastDamage [TargetedCreatures]")
            {
                applyToTargetedCreatures = true;
                applyCommand             = "LastDamage";
                return(true);
            }
            Match match = Regex.Match(message, @"^Apply\s+(\w+)" + PlayerSpecifier);

            if (!match.Success)
            {
                applyToAllPlayers = true;
                match             = Regex.Match(message, @"^Apply\s+(\w+)");
            }
            if (match.Success)
            {
                if (!applyToAllPlayers)
                {
                    SetTargetPlayer(match.Groups);
                    if (TargetPlayer == null)
                    {
                        applyToAllPlayers = true;
                    }
                }

                applyCommand = match.Groups[1].Value;
                if (applyCommand == "DamageToAllCreatures" || applyCommand == "HealthToAllCreatures" || applyCommand == "TempHpToAllCreatures")
                {
                    applyToAllPlayers        = false;
                    applyToOnScreenCreatures = true;
                }
                if (applyCommand == "DamageToSelected" || applyCommand == "HealthToSelected" || applyCommand == "TempHpToSelected")
                {
                    applyToAllPlayers       = false;
                    applyToSelectedCreature = true;
                }
                if (applyCommand == "LastDamage" || applyCommand == "LastHealth")
                {
                    DigitManager.SetValue("health", -1);
                }
                return(true);
            }

            return(false);
        }
        public void Execute(IDungeonMasterApp dungeonMasterApp, ChatMessage chatMessage)
        {
            List <int> playerIds = GetPlayerIds(dungeonMasterApp, testAllPlayers);

            if (dieStr.Contains("{dice.count}"))
            {
                const int MaxDiceAllowed = 50;
                decimal   value          = DigitManager.GetValue("dice");
                if (value == decimal.MinValue)
                {
                    value = 1;
                }
                if (value > MaxDiceAllowed)
                {
                    value = MaxDiceAllowed;
                    dungeonMasterApp.TellDungeonMaster($"Unable to roll {value} dice at once. Maximum on-screen dice is limited to {MaxDiceAllowed}.");
                }
                dieStr = dieStr.Replace("{dice.count}", value.ToString());
                DigitManager.ResetValue("dice");
            }
            dungeonMasterApp.InstantDice(diceRollType, dieStr.Trim(), playerIds);
        }
Exemple #3
0
        public void Execute(IDungeonMasterApp dungeonMasterApp, ChatMessage chatMessage)
        {
            if (applyToTargetedCreatures)
            {
                dungeonMasterApp.ApplyToTargetedCreatures(applyCommand);
                return;
            }

            string  keyword = GetActiveKeyword();
            decimal value   = DigitManager.GetValue(keyword);

            if (value > 10000)
            {
                System.Diagnostics.Debugger.Break();
                dungeonMasterApp.TellDungeonMaster($"{keyword} value unreasonably high - {value}. Resetting it to zero. Please try again.");
                DigitManager.SetValue(keyword, 0);
                return;
            }

            if (applyToOnScreenCreatures && value != decimal.MinValue)
            {
                dungeonMasterApp.ApplyToOnScreenCreatures(applyCommand, (int)value);
                return;
            }

            if (applyToSelectedCreature && value != decimal.MinValue)
            {
                dungeonMasterApp.ApplyToSelectedCreature(applyCommand, (int)value);
                return;
            }

            if (value == decimal.MinValue)
            {
                dungeonMasterApp.TellDungeonMaster($"Set numeric value first before applying {applyCommand}.");
                return;
            }
            dungeonMasterApp.Apply(applyCommand, value, GetPlayerIds(dungeonMasterApp, applyToAllPlayers));
            DigitManager.ResetValue(keyword);
        }
Exemple #4
0
        public static int GetInGameCreatureTargetNumber(string targetNumStr)
        {
            int targetNum;

            if (targetNumStr == "{creature.count}")
            {
                targetNum = (int)DigitManager.GetValue("creature");
            }
            else
            {
                if (!int.TryParse(targetNumStr, out targetNum))
                {
                    return(int.MinValue);
                }
                else if (!Debouncer.IsGood("creature", targetNum))
                {
                    return(int.MinValue);
                }
            }

            return(targetNum);
        }
Exemple #5
0
 public void Execute(IDungeonMasterApp dungeonMasterApp, ChatMessage chatMessage)
 {
     DigitManager.ResetValue(keyword);
 }
Exemple #6
0
 public void Execute(IDungeonMasterApp dungeonMasterApp, ChatMessage chatMessage)
 {
     DigitManager.AddDigit(keyword, digit);
 }
        public bool Matches(string message)
        {
            cardId         = null;
            targetOverride = null;
            playerName     = null;
            if (message.StartsWith(STR_ToggleHandVisibility))
            {
                cardCommandType = CardCommandType.ToggleHandVisibility;
                string creatureIdStr = message.Substring(STR_ToggleHandVisibility.Length);
                if (creatureIdStr.Contains("{creature.count}"))
                {
                    creatureIdStr = creatureIdStr.Replace("{creature.count}", DigitManager.GetValue("creature").ToString());
                }
                creatureId = GetCreatureId(creatureIdStr);
                if (creatureId == int.MinValue)
                {
                    playerName = creatureIdStr;
                    return(true);
                }
                if (creatureId < 0)
                {
                    lastNpcCreatureId = creatureId;
                }
                return(true);
            }

            if (message.StartsWith(STR_RevealSecretCard))
            {
                cardCommandType = CardCommandType.RevealSecretCard;
                cardId          = message.EverythingAfterLast(" ").Trim();
                string commandPlayerName = message.EverythingBeforeLast(" ").Trim();
                targetOverride = commandPlayerName.EverythingAfter(" ").Trim();
                return(true);
            }

            // TODO: Flesh this out.
            if (message == STR_HideAllNpcCards)
            {
                cardCommandType = CardCommandType.HideAllNpcCards;
                creatureId      = 0;
                return(true);
            }

            if (message.StartsWith(STR_SelectNextNpcCard) || message.StartsWith(STR_SelectNextPlayerCard))
            {
                targetOverride  = message.EverythingAfter(" ").Trim();
                cardCommandType = CardCommandType.SelectNextCard;
                return(true);
            }

            if (message.StartsWith(STR_SelectPreviousNpcCard) || message.StartsWith(STR_SelectPreviousPlayerCard))
            {
                targetOverride  = message.EverythingAfter(" ").Trim();
                cardCommandType = CardCommandType.SelectPreviousCard;
                return(true);
            }
            if (message.StartsWith(STR_PlaySelectedNpcCard) || message.StartsWith(STR_PlaySelectedPlayerCard))
            {
                targetOverride = message.EverythingAfter(" ").Trim();
                if (string.IsNullOrWhiteSpace(targetOverride))
                {
                    targetOverride = STR_LastNpcCreatureId;
                }
                cardCommandType = CardCommandType.PlaySelectedCard;
                return(true);
            }

            return(false);
        }