Example #1
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            ChannelSettings thisChannel = bot.GetChannelSettings(channel);

            if (thisChannel.AllowTableRolls)
            {
                bool includeLabel   = true;
                bool secondaryRolls = true;

                if (terms != null && terms.Length >= 1 && terms.Contains("nolabel"))
                {
                    includeLabel = false;
                }
                if (terms != null && terms.Length >= 1 && terms.Contains("nosecondary"))
                {
                    secondaryRolls = false;
                }

                int    rollModifier = commandController.GetRollModifierFromCommandTerms(terms);
                string tableName    = commandController.GetTableNameFromCommandTerms(terms);

                SavedRollTable savedTable = Utils.GetTableFromId(bot.SavedTables, tableName);

                if (savedTable.DefaultTable || thisChannel.AllowCustomTableRolls)
                {
                    string sendMessage = bot.DiceBot.GetRollTableResult(bot.SavedTables, tableName, characterName, channel, rollModifier, includeLabel, secondaryRolls, 3);

                    bot.SendMessageInChannel(sendMessage, channel);
                }
                else
                {
                    bot.SendMessageInChannel("Only default talbes are allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel);
                }
            }
            else
            {
                bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel);
            }
        }
Example #2
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            ChannelSettings thisChannel = bot.GetChannelSettings(channel);

            bool characterIsAdmin = Utils.IsCharacterAdmin(bot.AccountSettings.AdminCharacters, characterName);

            if (thisChannel.ChipsClearance == ChipsClearanceLevel.ChannelOp && command.ops == null)
            {
                bot.RequestChannelOpListAndQueueFurtherRequest(command);
            }
            else if ((thisChannel.ChipsClearance == ChipsClearanceLevel.DicebotAdmin && !characterIsAdmin) ||
                     (thisChannel.ChipsClearance == ChipsClearanceLevel.ChannelOp && !command.ops.Contains(characterName) && !characterIsAdmin))
            {
                bot.SendMessageInChannel(Utils.GetCharacterUserTags(characterName) + " cannot perform [" + Name + "] under the current chip settings for this channel.", channel);
            }
            else if (thisChannel.AllowChips)
            {
                string messageString = "";
                if (terms.Length < 2)
                {
                    messageString = "Error: This command requires a number (first) and a user name (second).";
                }
                else
                {
                    bool all        = false;
                    int  giveAmount = Utils.GetNumberFromInputs(terms);

                    string[] rawTermsMost = new string[rawTerms.Length - 1];

                    for (int i = 1; i < rawTerms.Length; i++)
                    {
                        rawTermsMost[i - 1] = rawTerms[i];
                    }

                    string targetUserName = Utils.GetFullStringOfInputs(rawTermsMost).Trim();

                    if (giveAmount <= 0 && !all)
                    {
                        messageString = "Error: You must input a number to take an amount of chips.";
                    }
                    else
                    {
                        messageString = bot.DiceBot.TakeChips(characterName, targetUserName, channel, giveAmount, all);

                        commandController.SaveChipsToDisk();
                    }
                }

                bot.SendMessageInChannel(messageString, channel);
            }
            else
            {
                bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel);
            }
        }
Example #3
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            ChannelSettings thisChannel = bot.GetChannelSettings(channel);

            if (thisChannel.AllowGames)
            {
                string messageString = "";

                IGame gametype    = commandController.GetGameTypeFromCommandTerms(bot.DiceBot, terms);
                bool  keepSession = terms.Contains("keepsession") || terms.Contains("keepgame");
                bool  endSession  = terms.Contains("endsession") || terms.Contains("endgame");

                if (gametype == null)
                {
                    //check game sessions and see if this channel has a session for anything
                    var gamesParticipated = bot.DiceBot.GameSessions.Where(a => a.ChannelId == channel && a.Players.Contains(characterName));
                    if (gamesParticipated.Count() == 0)
                    {
                        messageString = "Error: Game type not found.";
                    }
                    else if (gamesParticipated.Count() > 1)
                    {
                        messageString = "Error: You must specify a game type if you are in more than one game.";
                    }
                    else if (gamesParticipated.Count() == 1)
                    {
                        GameSession sesh = gamesParticipated.First();
                        gametype = sesh.CurrentGame;
                    }
                }
                if (gametype != null) //gametype can be set above after being null so this should no longer be 'else'
                {
                    GameSession sesh = bot.DiceBot.GetGameSession(channel, gametype);

                    if (sesh != null)
                    {
                        ChipPile potChips = bot.DiceBot.GetChipPile(DiceBot.PotName, channel);

                        if (sesh.Ante > 0 && potChips.Chips > 0)
                        {
                            messageString = "The pot already has chips in it. The pot must be empty before starting a game with ante.";
                        }
                        else if (sesh.CurrentGame.GetMinPlayers() > sesh.Players.Count)
                        {
                            messageString = "Cannot start " + sesh.CurrentGame.GetGameName() + " because there are currently less than [b]" + sesh.CurrentGame.GetMinPlayers() + " players[/b].";
                        }
                        else if (sesh.State == GameState.GameInProgress)
                        {
                            messageString = "Cannot start " + sesh.CurrentGame.GetGameName() + " because the game is already in progress. Please finish the current round first.";
                        }
                        else if (sesh.CurrentGame.GetType() == typeof(Roulette) && !bot.DiceBot.CountdownFinishedOrNotStarted(channel, sesh.CurrentGame.GetGameName()))
                        {
                            double secondsRemain = bot.DiceBot.GetSecondsRemainingOnCountdownTimer(channel, gametype.GetGameName());

                            messageString = "Cannot start " + sesh.CurrentGame.GetGameName() + " because the starting countdown is not yet finished. [b]" + secondsRemain.ToString("N3") + " seconds [/b]remain.";
                        }
                        else
                        {
                            messageString  = sesh.CurrentGame.GetStartingDisplay();
                            messageString += "\n" + bot.DiceBot.StartGame(channel, gametype, bot, keepSession, endSession);

                            if (sesh.CurrentGame.GetType() == typeof(Roulette))
                            {
                                bot.DiceBot.StartCountdownTimer(channel, gametype.GetGameName(), characterName, 5 * 60 * 1000);
                            }

                            commandController.SaveChipsToDisk();
                        }
                    }
                    else
                    {
                        messageString = "Error: Game session for " + gametype.GetGameName() + " not found or created.";
                    }
                }

                bot.SendMessageInChannel(messageString, channel);
            }
            else
            {
                bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel);
            }
        }
Example #4
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            string cardName = Utils.GetFullStringOfInputs(rawTerms);

            List <SavedDeck> possibleDecks = bot.SavedDecks.Where(a => a.DeckList.Contains(cardName)).ToList();

            string allReturned = "";

            if (possibleDecks != null && possibleDecks.Count >= 1)
            {
                foreach (SavedDeck saved in possibleDecks)
                {
                    if (!string.IsNullOrEmpty(allReturned))
                    {
                        allReturned += ", ";
                    }

                    int    startIndex = saved.DeckList.IndexOf(cardName);
                    string relevant   = saved.DeckList.Substring(startIndex);

                    string[] remainingCards = relevant.Split(',');

                    if (remainingCards[0].Contains('|'))
                    {
                        string[] thisSplit = remainingCards[0].Split('|');
                        DeckCard d         = new DeckCard()
                        {
                            specialName = thisSplit[0], description = thisSplit[1]
                        };
                        allReturned += d.FullDescription();
                    }
                    else
                    {
                        DeckCard d = new DeckCard()
                        {
                            specialName = remainingCards[0]
                        };
                        allReturned += d.FullDescription();
                    }

                    allReturned += " (" + saved.DeckId + ")";
                }
            }
            else
            {
                allReturned = "The card '" + cardName + "' was not found.";
            }

            bot.SendMessageInChannel("[i]Card Info: [/i]" + allReturned, channel);
        }
Example #5
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            ChannelSettings thisChannel = bot.GetChannelSettings(channel);

            if (thisChannel.AllowChips)
            {
                string messageString = "";

                ChipPile existing = bot.DiceBot.GetChipPile(characterName, channel, false);
                if (existing != null)
                {
                    messageString = Utils.GetCharacterUserTags(characterName) + " is already registered.";
                }
                else
                {
                    messageString = Utils.GetCharacterUserTags(characterName) + " was registered for a chips pile.";

                    if (thisChannel.StartWith500Chips)
                    {
                        messageString += "\n[b]500 chips[/b] were given to " + Utils.GetCharacterUserTags(characterName) + " to start.";
                    }

                    bot.DiceBot.AddChips(characterName, channel, 0, false);

                    commandController.SaveChipsToDisk();
                }

                bot.SendMessageInChannel(messageString, channel);
            }
            else
            {
                bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel);
            }
        }
Example #6
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            ChannelSettings thisChannel = bot.GetChannelSettings(channel);

            if (thisChannel.AllowChips)
            {
                bool all    = false;
                bool pot    = false;
                bool secret = false;

                if (terms != null && terms.Length >= 1 && terms.Contains("all"))
                {
                    all = true;
                }

                if (terms != null && terms.Length >= 1 && terms.Contains("pot"))
                {
                    pot = true;
                }

                if (terms != null && terms.Length >= 1 && terms.Contains("secret"))
                {
                    secret = true;
                }

                string messageString = "";
                if (all)
                {
                    messageString = bot.DiceBot.ListAllChipPiles(channel);
                }
                else
                {
                    if (pot)
                    {
                        messageString = bot.DiceBot.DisplayChipPile(channel, DiceBot.PotName);
                    }
                    else
                    {
                        messageString = bot.DiceBot.DisplayChipPile(channel, characterName);
                    }
                }

                if (all || secret)
                {
                    bot.SendPrivateMessage(messageString, characterName);
                }
                else
                {
                    bot.SendMessageInChannel(messageString, channel);
                }
            }
            else
            {
                bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel);
            }
        }
Example #7
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            if (command.ops == null)
            {
                bot.RequestChannelOpListAndQueueFurtherRequest(new UserGeneratedCommand()
                {
                    channel       = channel,
                    terms         = terms,
                    rawTerms      = rawTerms,
                    ops           = null,
                    characterName = characterName,
                    commandName   = Name
                });
            }
            else
            {
                Console.WriteLine("Channeloprequest completing");
                string[] opsList = command.ops;
                string   output  = "";
                if (opsList == null)
                {
                    output = "opslist was null";
                }
                else
                {
                    output  = Utils.PrintList(opsList);
                    output += " " + Utils.GetCharacterUserTags(characterName) + " is an op? " + opsList.Contains(characterName);
                }

                bot.SendMessageInChannel("[b][ADMIN] [/b]" + output, channel);
            }
        }
Example #8
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            ChannelSettings existing = bot.GetChannelSettings(channel);

            string sendMessage = "[b]Added[/b] " + channel + " to list of startup channels.";

            if (existing.StartupChannel)
            {
                sendMessage = "[b]Removed[/b] " + channel + " from list of startup channels.";
            }
            existing.StartupChannel = !existing.StartupChannel;

            Utils.WriteToFileAsData(bot.SavedChannelSettings, Utils.GetTotalFileName(BotMain.FileFolder, BotMain.ChannelSettingsFileName));

            bot.SendMessageInChannel(sendMessage, channel);
        }
Example #9
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            ChannelSettings thisChannel = bot.GetChannelSettings(channel);

            if (thisChannel.AllowChips)
            {
                string messageString = "";
                if (terms.Length < 2)
                {
                    messageString = "Error: This command requires a number (first) and a user name (second).";
                }
                else
                {
                    bool all        = false;
                    int  giveAmount = Utils.GetNumberFromInputs(rawTerms);

                    string[] rawTermsMost = new string[rawTerms.Length - 1];

                    for (int i = 1; i < rawTerms.Length; i++)
                    {
                        rawTermsMost[i - 1] = rawTerms[i];
                    }

                    string targetUserName = Utils.GetFullStringOfInputs(rawTermsMost).Trim();

                    if (giveAmount <= 0 && !all)
                    {
                        messageString = "Error: You must input a number to give an amount of chips.";
                    }
                    else
                    {
                        messageString = bot.DiceBot.GiveChips(characterName, targetUserName, channel, giveAmount, all);

                        commandController.SaveChipsToDisk();
                    }
                }

                bot.SendMessageInChannel(messageString, channel);
            }
            else
            {
                bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel);
            }
        }
Example #10
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            SettingType changed = SettingType.NONE;

            ChannelSettings thisChannel = bot.GetChannelSettings(channel);

            bool setValue = false;

            if (terms != null && terms.Length >= 1)
            {
                if (terms.Contains("useeicons"))
                    changed = SettingType.UseEicons;
                if (terms.Contains("greetnewusers"))
                    changed = SettingType.GreetNewUsers;
                if (terms.Contains("allowtablerolls"))
                    changed = SettingType.AllowTableRolls;
                if (terms.Contains("allowcustomtablerolls"))
                    changed = SettingType.AllowCustomTableRolls;
                if (terms.Contains("allowtableinfo"))
                    changed = SettingType.AllowTableInfo;
                if (terms.Contains("allowchips"))
                    changed = SettingType.AllowChips;
                if (terms.Contains("allowgames"))
                    changed = SettingType.AllowGames;
                if (terms.Contains("usevcaccount"))
                    changed = SettingType.UseVcAccountForChips;
                if (terms.Contains("startupchannel"))
                    changed = SettingType.StartupChannel;
                if (terms.Contains("startwith500chips"))
                    changed = SettingType.StartWith500Chips;
                if (terms.Contains("onlyopaddchips"))
                    changed = SettingType.OnlyOpAddChips;
                if (terms.Contains("onlyopbotcommands"))
                    changed = SettingType.OnlyOpBotCommands;
                if (terms.Contains("onlyopdeckcontrols"))
                    changed = SettingType.OnlyOpDeckControls;
                if (terms.Contains("onlyoptablecommands"))
                    changed = SettingType.OnlyOpTableCommands;

                if (terms.Contains("on") || terms.Contains("true"))
                    setValue = true;
                if (terms.Contains("off") || terms.Contains("false"))
                    setValue = false;
            }

            switch (changed)
            {
                case SettingType.NONE:
                    break;
                case SettingType.UseEicons:
                    thisChannel.UseEicons = setValue;
                    break;
                case SettingType.GreetNewUsers:
                    thisChannel.GreetNewUsers = setValue;
                    break;
                case SettingType.AllowTableRolls:
                    thisChannel.AllowTableRolls = setValue;
                    break;
                case SettingType.AllowCustomTableRolls:
                    thisChannel.AllowCustomTableRolls = setValue;
                    break;
                case SettingType.AllowTableInfo:
                    thisChannel.AllowTableInfo = setValue;
                    break;
                case SettingType.AllowChips:
                    thisChannel.AllowChips = setValue;
                    break;
                case SettingType.AllowGames:
                    thisChannel.AllowGames = setValue;
                    break;
                case SettingType.UseVcAccountForChips:
                    thisChannel.UseVcAccountForChips = setValue;
                    break;
                case SettingType.StartupChannel:
                    thisChannel.StartupChannel = setValue;
                    break;
                case SettingType.StartWith500Chips:
                    thisChannel.StartWith500Chips = setValue;
                    break;
                case SettingType.OnlyOpAddChips:
                    {
                        if(thisChannel.ChipsClearance != ChipsClearanceLevel.DicebotAdmin)
                        {
                            if(setValue)
                            {
                                thisChannel.ChipsClearance = ChipsClearanceLevel.ChannelOp;
                            }
                            else
                            {
                                thisChannel.ChipsClearance = ChipsClearanceLevel.NONE;
                            }
                        }
                    }
                    break;
                case SettingType.OnlyOpBotCommands:
                    thisChannel.OnlyChannelOpsCanUseAnyBotCommands = setValue;
                    break;
                case SettingType.OnlyOpDeckControls:
                    thisChannel.OnlyChannelOpsCanUseDeckControls = setValue;
                    break;
                case SettingType.OnlyOpTableCommands:
                    thisChannel.OnlyChannelOpsCanUseTableCommands = setValue;
                    break;
            }

            if (changed == SettingType.NONE)
            {
                string output = "Setting not found. Be sure to specify which setting to change, followed by 'true' or 'false'. Settings use the same name displayed in the !viewsettings command.";

                bot.SendMessageInChannel(output, channel);
            }
            else
            {
                Utils.WriteToFileAsData(bot.SavedChannelSettings, Utils.GetTotalFileName(BotMain.FileFolder, BotMain.ChannelSettingsFileName));

                string output = "(Channel setting updated) " + Utils.GetCharacterUserTags(characterName) + " set " + changed + " to " + setValue;

                if (changed == SettingType.OnlyOpAddChips && thisChannel.ChipsClearance == ChipsClearanceLevel.DicebotAdmin)
                {
                    output = "(" + changed + " Channel setting cannot be updated for this channel) ";
                }

                bot.SendMessageInChannel(output, channel);
            }
        }
Example #11
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            string saveJson    = Utils.GetFullStringOfInputs(rawTerms);
            string sendMessage = "";

            try
            {
                //accept JSON format deck
                SavedDeck d = JsonConvert.DeserializeObject <SavedDeck>(saveJson);

                FChatDicebot.DiceFunctions.Deck newDeck = new DiceFunctions.Deck(DiceFunctions.DeckType.Custom);

                newDeck.CreateFromDeckList(d.DeckList);

                string newDeckId = Utils.GetCustomDeckName(characterName);

                var thisCharacterDecks = bot.SavedDecks.Where(a => a.OriginCharacter == characterName);

                SavedDeck existingDeck = Utils.GetDeckFromId(bot.SavedDecks, newDeckId);

                if (thisCharacterDecks.Count() >= BotMain.MaximumSavedTablesPerCharacter && existingDeck == null)
                {
                    sendMessage = "Failed: A character can only save up to 3 decks at one time. Delete or overwrite old decks.";
                }
                else if (existingDeck != null && existingDeck.OriginCharacter != characterName)
                {
                    sendMessage = "Failed: This table name is taken by a different character.";
                }
                else if (newDeckId.Length < 2)
                {
                    sendMessage = "Failed: Deck name too short.";
                }
                else if (newDeck.GetTotalCards() <= 0)
                {
                    sendMessage = "Failed: No card entries found for this deck.";
                }
                else if (newDeck.GetTotalCards() > BotMain.MaximumCardsInDeck)
                {
                    sendMessage = "Failed: Deck contains more than " + BotMain.MaximumCardsInDeck + " cards.";
                }
                else
                {
                    SavedDeck newSavedDeck = new SavedDeck()
                    {
                        DeckList        = newDeck.GetDeckList(),
                        DeckId          = newDeckId,
                        OriginCharacter = characterName
                    };

                    if (existingDeck != null)
                    {
                        existingDeck.Copy(newSavedDeck);
                    }
                    else
                    {
                        bot.SavedDecks.Add(newSavedDeck);
                    }

                    Utils.WriteToFileAsData(bot.SavedDecks, Utils.GetTotalFileName(BotMain.FileFolder, BotMain.SavedDecksFileName));

                    bot.DiceBot.ResetDeck(false, channel, DeckType.Custom, newDeckId);
                    sendMessage = "[b]Success[/b]. Deck saved by [user]" + characterName + "[/user]. Draw from this deck using !drawcard custom";
                }
            }
            catch (Exception)
            {
                sendMessage = "Failed to parse deck entry data. Make sure the Json is correctly formatted.";
            }

            bot.SendMessageInChannel(sendMessage, channel);
        }
Example #12
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            int numberCharacters = 0;

            if (terms.Length > 0)
            {
                int.TryParse(terms[0], out numberCharacters);
            }

            bot.SendMessageInChannel("[b][ADMIN] [/b]" + Utils.GetStringOfNLength(numberCharacters), channel);
        }
Example #13
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            CardCommandOptions options = new CardCommandOptions(commandController, terms, characterName);

            int numberDrawn = Utils.GetNumberFromInputs(terms);

            if (numberDrawn > 1)
            {
                options.cardsS = "s";
            }

            string customDeckName = Utils.GetCustomDeckName(characterName);

            string deckTypeString             = Utils.GetDeckTypeStringHidePlaying(options.deckType, customDeckName);
            string cardDrawingCharacterString = Utils.GetCharacterStringFromSpecialName(options.characterDrawName);

            string trueDraw             = "";
            string drawOutput           = bot.DiceBot.DrawCards(numberDrawn, options.jokers, options.deckDraw, channel, options.deckType, options.characterDrawName, options.secretDraw, out trueDraw);
            string channelMessageOutput = "[i]" + cardDrawingCharacterString + ": " + deckTypeString + "Card" + options.cardsS + " drawn:[/i] " + drawOutput;

            if (options.secretDraw && !(options.characterDrawName == DiceBot.DealerName || options.characterDrawName == DiceBot.BurnCardsName || options.characterDrawName == DiceBot.DiscardName))
            {
                string playerMessageOutput = "[i]" + cardDrawingCharacterString + ": " + deckTypeString + "Card" + options.cardsS + " drawn:[/i] " + trueDraw;
                bot.SendPrivateMessage(playerMessageOutput, characterName);
            }

            bot.SendMessageInChannel(channelMessageOutput, channel);
        }
Example #14
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            ChannelSettings thisChannel = bot.GetChannelSettings(channel);

            string allSettings = string.Format("{0} [b]Channel Settings[/b]: \n" +
                                               "[b]StartupChannel:[/b] {1}, [b]AllowTableInfo:[/b] {2}, [b]AllowTableRolls:[/b] {3},\n" +
                                               "[b]AllowCustomTableRolls:[/b] {4}, [b]GreetNewUsers:[/b] {5}, [b]AllowChips:[/b] {6} \n" +
                                               "[b]Add Chips Restriction:[/b] {7} (OnlyOpAddChips), [b]StartWith500Chips[/b]: {8} \n" +
                                               "[b]AllowGames:[/b] {9}",
                                               thisChannel.Name,
                                               thisChannel.StartupChannel, thisChannel.AllowTableInfo, thisChannel.AllowTableRolls,
                                               thisChannel.AllowCustomTableRolls, thisChannel.GreetNewUsers, thisChannel.AllowChips,
                                               thisChannel.ChipsClearance.ToString(), thisChannel.StartWith500Chips,
                                               thisChannel.AllowGames);

            bot.SendMessageInChannel(allSettings, channel);
        }
Example #15
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            DeckType deckType = commandController.GetDeckTypeFromCommandTerms(terms);

            string customDeckName = Utils.GetCustomDeckName(characterName);
            string deckTypeString = Utils.GetDeckTypeStringHidePlaying(deckType, customDeckName);

            Deck   a          = bot.DiceBot.GetDeck(channel, deckType, customDeckName);
            string sendString = "";

            if (a != null)
            {
                sendString = "[i]" + deckTypeString + "Channel deck contents: [/i]" + a.ToString();
            }
            else
            {
                sendString = "[i]Error: " + deckTypeString + " deck not found[/i]";
            }

            bot.SendMessageInChannel(sendString, channel);
        }
Example #16
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            ChannelSettings thisChannel = bot.GetChannelSettings(channel);

            if (thisChannel.AllowChips)
            {
                bool half  = false;
                bool third = false;

                if (terms != null && terms.Length >= 1 && terms.Contains("half"))
                {
                    half = true;
                }

                if (terms != null && terms.Length >= 1 && terms.Contains("third"))
                {
                    third = true;
                }

                string messageString = bot.DiceBot.ClaimPot(characterName, channel, half, third);

                commandController.SaveChipsToDisk();

                bot.SendMessageInChannel(messageString, channel);
            }
            else
            {
                bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel);
            }
        }
Example #17
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            GameCommand c = new GameCommand();

            c.Run(bot, commandController, rawTerms, terms, characterName, channel, command);
        }
Example #18
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            MoveCards.Run(bot, commandController, rawTerms, terms, characterName, channel, command, CardMoveType.ToDiscardFromPlay);

            //bool all = false;
            //bool redraw = false;
            //bool secretDraw = false;
            //string characterDrawName = commandController.GetCharacterDrawNameFromCommandTerms(characterName, terms);
            //if (characterDrawName == DiceBot.DiscardName)
            //    characterDrawName = characterName;

            //if (terms != null && terms.Length >= 1 && terms.Contains("all"))
            //    all = true;
            //if (terms != null && terms.Length >= 1 && terms.Contains("redraw"))
            //    redraw = true;
            //if (terms != null && terms.Length >= 1 && (terms.Contains("s") || terms.Contains("secret")))
            //    secretDraw = true;

            //List<int> discardsTemp = Utils.GetAllNumbersFromInputs(terms);
            //List<int> discards = new List<int>();

            ////decrease all the numbers by 1 to match array indexes, rather than the card position for a player
            //if (discardsTemp.Count > 0)
            //{
            //    foreach (int i in discardsTemp)
            //    {
            //        discards.Add(i - 1);
            //    }
            //}

            //string cardsS = "";
            //if (discards.Count > 1)
            //    cardsS = "s";

            //DeckType deckType = commandController.GetDeckTypeFromCommandTerms(terms);

            //string deckTypeString = Utils.GetDeckTypeStringHidePlaying(deckType);
            //string cardDrawingCharacterString = Utils.GetCharacterStringFromSpecialName(characterDrawName);

            //int numberDiscards = 0;
            //string messageOutput = "[i]" + cardDrawingCharacterString + ": " + deckTypeString + "Card" + cardsS + " discarded from play:[/i] " + bot.DiceBot.DiscardCardsFromPlay(discards, all, channel, deckType, characterDrawName, out numberDiscards);
            //if (redraw)
            //{
            //    string trueDraw = "";
            //    messageOutput += "\n [i]Redrawn:[/i] " + bot.DiceBot.DrawCards(numberDiscards, false, true, channel, deckType, characterDrawName, secretDraw, out trueDraw);
            //}

            //if (secretDraw && !(characterDrawName == DiceBot.DealerName || characterDrawName == DiceBot.BurnCardsName))
            //{
            //    bot.SendPrivateMessage(messageOutput, characterName);
            //}

            //if (secretDraw)
            //{
            //    string redrawSecretString = redraw ? " (and redrew)" : "";
            //    string newMessageOutput = "[i]" + cardDrawingCharacterString + ": " + deckTypeString + "Card" + cardsS + " discarded from play: (secret)" + redrawSecretString + "[/i] ";
            //    bot.SendMessageInChannel(newMessageOutput, channel);
            //}
            //else
            //{
            //    bot.SendMessageInChannel(messageOutput, channel);
            //}
        }
Example #19
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            DeckType deckType = commandController.GetDeckTypeFromCommandTerms(terms);

            string customDeckName = Utils.GetCustomDeckName(characterName);
            string deckTypeString = Utils.GetDeckTypeStringHidePlaying(deckType, customDeckName);

            Deck a = bot.DiceBot.GetDeck(channel, deckType, customDeckName);

            string sendString = "";

            if (a != null)
            {
                string cardsString  = a.GetCardsRemaining() + " / " + a.GetTotalCards();
                string jokersString = a.ContainsJokers() ? " [i](contains jokers)[/i] " : "";
                sendString = "[i]" + deckTypeString + "Channel deck cards remaining: [/i]" + cardsString + jokersString;
            }
            else
            {
                sendString = "[i]Error: " + deckTypeString + " deck not found[/i]";
            }
            bot.SendMessageInChannel(sendString, channel);
        }
Example #20
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            ChannelSettings thisChannel = bot.GetChannelSettings(channel);

            if (thisChannel.AllowGames)
            {
                string messageString = "";

                IGame gametype = commandController.GetGameTypeFromCommandTerms(bot.DiceBot, terms);

                if (gametype == null)
                {
                    //TODO: make this code somewhere else - it's repeated in many game commands
                    //check game sessions and see if this channel has a session for anything
                    var gamesParticipated = bot.DiceBot.GameSessions.Where(a => a.ChannelId == channel && a.Players.Contains(characterName));
                    if (gamesParticipated.Count() == 0)
                    {
                        messageString = "Error: Game type not found.";
                    }
                    else if (gamesParticipated.Count() > 1)
                    {
                        messageString = "Error: You must specify a game type if you are in more than one game.";
                    }
                    else if (gamesParticipated.Count() == 1)
                    {
                        GameSession sesh = gamesParticipated.First();
                        gametype = sesh.CurrentGame;
                    }
                }
                if (gametype != null)
                {
                    GameSession sesh = bot.DiceBot.GetGameSession(channel, gametype, false);
                    if (sesh != null)
                    {
                        if (!sesh.Players.Contains(characterName))
                        {
                            messageString = Utils.GetCharacterUserTags(characterName) + " has not joined " + sesh.CurrentGame.GetGameName() + ".";
                        }
                        else
                        {
                            messageString = bot.DiceBot.LeaveGame(characterName, channel, gametype);

                            messageString += "\n" + sesh.Players.Count + " / " + sesh.CurrentGame.GetMaxPlayers() + " players ready.";

                            if (sesh.CurrentGame.GetType() == typeof(Roulette))
                            {
                                sesh.RemoveRouletteBet(characterName);
                            }

                            if (sesh.Players.Count >= sesh.CurrentGame.GetMinPlayers())
                            {
                                messageString += "[b] (Ready to start!)[/b]";
                            }
                        }
                    }
                    else
                    {
                        messageString = "Error: Game session for " + gametype.GetGameName() + " not found or created.";
                    }
                }

                bot.SendMessageInChannel(messageString, channel);
            }
            else
            {
                bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel);
            }
        }
Example #21
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            string customDeckName = Utils.GetCustomDeckName(characterName);

            SavedDeck deleteDeck = Utils.GetDeckFromId(bot.SavedDecks, customDeckName);

            string sendMessage = "No decks found for [user]" + characterName + "[/user]";

            if (deleteDeck != null)
            {
                if (characterName == deleteDeck.OriginCharacter)
                {
                    bot.SavedDecks.Remove(deleteDeck);

                    sendMessage = "[b]" + deleteDeck.DeckId + "[/b] deleted by [user]" + characterName + "[/user]";

                    Utils.WriteToFileAsData(bot.SavedDecks, Utils.GetTotalFileName(BotMain.FileFolder, BotMain.SavedDecksFileName));
                }
                else
                {
                    sendMessage = "Only " + deleteDeck.OriginCharacter + " can delete their own saved deck.";
                }
            }

            bot.SendMessageInChannel(sendMessage, channel);
        }
Example #22
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            var thisCharacterTables = bot.SavedTables.Where(a => a.OriginCharacter == characterName);

            string sendMessage = "No tables found for " + Utils.GetCharacterUserTags(characterName);

            if (thisCharacterTables.Count() > 0)
            {
                string tablesList = "";
                foreach (SavedRollTable savedTable in thisCharacterTables)
                {
                    if (!string.IsNullOrEmpty(tablesList))
                    {
                        tablesList += ", ";
                    }

                    tablesList += savedTable.TableId;
                }
                sendMessage = "Tables found for " + Utils.GetCharacterUserTags(characterName) + ": " + tablesList;
            }

            bot.SendMessageInChannel(sendMessage, channel);
        }
Example #23
0
 public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
 {
     bot.SendMessageInChannel("Goodbye~", channel);
     bot.LeaveChannel(channel);
 }
Example #24
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            DeckType deckType = commandController.GetDeckTypeFromCommandTerms(terms);

            string customDeckString = Utils.GetCustomDeckName(characterName);
            string deckTypeString   = Utils.GetDeckTypeStringHidePlaying(deckType, customDeckString);

            bot.DiceBot.EndHand(channel, deckType);
            bot.SendMessageInChannel("[i]" + deckTypeString + "All hands have been emptied.[/i]", channel);
        }
Example #25
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            int numberRolled = Utils.GetNumberFromInputs(terms);

            string resultString = "";

            if (numberRolled > DiceBot.MaximumDice)
            {
                resultString = "Error: Cannot roll more than " + DiceBot.MaximumDice + " dice.";
            }
            else
            {
                resultString = bot.DiceBot.RollFitD(numberRolled);
            }

            bot.SendMessageInChannel(resultString, channel);
        }
Example #26
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            ChannelSettings thisChannel = bot.GetChannelSettings(channel);

            if (thisChannel.AllowChips)
            {
                bool all = false;

                int betAmount = Utils.GetNumberFromInputs(terms);

                if (terms != null && terms.Length >= 1 && terms.Contains("all"))
                {
                    all = true;
                }

                string messageString = "";
                if (betAmount == 0 && !all)
                {
                    messageString = "Error: You must input a number or 'all' to make a bet.";
                }
                else
                {
                    messageString = bot.DiceBot.BetChips(characterName, channel, betAmount, all);

                    commandController.SaveChipsToDisk();
                }

                bot.SendMessageInChannel(messageString, channel);
            }
            else
            {
                bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel);
            }
        }
Example #27
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            MoveCards.Run(bot, commandController, rawTerms, terms, characterName, channel, command, CardMoveType.DiscardCard);

            //CardCommandOptions options = new CardCommandOptions(bot, commandController, rawTerms, terms, characterName, channel, command);
            //string deckTypeString = Utils.GetDeckTypeStringHidePlaying(options.deckType);
            //string cardDrawingCharacterString = Utils.GetCharacterStringFromSpecialName(options.characterDrawName);

            //int numberDiscards = 0;
            //string messageOutput = "[i]" + cardDrawingCharacterString + ": " + deckTypeString + "Card" + options.cardsS + " discarded:[/i] " + bot.DiceBot.DiscardCards(options.moveCardsList, options.all, channel, options.deckType, options.characterDrawName, out numberDiscards);
            //string trueDraw = "";
            //string privateMessageDraw = "";
            //if (options.redraw)
            //{
            //    messageOutput += "\n [i]Redrawn:[/i] " + bot.DiceBot.DrawCards(numberDiscards, false, true, channel, options.deckType, options.characterDrawName, options.secretDraw, out trueDraw);
            //    privateMessageDraw = "[i]Redrawn:[/i] " + trueDraw;
            //}

            //if (options.secretDraw && options.redraw && !(options.characterDrawName == DiceBot.DealerName || options.characterDrawName == DiceBot.BurnCardsName || options.characterDrawName == DiceBot.DiscardName))
            //{
            //    bot.SendPrivateMessage(privateMessageDraw, characterName);
            //}

            //if (options.secretDraw)
            //{
            //    string redrawSecretString = options.redraw ? " (and redrew)" : "";
            //    string newMessageOutput = "[i]" + cardDrawingCharacterString + ": " + deckTypeString + "Card" + options.cardsS + " discarded: (secret)" + redrawSecretString + "[/i] ";
            //    bot.SendMessageInChannel(newMessageOutput, channel);
            //}
            //else
            //{
            //    bot.SendMessageInChannel(messageOutput, channel);
            //}
        }
Example #28
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            ChannelSettings thisChannel = bot.GetChannelSettings(channel);

            bool characterIsAdmin = Utils.IsCharacterAdmin(bot.AccountSettings.AdminCharacters, characterName);

            if (thisChannel.ChipsClearance == ChipsClearanceLevel.ChannelOp && command.ops == null)
            {
                bot.RequestChannelOpListAndQueueFurtherRequest(command);
            }
            else if ((thisChannel.ChipsClearance == ChipsClearanceLevel.DicebotAdmin && !characterIsAdmin) ||
                     (thisChannel.ChipsClearance == ChipsClearanceLevel.ChannelOp && !command.ops.Contains(characterName) && !characterIsAdmin))
            {
                bot.SendMessageInChannel(Utils.GetCharacterUserTags(characterName) + " cannot perform [" + Name + "] under the current chip settings for this channel.", channel);
            }
            else if (thisChannel.AllowChips)
            {
                string messageString = bot.DiceBot.RemoveChipsPile(characterName, channel);

                commandController.SaveChipsToDisk();

                bot.SendMessageInChannel(messageString, channel);
            }
            else
            {
                bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel);
            }
        }
Example #29
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            ChannelSettings thisChannel = bot.GetChannelSettings(channel);

            bool characterIsAdmin             = Utils.IsCharacterAdmin(bot.AccountSettings.AdminCharacters, characterName);
            bool characterIsTrustedForChannel = Utils.IsCharacterTrusted(bot.AccountSettings.TrustedCharacters, characterName, channel);

            if (thisChannel.ChipsClearance == ChipsClearanceLevel.ChannelOp && command.ops == null)
            {
                bot.RequestChannelOpListAndQueueFurtherRequest(command);
            }
            else if ((thisChannel.ChipsClearance == ChipsClearanceLevel.DicebotAdmin && !characterIsAdmin && !characterIsTrustedForChannel) ||
                     (thisChannel.ChipsClearance == ChipsClearanceLevel.ChannelOp && !command.ops.Contains(characterName) && !characterIsAdmin))
            {
                bot.SendMessageInChannel(Utils.GetCharacterUserTags(characterName) + " cannot perform [" + Name + "] under the current chip settings for this channel.", channel);
            }
            else if (thisChannel.AllowChips)
            {
                bool pot = false;

                int chipAmount = Utils.GetNumberFromInputs(terms);

                if (terms != null && terms.Length >= 1 && terms.Contains("pot"))
                {
                    pot = true;
                }

                string messageString = "";
                if (chipAmount <= 0)
                {
                    messageString = "Error: You must specify a number of chips above 0 to add.";
                }
                else
                {
                    messageString = bot.DiceBot.AddChips(characterName, channel, chipAmount, pot);

                    commandController.SaveChipsToDisk();
                }

                bot.SendMessageInChannel(messageString, channel);
            }
            else
            {
                bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel);
            }
        }
Example #30
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            if (rawTerms.Length < 2)
            {
                bot.SendMessageInChannel("Error: This command requires 2 terms. (Amount and chip code)", channel);
            }
            else
            {
                int chipAmount = Utils.GetNumberFromInputs(terms);

                string chipCode = rawTerms[1];

                if (chipAmount > 0 && !string.IsNullOrEmpty(chipCode))
                {
                    bot.ChipsCoupons.Add(new ChipsCoupon()
                    {
                        ChipsAmount = chipAmount,
                        Code        = chipCode
                    });
                    commandController.SaveCouponsToDisk();

                    bot.SendMessageInChannel("Added code " + chipCode + " for " + chipAmount + " chips.", channel);
                }
                else
                {
                    bot.SendMessageInChannel("Error on inputs for chips code.", channel);
                }
            }
        }