Esempio n. 1
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);
        }
Esempio 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)
            {
                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);
            }
        }
Esempio n. 3
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            string channelId = Utils.GetChannelIdFromInputs(rawTerms);

            string sendMessage = "Attempting to join channel: " + channelId;

            bot.JoinChannel(channelId);

            //send to character if there is no origin channel for this command
            if (!commandController.MessageCameFromChannel(channel))
            {
                bot.SendPrivateMessage(sendMessage, characterName);
            }
            else
            {
                bot.SendMessageInChannel(sendMessage, channel);
            }
        }
Esempio n. 4
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            string messageText = "[b]General Commands:[/b]\n!roll, !fitd" +
                                 "\n!drawcard, !resetdeck, !shuffledeck, !endhand, !showhand, !discardcard, !takefromdiscard, !deckinfo, !playcard, !takefromplay, !discardfromplay, !playfromdiscard\n" +
                                 "!register, !addchips, !showchips, !givechips, !bet, !claimpot, !removepile, !takechips, !redeemchips, !removechips\n" +
                                 "!joinchannel, !leavethischannel\n!botinfo, !uptime, !help\n" +
                                 "!rolltable, !savetable, !deletetable, !tableinfo\n" +
                                 "!joingame, !leavegame, !cancelgame, !startgame, !gamestatus, !gamecommand, !gc\n" +
                                 "[b]Channel Op only Commands:[/b]\n" +
                                 "!removeallpiles, !setstartingchannel, !updatesetting, !viewsettings\n" +
                                 "For full information on commands, see the profile [user]Dice Bot[/user].";

            if (string.IsNullOrEmpty(channel))
            {
                bot.SendPrivateMessage(messageText + "\nMost of [user]Dice Bot[/user]'s functions require it to be in a [b]channel[/b]. You can invite it to a private channel and then use [b]!joinchannel[/b] to test commands.", characterName);
            }
            else
            {
                bot.SendMessageInChannel(messageText, channel);
            }
        }
Esempio n. 5
0
        public static void Run(BotMain bot, BotCommandController commandController,
                               string[] rawTerms, string[] terms, string characterName, string channel,
                               UserGeneratedCommand command, CardMoveType moveType)
        {
            CardCommandOptions options = new CardCommandOptions(commandController, terms, characterName);

            if (!(moveType == CardMoveType.DiscardCard || moveType == CardMoveType.PlayCard))
            {
                options.redraw = false;
            }

            string customDeckString           = Utils.GetCustomDeckName(characterName);
            string deckTypeString             = Utils.GetDeckTypeStringHidePlaying(options.deckType, customDeckString);
            string cardDrawingCharacterString = Utils.GetCharacterStringFromSpecialName(options.characterDrawName);

            int numberDiscards = 0;

            string actionString = "";

            switch (moveType)
            {
            case CardMoveType.DiscardCard:
                actionString = bot.DiceBot.DiscardCards(options.moveCardsList, options.all, channel, options.deckType, options.characterDrawName, out numberDiscards);
                break;

            case CardMoveType.PlayCard:
                actionString = bot.DiceBot.PlayCards(options.moveCardsList, options.all, channel, options.deckType, options.characterDrawName, out numberDiscards);
                break;

            case CardMoveType.ToHandFromDiscard:
                actionString = bot.DiceBot.TakeCardsFromDiscard(options.moveCardsList, options.all, channel, options.deckType, options.characterDrawName, out numberDiscards);
                break;

            case CardMoveType.ToPlayFromDiscard:
                actionString = bot.DiceBot.PlayCardsFromDiscard(options.moveCardsList, options.all, channel, options.deckType, options.characterDrawName, out numberDiscards);
                break;

            case CardMoveType.ToHandFromPlay:
                actionString = bot.DiceBot.TakeCardsFromPlay(options.moveCardsList, options.all, channel, options.deckType, options.characterDrawName, out numberDiscards);
                break;

            case CardMoveType.ToDiscardFromPlay:
                actionString = bot.DiceBot.DiscardCardsFromPlay(options.moveCardsList, options.all, channel, options.deckType, options.characterDrawName, out numberDiscards);
                break;
            }

            if (numberDiscards > 1 || numberDiscards == 0)
            {
                options.cardsS = "s";
            }
            string messageOutput = "[i]" + cardDrawingCharacterString + ": " + deckTypeString + "Card" + options.cardsS +
                                   " " + Utils.GetCardMoveTypeString(moveType) + "[/i] " + actionString;
            string trueDraw           = "";
            string privateMessageDraw = "";

            if (options.redraw)
            {
                messageOutput     += "\n [i]Redrawn:[/i] " + bot.DiceBot.DrawCards(numberDiscards, options.jokers, options.deckDraw, 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 + numberDiscards + " Card" + options.cardsS + " " + Utils.GetCardMoveTypeString(moveType) + " (secret)" + redrawSecretString + "[/i] ";
                bot.SendMessageInChannel(newMessageOutput, channel);
            }
            else
            {
                bot.SendMessageInChannel(messageOutput, channel);
            }
        }
Esempio n. 6
0
        public string RunGame(System.Random r, List <String> playerNames, DiceBot diceBot, BotMain botMain, GameSession session)
        {
            botMain.SendMessageInChannel("[color=yellow]Selecting a new king and assigning numbers...[/color]", session.ChannelId);

            int index = r.Next(playerNames.Count);

            string selectedKing = playerNames[index];

            while (session.KingsGamePlayers != null && session.KingsGamePlayers.Count > 1 &&
                   session.KingsGamePlayers.FirstOrDefault(a => a.Role == 0) != null &&
                   session.KingsGamePlayers.FirstOrDefault(a => a.Role == 0).Name == selectedKing)
            {
                index = r.Next(playerNames.Count);

                selectedKing = playerNames[index];
            }

            int    kingTextNumber = r.Next(7);
            string kingIntroText  = "";

            switch (kingTextNumber)
            {
            case 0:
                kingIntroText = "All hail king ";
                break;

            case 1:
                kingIntroText = "The new king is ";
                break;

            case 2:
                kingIntroText = "Your king is ";
                break;

            case 3:
                kingIntroText = "Behold king ";
                break;

            case 4:
                kingIntroText = "A new king has been chosen, ";
                break;

            case 5:
                kingIntroText = "This round's king is ";
                break;

            case 6:
                kingIntroText = "The king is ";
                break;

            default:
                kingIntroText = "The new king is ";
                break;
            }


            int[] assignedNumbers = new int[playerNames.Count - 1];

            int createdNumbers = 0;

            List <int> includedInts = new List <int>();

            //assign a number to every remaining player
            for (int i = 0; i < assignedNumbers.Length; i++)
            {
                int assignedNumber = r.Next(assignedNumbers.Length - createdNumbers) + 1;

                int counter = 0;
                for (int q = 0; q < assignedNumber; q++)
                {
                    counter += 1;
                    while (includedInts.Contains(counter))
                    {
                        counter += 1;
                    }
                }

                includedInts.Add(counter);
                assignedNumbers[i] = counter;
                createdNumbers++;
            }

            int createdNumberIndex = 0;
            int playerNumber       = 0;

            session.KingsGamePlayers = new List <KingsGamePlayer>();

            foreach (string player in playerNames)
            {
                if (playerNumber != index)
                {
                    int    playerAssignedNumber = assignedNumbers[createdNumberIndex];
                    string messageToPlayer      = "Your number is " + playerAssignedNumber + " for this round.";
                    createdNumberIndex++;
                    session.KingsGamePlayers.Add(new KingsGamePlayer()
                    {
                        Name = player,
                        Role = playerAssignedNumber
                    });

                    botMain.SendPrivateMessage(messageToPlayer, player);
                }
                else
                {
                    session.KingsGamePlayers.Add(new KingsGamePlayer()
                    {
                        Name = player,
                        Role = 0
                    });
                }
                playerNumber++;
            }

            botMain.SendPrivateMessage("You are the king this round!\nGive your command to the other players using the numbers 1 - " + assignedNumbers.Length + " and then award points based on if they completed the tasks.", selectedKing);

            string outputString = "" + kingIntroText + Utils.GetCharacterUserTags(selectedKing) +
                                  "\nEveryone has been assigned their numbers and the king may make decrees using the numbers 1 - " + assignedNumbers.Length + "." +
                                  "\n..." +
                                  "\nNext Step: After the tasks are finished, the king must assign points with !gc awardpoints [player number(s)], or the round can be cancelled with !gc endround" +
                                  "\nNote: If there is any confusion about who has what number you can use !gc showallnumbers[/sub]";

            session.State = DiceFunctions.GameState.GameInProgress;

            return(outputString);
        }
Esempio n. 7
0
        public string IssueGameCommand(DiceBot diceBot, BotMain botMain, string character, string channel, GameSession session, string[] terms)
        {
            string returnString = "";

            if (terms.Contains("showallnumbers"))
            {
                if (session.State == GameState.GameInProgress)
                {
                    string messageString = "Showing all information for this round of The King's Game:\n" + GetPlayerNumbers(session);
                    botMain.SendPrivateMessage(messageString, character);
                    returnString = Utils.GetCharacterUserTags(character) + " has been sent the information for this round's secret numbers.";
                }
                else
                {
                    returnString = "The King's Game is not already in progress, there are no numbers to show.";
                }
            }
            else if (terms.Contains("endround"))
            {
                returnString = "King's Game round has ended manually.";
                ResetGameRound(session);
            }
            else if (terms.Contains("awardpoints"))
            {
                if (session.State == GameState.GameInProgress)
                {
                    if (PlayerIsKing(session, character))
                    {
                        if (session.KingsGamePlayers == null || session.KingsGamePlayers.Count < GetMinPlayers())
                        {
                            returnString = "Error: King's Game players list not set correctly.";
                        }
                        else
                        {
                            List <int> playerAwardsTemp = Utils.GetAllNumbersFromInputs(terms);
                            List <int> playerAwards     = new List <int>();

                            //decrease all the numbers by 1 to match array indexes, rather than the card position for a player
                            if (playerAwardsTemp.Count > 0)
                            {
                                foreach (int i in playerAwardsTemp)
                                {
                                    if (i > 0 && i < session.KingsGamePlayers.Count)
                                    {
                                        playerAwards.Add(i);
                                    }
                                }
                            }

                            string playerAwardsList = "";
                            if (playerAwards.Count > 0)
                            {
                                foreach (int i in playerAwards)
                                {
                                    playerAwardsList += GetPlayerNameAndNumber(session, i);
                                    KingsGamePlayer player = session.KingsGamePlayers.FirstOrDefault(a => a.Role == i);
                                    if (player != null)
                                    {
                                        string chipsAward = diceBot.AddChips(player.Name, channel, 100, false);
                                        playerAwardsList += "\n" + chipsAward;
                                    }
                                    playerAwardsList += "\n";
                                }
                            }
                            else
                            {
                                playerAwardsList = "no one";
                            }


                            string messageString = "King " + Utils.GetCharacterUserTags(character) + " is awarding Points to :\n" + playerAwardsList;

                            returnString = messageString + "\n This round has finished.";

                            ResetGameRound(session);
                        }
                    }
                    else
                    {
                        returnString = "Only the king can award points for the round.";
                    }
                }
                else
                {
                    returnString = "The King's Game is not already in progress, points cannot be awarded.";
                }
            }
            else
            {
                returnString = "A command for " + GetGameName() + " was not found.";
            }

            return(returnString);
        }