Ejemplo n.º 1
0
 public WhisperItemList(Viewer v, int interval)
 {
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            irc.sendIRCMessage("CAP REQ :twitch.tv/membership");
            //irc.sendIRCMessage("CAP REQ :twitch.tv/tags");
            irc.sendIRCMessage("CAP REQ :twitch.tv/commands");
            irc.joinRoom("firesofiso");
            GetFullViewerList();
            allTimers.Add(CreateTimer(240000, true, true, PING));
            allTimers.Add(CreateTimer(6000, true, true, SaveData));
            allTimers.Add(CreateTimer(6000, true, true, AdventurerBattle));
            allTimers.Add(CreateTimer(6000, true, true, HealViewers));
            allTimers.Add(CreateTimer(6000, true, true, GiveFayth));

            //Blessings -
            for (int i = 0; i < 5; i++)
            {
                faythTimers[i] = CreateTimer(300000, false, false, delegate { SetBlessing(i, 2); });
            }

            irc.sendChatMessage("/me Now Processing Adventurers!");

            while (true)
            {
                string message = irc.readMessage();

                Console.WriteLine(message);
                if (message != null)
                {
                    // This part is just for keeping track of who is in chat currently. Seems to be working okay.
                    if (message.Contains("PRIVMSG") || message.Contains("JOIN"))
                    {
                        Viewer user = new Viewer(GetUserName(message));
                        if (!currentViewers.Contains(user))
                        {
                            if (fullViewerList.Contains(user))
                            {
                                user = fullViewerList.Find(x => x.Name == user.Name);
                                user.RetrieveInventory(itemDB);
                            }
                            currentViewers.Add(user);
                        }
                    }

                    // Playing ping pong with the twitch server.
                    if (message.Contains("PING"))
                    {
                        irc.sendIRCMessage("PONG");
                    }

                    // Remove the viewer from current viewers when they leave the channel.
                    if (message.Contains("PART"))
                    {
                        //find username in currentViewers
                        //remove them from currentViewers
                        currentViewers.Remove(currentViewers.Find(x => x.Name == GetUserName(message))); // - this is very questionable, not really sure what remove is going to do.
                    }


                    Viewer currentViewer = GetUserFromList(currentViewers, GetUserName(message));

                    // -------------- COMMANDS --------------------

                    // CHAT COMMANDS -

                    // !discord - display a link to the discord
                    if (message.Contains("!discord"))
                    {
                        irc.sendChatMessage("[ discord.gg/sJJa23e ]  Join the Community Discord.  Keep up the conversation with other viewers and Firesofiso.  Maybe play some games or watch movies or something.  Who knows!?");
                    }

                    // !red13 - explaination of the bot game.
                    if (message.Contains("!red13"))
                    {
                        irc.sendChatMessage("Hey, I'm RedXIIIBot and I run a game in chat that allows you to battle in dungeons collecting items and richs.  Level up, gain strength, fight stronger things, level up, repeat.  Commands and info at https://goo.gl/ELjJpn.  Whisper me so I can whisper information back to you.");
                    }



                    // WHISPER COMMANDS -
                    // Will remain chat commands until things are fleshed out.

                    if (message.Contains("!me"))
                    {
                        //Bot should whisper the user with their stats.
                        // Level, health, attack, defense.

                        irc.sendChatMessage("/w " + currentViewer.Name + " Lvl: " + currentViewer.Level + " :: Exp: " + currentViewer.Exp + " / " + currentViewer.ExpNeeded + " :: Gil: " + currentViewer.Gil + " :: AA: " + currentViewer.autoAdventure + " :: Fayth: " + currentViewer.fayth);
                        irc.sendChatMessage("/w " + currentViewer.Name + " Health: " + currentViewer.CurrentHealth + " / " + currentViewer.MaxHealth + " :: DPS: " + currentViewer.DPS + " :: Defense: " + currentViewer.Defense);
                    }

                    // Check to see what enemy you are fighting and what level it is.
                    if (message.Contains("!check"))
                    {
                        if (currentViewer.target != null)
                        {
                            irc.sendChatMessage("/w " + currentViewer.Name + " Enemy: " + currentViewer.target.Name + " Lvl: " + currentViewer.target.lvl);
                        }
                        else
                        {
                            irc.sendChatMessage("/w " + currentViewer.Name + " You have no target.");
                        }
                    }

                    if (message.Contains("!start"))
                    {
                        StartAdventure(currentViewer);
                    }

                    if (message.Contains("!auto"))
                    {
                        currentViewer.autoAdventure = !currentViewer.autoAdventure;
                        irc.sendChatMessage("/w " + currentViewer.Name + " Auto Adventuring - " + currentViewer.autoAdventure);
                    }


                    // !kills - whispers how many total kills the play has gotten.
                    if (message.Contains("!kills"))
                    {
                        irc.sendChatMessage("/w " + currentViewer.Name + " You have killed " + currentViewer.totalSlain + " enemies throughout your adventures.");
                    }

                    // !shop - Red will whisper the user its current list of shop items.
                    //  [thoughts]
                    //      1 - Diff items in different areas
                    //      2 - One big shop containing the essentials - all equipment and stuff is crafted or found on enemies.
                    //  Within this command is the buying command - !shop <itemName> <quantity>
                    //      -This sub-command could potentially be its own command, i.e. !buy
                    //---
                    if (message.Contains("!shop"))
                    {
                        if (!currentViewer.isAdventuring)
                        {
                            string command = message.Substring(message.LastIndexOf('!'));
                            Console.WriteLine(command);

                            string[] commandParts = command.Split(new char[] { ' ' });

                            // is the player asking for an item?
                            if (commandParts.Length > 1)
                            {
                                for (int i = 0; i < shoplist.Count; i++)
                                {
                                    // Is the item in the shop? Search by name.
                                    if (shoplist[i].CompareName(commandParts[1]))
                                    {
                                        // Is the player asking for a certain quantity of items?
                                        if (commandParts.Length == 3)
                                        {
                                            int numItems = ConvertToNumber(commandParts[2]);
                                            // Does the player have enough gil to buy said items?
                                            if (currentViewer.Gil >= shoplist[i].BuyPrice * numItems)
                                            {
                                                // Take players money
                                                // Give them the items.
                                                // Tell them what they got.

                                                Item temp = shoplist[i];
                                                currentViewer.AddItem(temp, numItems);

                                                /*
                                                 * if (temp.StackSize > 1)
                                                 * {
                                                 *
                                                 * } else
                                                 * {
                                                 *  if (currentViewer.Bag.Count() + numItems > currentViewer.Bag.MaxSize)
                                                 *  {
                                                 *      numItems = currentViewer.Bag.MaxSize - currentViewer.Bag.Count();
                                                 *  }
                                                 *  for (int j = 0; j < numItems; j++)
                                                 *  {
                                                 *      currentViewer.AddItem(temp);
                                                 *  }
                                                 * }
                                                 */
                                                currentViewer.Gil -= shoplist[i].BuyPrice * numItems;
                                            }
                                            else
                                            {
                                                // Player doesn't have enough gil to purchase items.
                                                irc.sendChatMessage("/w " + currentViewer.Name + " You don't have enough Gil for that.");
                                            }
                                        }

                                        // Is the player entering more commands than is required for this certain command?
                                        else if (commandParts.Length > 3)
                                        {
                                            // Tell them the correct format
                                            irc.sendChatMessage("/w " + currentViewer.Name + " There are too many parameters in that command.  Format: !shop <itemname> <quantity>.");
                                        }

                                        // Finally the player is only looking for 1 of an item in the shop.
                                        else
                                        {
                                            // Do they have enough gil?
                                            if (currentViewer.Gil >= shoplist[i].BuyPrice)
                                            {
                                                // Take the players money.
                                                // Give them the item they need.
                                                // Tell them what they bought.
                                                currentViewer.Gil -= shoplist[i].BuyPrice;
                                                currentViewer.AddItem(shoplist[i], 1);
                                            }
                                            else
                                            {
                                                irc.sendChatMessage("/w " + currentViewer.Name + " You don't have enough Gil for that.");
                                            }
                                        }
                                    }
                                }
                            }

                            // !shop command handled.
                            else
                            {
                                irc.sendChatMessage("/w " + currentViewer.Name + " Welcome to the Shop!");
                                WhisperItemList shopWhisper = new WhisperItemList(currentViewer.Name, shoplist, 500, false);
                                shopWhisper.Start();
                            }
                        }
                        else
                        {
                            irc.sendChatMessage("/w " + currentViewer.Name + " Shop is not available on adventures.");
                        }
                    }


                    // !bag or !inv command
                    //  - Red will whisper the player a list of the items in their bag.
                    if (message.Contains("!bag"))
                    {
                        if (currentViewer.Bag.Count == 0)
                        {
                            irc.sendChatMessage("/w " + currentViewer.Name + " Your bag is empty.");
                        }
                        else
                        {
                            string invString = "";
                            irc.sendChatMessage("/w " + currentViewer.Name + " " + currentViewer.Bag.Count + "/" + currentViewer.Bag.Size + " Items in your bag: ");
                            for (int i = 0; i < currentViewer.Bag.Count; i++)
                            {
                                Item temp = currentViewer.Bag.GetItemByIndex(i);

                                if (temp.StackSize == 1)
                                {
                                    int count = 1;

                                    for (int j = 0; j < currentViewer.Bag.Count; j++)
                                    {
                                        if (temp.ID == currentViewer.Bag.GetItemByIndex(j).ID&& j != i)
                                        {
                                            count++;
                                        }
                                    }
                                    invString += "[" + temp.Name + " x" + temp.Count + "]";
                                    i         += count - 1;
                                }
                                else
                                {
                                    invString += "[" + temp.Name + " x" + temp.Count + "]";
                                }

                                if (i < currentViewer.Bag.Count - 1)
                                {
                                    invString += ", ";
                                }
                            }
                            irc.sendChatMessage("/w " + currentViewer.Name + " " + invString);
                        }
                    }


                    // !pray - pray to a certain deity, god, summon, whatever to get a global buff.
                    if (message.Contains("!pray"))
                    {
                        string command = message.Substring(message.LastIndexOf('!'));
                        Console.WriteLine(command);

                        string[] commandParts = command.Split(new char[] { ' ' });

                        if (commandParts.Length == 1)
                        {
                            irc.sendChatMessage("/me Pray to a summon to obtain a global buff for all.  Requires 2700 Fayth.");
                        }
                        else if (commandParts.Length == 2)
                        {
                            if (currentViewer.fayth >= 2500)
                            {
                                if (commandParts[1].ToLower() == "kirin")
                                {
                                    faythBlessings[0] = 2;

                                    if (!faythTimers[0].Enabled)
                                    {
                                        faythTimers[0].Enabled  = true;
                                        faythTimers[0].Interval = 300000;
                                        irc.sendChatMessage("/me " + currentViewer.Name + " prayed to Kirin, Sanctuary Regeneration has increased for 5 minutes.");
                                    }
                                    else
                                    {
                                        faythTimers[0].Interval += 300000;
                                        irc.sendChatMessage("/me " + currentViewer.Name + " prayed to Kirin and extended his blessing by 5 minutes.");
                                    }
                                }
                                else if (commandParts[1].ToLower() == "ifrit")
                                {
                                    faythBlessings[1] = 2;

                                    if (!faythTimers[1].Enabled)
                                    {
                                        faythTimers[1].Enabled  = true;
                                        faythTimers[1].Interval = 300000;
                                        irc.sendChatMessage("/me " + currentViewer.Name + " prayed to Ifrit, Battle Damage has increased for 5 minutes.");
                                    }
                                    else
                                    {
                                        faythTimers[1].Interval += 300000;
                                        irc.sendChatMessage("/me " + currentViewer.Name + " prayed to Ifrit and extended his blessing by 5 minutes.");
                                    }
                                }
                                else if (commandParts[1].ToLower() == "titan")
                                {
                                    faythBlessings[2] = 2;

                                    if (!faythTimers[2].Enabled)
                                    {
                                        faythTimers[2].Enabled  = true;
                                        faythTimers[2].Interval = 300000;
                                        irc.sendChatMessage("/me " + currentViewer.Name + " prayed to Titan, Battle Defense has increased for 5 minutes.");
                                    }
                                    else
                                    {
                                        faythTimers[2].Interval += 300000;
                                        irc.sendChatMessage("/me " + currentViewer.Name + " prayed to Titan and extended his blessing by 5 minutes.");
                                    }
                                }
                                else if (commandParts[1].ToLower() == "garuda")
                                {
                                    faythBlessings[3] = 2;

                                    if (!faythTimers[3].Enabled)
                                    {
                                        faythTimers[3].Enabled  = true;
                                        faythTimers[3].Interval = 300000;
                                        irc.sendChatMessage("/me " + currentViewer.Name + " prayed to Garuda, Critical Hit Rate has increased for 5 minutes.");
                                    }
                                    else
                                    {
                                        faythTimers[3].Interval += 300000;
                                        irc.sendChatMessage("/me " + currentViewer.Name + " prayed to Garuda and extended her blessing by 5 minutes.");
                                    }
                                }
                                else if (commandParts[1].ToLower() == "chocobo")
                                {
                                    faythBlessings[4] = 2;

                                    if (!faythTimers[4].Enabled)
                                    {
                                        faythTimers[4].Enabled  = true;
                                        faythTimers[4].Interval = 300000;
                                        irc.sendChatMessage("/me " + currentViewer.Name + " prayed to Fat Chocobo, Gil Dropped has increased for 5 minutes.");
                                    }
                                    else
                                    {
                                        faythTimers[4].Interval += 300000;
                                        irc.sendChatMessage("/me " + currentViewer.Name + " prayed to Fat Chocobo and extended his blessing by 5 minutes.");
                                    }
                                }
                            }
                            else
                            {
                                irc.sendChatMessage("/w " + currentViewer.Name + " You do not believe enough");
                            }
                        }
                    }

                    // GOD COMMANDS - Firesofiso only

                    if (message.Contains("!givegil"))
                    {
                        if (currentViewer.Name == "firesofiso")
                        {
                            string command = message.Substring(message.LastIndexOf('!'));
                            Console.WriteLine(command);

                            string[] commandParts = command.Split(new char[] { ' ' });
                            string   viewerName;

                            if (commandParts.Length == 3)
                            {
                                if (commandParts[1][0] == '@')
                                {
                                    viewerName = commandParts[1].Substring(1).ToLower();
                                }
                                else
                                {
                                    viewerName = commandParts[1].ToLower();
                                }
                                GetUserFromList(fullViewerList, viewerName).Gil += ConvertToNumber(commandParts[2]);
                            }
                        }
                    }

                    if (message.Contains("!givefayth"))
                    {
                        if (currentViewer.Name == "firesofiso")
                        {
                            string command = message.Substring(message.LastIndexOf('!'));
                            Console.WriteLine(command);

                            string[] commandParts = command.Split(new char[] { ' ' });

                            if (commandParts.Length == 3)
                            {
                                string viewerName = commandParts[1].Substring(1).ToLower();
                                GetUserFromList(fullViewerList, viewerName).fayth += ConvertToNumber(commandParts[2]);
                            }
                        }
                    }

                    // !job - if the user doesn't have a job selected - display all the available jobs to pick from.
                    //      - I think it would be best to display the job name and description per line/whisper.
                    // !job <jobname> - Selects the job the user wants.
                }
            }
        }