예제 #1
0
        public async Task GamblingGames(SocketReaction reaction, IUserMessage msg)
        {
            switch (data)
            {
            case "Tavern":
            {
                string s = reaction.Emote.ToString();
                int    i = EUI.Dice(s);
                if (i > -1)
                {
                    switch (i)
                    {
                    case 1: await GamblingCommands.DiceGame_EvenOdd(player, reaction.Channel); break;
                    }
                }
                else
                {
                    i = EUI.GetNum(s);
                    string[] games =
                    {
                        "Blackjack",
                    };
                    if (i > games.Length)
                    {
                        return;
                    }

                    await GamblingGame.SelectInitialBet(player, reaction.Channel, games[i]); break;
                }
            }
            break;
            }
        }
예제 #2
0
        static void InitO_Events()
        {
            OptionsLoad.Add(MsgType.Event, ui =>
            {
                ui.options = new System.Collections.Generic.List <string>();

                if (OngoingEvent.Ongoing.eventinfo.shop != null)
                {
                    ui.options.Add(EUI.trade);
                }
            });

            OptionsLoad.Add(MsgType.EventShop, ui =>
            {
                ui.options = new System.Collections.Generic.List <string>()
                {
                    EUI.uturn
                };

                if (ui.data == null)
                {
                    for (int i = 0; i < OngoingEvent.Ongoing.eventinfo.shop.stock.Length; i++)
                    {
                        ui.options.Add(EUI.GetNum(i + 1));
                    }
                }
                else
                {
                    ui.options.AddRange(new[] { EUI.GetLetter(8), EUI.GetLetter(21), EUI.GetLetter(23), EUI.GetLetter(12) });
                }
            });
        }
예제 #3
0
        static void InitO_Area()
        {
            OptionsLoad.Add(MsgType.ArenaService, ui =>
                            ui.options = new List <string>()
            {
                EUI.sideQuest, EUI.bounties
            }
                            );

            OptionsLoad.Add(MsgType.ArenaFights, ui =>
            {
                if (int.TryParse(ui.data, out int l))
                {
                    ui.options = new List <string>()
                    {
                        EUI.ok, EUI.uturn
                    };
                }
                else if (int.TryParse(ui.data.TrimStart('#'), out l))
                {
                    ui.options = new List <string>();
                    for (int i = 1; i <= l; i++)
                    {
                        ui.options.Add(EUI.GetNum(i));
                    }
                }
            });
        }
예제 #4
0
        public async Task ArenaFights(SocketReaction reaction, IUserMessage msg)
        {
            string e    = reaction.Emote.ToString();
            var    data = await ArenaGlobalData.Load(player.AreaInfo.path);

            //is not a number, is paying
            switch (e)
            {
            case EUI.ok:
                await data.StartFight(int.Parse(this.data), player, reaction.Channel);

                break;

            case EUI.uturn:
                await data.DiscordUI(player, reaction.Channel);

                break;

            default:
                int i = EUI.GetNum(e) - 1;
                if (i < 0)
                {
                    return;
                }
                await data.DiscordUI(i, player, reaction.Channel);

                break;
            }
        }
예제 #5
0
 static void InitO_Encounter()
 {
     OptionsLoad.Add(MsgType.Adventure, ui => {
         if (ui.player.IsInAdventure)
         {
             ui.options = new List <string>(new[] { EUI.cycle, EUI.cancel });
         }
         else if (ui.data == null)
         {
             ui.options = new List <string>(new[] { EUI.ok, EUI.sideQuest });
         }
         else if (ui.data[0] == 'Q')
         {
             ui.options = new List <string>();
             for (int i = 0; i < 6; i++)
             {
                 ui.options.Add(EUI.GetNum(i + 1));
             }
         }
         else
         {
             ui.options = new List <string>();
             for (int i = 0; i < 4; i++)
             {
                 ui.options.Add(EUI.GetNum(i + 1));
             }
         }
     });
 }
예제 #6
0
        public async Task DynastyMember(SocketReaction reaction, IUserMessage _)
        {
            int index = EUI.GetNum(reaction.Emote.ToString()) - 1;

            if (index > -1)
            {
                string[] ids = data?.Split(';');
                await DynastyCommands.DynastyUser(player, 0, reaction.Channel, ids[index]);
            }
        }
예제 #7
0
        public async Task Adventure(SocketReaction reaction, IUserMessage msg)
        {
            string e = reaction.Emote.ToString();
            int    i = EUI.GetNum(e);

            if (i > -1)
            {
                if (data[0] == 'Q') //Select a quest
                {
                    await Adventures.Adventure.SelectIntensity(player, reaction.Channel, i);
                }
                else //Select difficulty
                {
                    int.TryParse(data, out int quest);
                    await Adventures.Adventure.StartAdventure(player, Channel,
                                                              ((Adventures.Adventure.Intensity[])Enum.GetValues(typeof(Adventures.Adventure.Intensity)))[i - 1],
                                                              quest > 0?Adventures.Adventure.currentQuests[quest - 1] : null);
                }
                return;
            }
            switch (e)
            {
            case EUI.ok:
                await Adventures.Adventure.SelectIntensity(player, reaction.Channel, 0);

                break;

            case EUI.sideQuest:
                await Adventures.Adventure.SelectQuest(player, reaction.Channel);

                break;

            case EUI.cycle:
                await player.Adventure.Display(player, reaction.Channel, true);

                break;

            case EUI.cancel:
                if (player.IsInAdventure)
                {
                    await player.Adventure.End(player, reaction.Channel, true);
                }
                else
                {
                    await GameCommands.StatsDisplay(player, reaction.Channel);
                }
                break;
            }
        }
예제 #8
0
        private static void InitO_Gambling()
        {
            OptionsLoad.Add(MsgType.GamblingGames, ui =>
            {
                ui.options = new List <string>();
                switch (ui.data)
                {
                case "Tavern":
                    ui.options.Add(EUI.Dice(1));
                    ui.options.Add(EUI.GetNum(0));
                    break;
                }
            });

            OptionsLoad.Add(MsgType.DiceGame, ui =>
                            ui.options = new List <string>()
            {
                EUI.prev,
                EUI.Dice(1),
                EUI.Dice(2),
                EUI.next,
                EUI.two, EUI.five, EUI.zero,
                EUI.cancel
            });

            OptionsLoad.Add(MsgType.GameBet, ui =>
                            ui.options = new List <string>()
            {
                EUI.prev,
                EUI.next,
                EUI.two, EUI.five, EUI.zero,
                EUI.ok,
            });

            OptionsLoad.Add(MsgType.CardGame, ui =>
            {
                Type type = GamblingGame.GetGameType(ui.data);
                Dictionary <string, string> actions = Utils.GetVar
                                                      <Dictionary <string, string> >(type, "Actions", true);
                ui.options = new List <string>(actions.Keys);
            });
        }
예제 #9
0
        static void InitO_Dynasty()
        {
            OptionsLoad.Add(MsgType.DynastyMembership, ui =>
                            ui.options = new List <string>()
            {
                EUI.greaterthan, EUI.lowerthan, EUI.cancel
            }
                            );

            OptionsLoad.Add(MsgType.DynastyMember, ui => {
                if (ui.data != null)
                {
                    string[] nums = ui.data?.Split(';');
                    if (nums.Length > 0)
                    {
                        ui.options = new List <string>();
                        for (int i = 0; i < nums.Length; i++)
                        {
                            ui.options.Add(EUI.GetNum(i + 1));
                        }
                    }
                }
            });
        }
예제 #10
0
        static void InitO_Sandbox()
        {
            OptionsLoad.Add(MsgType.Sandbox, ui =>
            {
                string[] ds = ui.data.Split(';');
                if (ds[1] == "confirm")
                {
                    ui.options = new List <string>()
                    {
                        EUI.ok, EUI.cancel
                    }
                }
                ;
                else
                {
                    ui.options = new List <string>()
                    {
                        EUI.storage, EUI.building
                    };
                    if (ds[1] == "upgrade")
                    {
                        ui.options.Add(EUI.greaterthan);
                    }
                    switch (ds[0])
                    {
                    case "house":

                        break;

                    case "stronghold":

                        break;
                    }
                }
            });

            OptionsLoad.Add(MsgType.SandboxStorage, ui =>
            {
                ui.options = new List <string>()
                {
                    EUI.prev, EUI.cycle, EUI.next
                };
            });

            OptionsLoad.Add(MsgType.TileControls, ui =>
            {
                string[] ds = ui.data.Split(';');
                if (ds.Length > 2)
                {
                    ui.options = new List <string>()
                    {
                        EUI.greaterthan,
                        EUI.explosive
                    };

                    if (int.TryParse(ds[2], out int readyAmount))
                    {
                        ui.options.Insert(0, EUI.cancel);
                        if (readyAmount > 0)
                        {
                            ui.options.Insert(0, EUI.collect);
                        }
                    }
                    else
                    {
                        ui.options.Insert(0, EUI.produce);
                    }
                }
                else
                {
                    ui.options = new List <string>();
                    int.TryParse(ds[1], out int tileCount);
                    for (int i = 0; i < tileCount; i++)
                    {
                        ui.options.Add(EUI.GetNum(i + 1));
                    }
                }
            });

            OptionsLoad.Add(MsgType.TileProductions, ui =>
            {
                string[] ds = ui.data.Split(';');
                ui.options  = new List <string>()
                {
                    EUI.prev, EUI.next
                };
                int.TryParse(ds[2], out int count);
                for (int i = 0; i < count; i++)
                {
                    ui.options.Add(EUI.GetNum(i + 1));
                }
            });

            OptionsLoad.Add(MsgType.TileProduce, ui
                            => ui.options = new List <string>()
            {
                EUI.prev,
                EUI.lowerthan,
                EUI.greaterthan,
                EUI.next,
                EUI.ok
            });
        }
예제 #11
0
        public async Task EventShop(SocketReaction reaction, IUserMessage msg)
        {
            string emote = reaction.Emote.ToString();

            if (emote == EUI.uturn)
            {
                if (data != null)
                {
                    await OngoingEvent.Ongoing.OpenShop(player, msg.Channel);
                }

                else
                {
                    await player.NewUI(await msg.Channel.SendMessageAsync(
                                           embed: OngoingEvent.Ongoing.EmbedInfo()), MsgType.Event);
                }

                return;
            }

            int i = data != null?int.Parse(data) : EUI.GetNum(emote) - 1;

            if (data == null)
            {
                await OngoingEvent.Ongoing.OpenShop(player, msg.Channel, i, true);
            }
            else if (i >= 0 && i < OngoingEvent.Ongoing.eventinfo.shop.stock.Length) //Is buying an item by count
            {
                //Drop from start 1 to index
                int amount   = 0;
                var shop     = OngoingEvent.Ongoing.eventinfo.shop;
                int currency = player.Currency.Get(shop.currency);

                if (emote == EUI.GetLetter(8))
                {
                    amount = 1;
                }
                else if (emote == EUI.GetLetter(21))
                {
                    amount = 5;
                }
                else if (emote == EUI.GetLetter(23))
                {
                    amount = 10;
                }
                else if (emote == EUI.GetLetter(12))
                {
                    amount = NumbersM.FloorParse <int>(
                        ((double)currency) / shop.stock[i].count);
                }

                if (currency < shop.stock[i].count * amount)
                {
                    await msg.Channel.SendMessageAsync($"Missing {shop.stock[i].count * amount - currency} {shop.currency} for this purchase");
                }
                else
                {
                    string collected = "";
                    if (shop.Stackable(i))
                    {
                        StackedItems item = new StackedItems(shop.ParseItem(i, player.level), amount);
                        item.item.Scale(player.level);
                        if (player.CollectItem(item, true))
                        {
                            int price = shop.stock[i].count * amount;
                            collected += $"Bought {item} for {price} {shop.currency}";
                            player.Currency.Mod(shop.currency, -price);
                        }
                        else
                        {
                            collected = $"Inventory may not contain {item}";
                        }
                    }
                    else
                    {
                        string warning = null;
                        collected = null;
                        for (int k = 0; k < amount; k++)
                        {
                            Item item = shop.ParseItem(i, player.level);
                            item.Scale(player.level);
                            if (player.CollectItem(item, 1, true))
                            {
                                collected += $"Bought {item} for {shop.stock[i].count} {shop.currency}" + Environment.NewLine;
                            }
                            else
                            {
                                warning = $"Inventory full! Bought {k}/{amount} items";
                                amount  = k;
                            }
                        }

                        if (collected != null)
                        {
                            collected = $"```{collected}```" + warning;
                        }
                        else if (warning != null)
                        {
                            collected = warning;
                        }

                        if (amount > 0)
                        {
                            player.Currency.Mod(shop.currency, -(amount * shop.stock[i].count));
                        }
                    }

                    if (collected != null)
                    {
                        await msg.Channel.SendMessageAsync(collected);
                    }
                    await OngoingEvent.Ongoing.OpenShop(player, msg.Channel, i, true);
                }
            }
        }