Ejemplo n.º 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);

            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);
            }
        }
Ejemplo n.º 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);

            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);
            }
        }
Ejemplo n.º 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.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);
            }
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 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)
            {
                if (thisChannel.ChipsClearance != ChipsClearanceLevel.DicebotAdmin)
                {
                    bot.SendMessageInChannel("Redeemchips is only functional in channels that have [b]restricted[/b] chips pools. Please try using '!addchips' instead.", channel);
                }
                else
                {
                    string messageString = "";

                    if (rawTerms.Count() < 1)
                    {
                        messageString = "Error: This command requires a chips code.";
                    }
                    else
                    {
                        string chipsCode = rawTerms[0];

                        //find chips coupon
                        ChipsCoupon coupon = bot.ChipsCoupons.FirstOrDefault(a => a.Code == chipsCode);

                        if (coupon == null)
                        {
                            messageString = "chips code not found (" + chipsCode + ")";
                        }
                        else if (coupon.Redeemed)
                        {
                            messageString = "This chips code (" + chipsCode + ") has already been redeemed.";
                        }
                        else
                        {
                            //mark redeemed and add chips to the redeeming character
                            coupon.Redeemed   = true;
                            coupon.RedeemedBy = characterName;

                            messageString = "Chips code redeemed.\n" + bot.DiceBot.AddChips(characterName, channel, coupon.ChipsAmount, false) +
                                            "\n[sub]Thank you for purchasing Dice Bot chips![/sub]";

                            commandController.SaveChipsToDisk();
                            commandController.SaveCouponsToDisk();
                        }
                    }


                    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);
            }
        }
Ejemplo n.º 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);

            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);
            }
        }
Ejemplo n.º 7
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);
            }
        }
Ejemplo n.º 8
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);
            }
        }
Ejemplo n.º 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 < 1)
                {
                    messageString = "Error: This command requires a number.";
                }
                else
                {
                    bool pot = false;

                    int chipAmount = Utils.GetNumberFromInputs(terms);

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

                    messageString = "";
                    if (chipAmount <= 0)
                    {
                        messageString = "Error: You must specify a number of chips above 0 to remove.";
                    }
                    else
                    {
                        messageString = bot.DiceBot.AddChips(characterName, channel, -1 * 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);
            }
        }
Ejemplo n.º 10
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);
            }
        }