Exemplo n.º 1
0
        public async Task Tavern(SocketReaction reaction, IUserMessage msg)
        {
            if (EUI.Dice(reaction.Emote.ToString()) == 1)
            {
                await GamblingCommands.TavernGames(player, reaction.Channel);

                return;
            }
            switch (reaction.Emote.ToString())
            {
            case EUI.sideQuest:
            {
                var qt = User.DailyQuestBoard.Load(player._id);
                await qt.ShowBoard(player, reaction.Channel);
            }
            break;

            case EUI.bounties:
            {
                Areas.AreaPartials.Area tavern = player.Area;
                if (tavern.parent != null)
                {
                    tavern = Areas.AreaPartials.Area.LoadArea(tavern.GeneratePath(false) + tavern.parent);
                }
                await TavernInteractive.GenerateBountyFile(player, tavern, -1, reaction.Channel);
            }
            break;
            }
        }
Exemplo n.º 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) });
                }
            });
        }
Exemplo n.º 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));
                    }
                }
            });
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 5
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;
            }
        }
Exemplo n.º 6
0
        public async Task DiceGame(SocketReaction reaction, IUserMessage _)
        {
            string[] d = data.Split(';');
            //$"{coins};{streak}
            int.TryParse(d[0], out int coins);
            int.TryParse(d[1], out int streak);

            int i = EUI.Dice(reaction.Emote.ToString());

            if (i != -1)
            {
                await GamblingCommands.DiceGame_EvenOdd(player, reaction.Channel, i, coins, streak);
            }
            switch (reaction.Emote.ToString())
            {
            case EUI.cancel: await GameCommands.ShortStatsDisplay(player, reaction.Channel); break;

            case EUI.prev: await GamblingCommands.DiceGame_EvenOdd(player, reaction.Channel, -1, Math.Max(coins - 10, 10), streak); break;

            case EUI.next: await GamblingCommands.DiceGame_EvenOdd(player, reaction.Channel, -1, coins + 10, streak); break;

            case EUI.two: await GamblingCommands.DiceGame_EvenOdd(player, reaction.Channel, -1, coins * 2, streak); break;

            case EUI.five: await GamblingCommands.DiceGame_EvenOdd(player, reaction.Channel, -1, coins * 5, streak); break;

            case EUI.zero: await GamblingCommands.DiceGame_EvenOdd(player, reaction.Channel, -1, coins * 10, streak); break;
            }
        }
Exemplo n.º 7
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));
             }
         }
     });
 }
Exemplo n.º 8
0
        async Task RemoveReactions(IUserMessage msg)
        {
            msg ??= message ?? await GetUiMessage();

            var bot = Handlers.DiscordBotHandler.Client.CurrentUser;

            _ = msg.RemoveReactionsAsync(bot, options.Select(x => EUI.ToEmote(x)).ToArray());
        }
Exemplo n.º 9
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]);
            }
        }
Exemplo n.º 10
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;
            }
        }
Exemplo n.º 11
0
 public void LoadOptions(IUserMessage reply)
 {
     if (options != null)
     {
         try
         {
             _ = reply.AddReactionsAsync(options.Select(s => EUI.ToEmote(s)).ToArray());
         }
         catch (Exception e)
         {
             _ = Handlers.UniqueChannels.Instance.SendToLog(e);
             Log.LogS(e);
         }
     }
 }
Exemplo n.º 12
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);
            });
        }
Exemplo n.º 13
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));
                        }
                    }
                }
            });
        }
Exemplo n.º 14
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
            });
        }
Exemplo n.º 15
0
        partial void InitialiseOption()
        {
            switch (type)
            {
                #region Basics
            case MsgType.Main:
                options = new List <string>
                {
                    EUI.explore, EUI.tpost, EUI.help
                };
                break;

            case MsgType.Sheet:
                options = new List <string>
                {
                    EUI.stats, EUI.xp,
                    EUI.loot, EUI.help
                };
                break;

            case MsgType.Stats:
                options = new List <string>
                {
                    loot, explore, tpost
                    //help
                };
                break;

            case MsgType.XP:
            {
                options = new List <string>
                {
                    loot, ability
                    //help
                };
                if (player.skillPoints > 0)
                {
                    options.Add(skills);
                }
                if (player.Specialization != null)
                {
                    options.Add(EUI.SpecIcon(
                                    (int)player.Specialization.specType));
                }
                else if (player.level > 19)
                {
                    options.Add(pickSpec);
                }
            }
            break;

            case MsgType.Skills:
                options = new List <string>
                {
                    GetLetter(4), GetLetter(8), GetLetter(18),
                    GetLetter(2), GetLetter(3), GetLetter(15),
                    //help
                };
                break;

            case MsgType.Schems:
                options = new List <string>
                {
                    prev, next
                };
                break;

            case MsgType.Loot:
            {
                options = new List <string>
                {
                    prev, next, loot, inv,
                    explore, help
                };
                if (player.Encounter != null)
                {
                    int.TryParse(data, out int page);
                    var ploot = player.Encounter.loot;
                    if (ploot != null)
                    {
                        if (ploot.Count < 30 ||
                            page <= 0)
                        {
                            options.Remove(prev);
                        }
                        if (ploot.Count < 16 || page + 1
                            >= (Math.Ceiling(ploot.Count / 25.00)))
                        {
                            options.Remove(next);
                        }
                    }
                }
            }
            break;

            case MsgType.Puzzle: options = player.Encounter.puzzle.emotes.ToList(); break;
                #endregion

                #region Pets
            case MsgType.EggPocket:
                options = new List <string>()
                {
                    pets, cancel,     //discard egg
                };
                break;

            case MsgType.EggInfo:
                //when a new egg is found
                options = new List <string>()
                {
                    egg,     //pickup
                };
                break;

            case MsgType.InspectPet:
            {
                switch (player.PetList[int.Parse(data)].status)
                {
                case NPCSystems.Companions.Pets.Pet.PetStatus.Idle:
                    options = new List <string>()
                    {
                        EUI.summon, EUI.skills, EUI.whistle, EUI.pickSpec
                    }; break;

                case NPCSystems.Companions.Pets.Pet.PetStatus.Fetching:
                    options = new List <string>()
                    {
                        EUI.whistle
                    }; break;
                }
            }
            break;

            case MsgType.PetList:
            {
                options = new List <string>();
                for (int i = 0; i < player.PetList.Count; i++)
                {
                    options.Add(GetNum(i));
                }
            }
            break;

            case MsgType.PetUpgrade:
            {
                options = new List <string>()
                {
                    uturn
                };
                int      k     = -1;
                string[] split = data.Split(';');
                if (split.Length > 1)
                {
                    int.TryParse(data.Split(';')[1], out k);
                }

                if (k > -1 && k < 2)
                {
                    options.Add(greaterthan);
                }
                else
                {
                    int max = k > -1 ? ReferenceData.DmgType.Length :
                              Enum.GetNames(typeof(NPCSystems.Companions.Pets.PetUpgrades.Upgrade)).Length;
                    for (int i = 0; i < max; i++)
                    {
                        options.Add(k > -1 ? GetElement((ReferenceData.DamageType)i) : GetNum(i));
                    }
                }
            }
            break;

            case MsgType.PetEvolve:
                options = new List <string>();
                int count = int.Parse(data.Split(';')[1]);
                for (int i = 0; i < count; i++)
                {
                    options.Add(GetNum(i));
                }
                break;
                #endregion

                #region NPCs
            case MsgType.NPC:
            {
                options = new List <string>
                {
                    inv, stats, explore,
                    help
                };
                if (player.Encounter != null &&
                    player.Encounter.npc != null && player.Encounter.npc.inventory != null &&
                    player.Encounter.npc.inventory.Count >= 1)
                {
                    options.Insert(0, trade);
                }
            }
            break;

            case MsgType.NPCInv:
            {
                options = new List <string>
                {
                    stats, inv, help
                };
                if (player.Encounter != null && player.Encounter.npc != null &&
                    player.Encounter.npc.inventory != null &&
                    player.Encounter.npc.inventory.Count > 15)
                {
                    options.Insert(0, next);
                    options.Insert(0, prev);
                }
            }
            break;
                #endregion

                #region Combat
            case MsgType.Combat:
            {
                options = new List <string>
                {
                    ability, help
                };
                if (player != null)
                {
                    if (player.IsEncounter("Combat"))
                    {
                        options.Insert(0, brawl);
                        if (player.Encounter.Name != Encounter.Names.PVP)
                        {
                            options.Insert(1, run);
                        }
                    }
                }
            }
            break;
                #endregion

                #region Character Set Up
            case MsgType.SetSkill:
            {
                options = new List <string>();
                string[] arrays = data.Split(';');
                bool[]   rused  = Utils.JSON <bool[]>(arrays[1]);
                for (int i = 0; i < 6; i++)
                {
                    if (!rused[i])
                    {
                        options.Add(GetLetter(i));
                    }
                }
            }
            break;

            case MsgType.ChooseRace:
            {
                options = new List <string>()
                {
                    GetLetter(7), GetLetter(19), GetLetter(20),
                    GetLetter(12), GetLetter(8)
                };
            }
            break;

            case MsgType.AbilityLevel:
            {
                Ability a = player.abilities[int.Parse(data)];
                if (a.level >= a.maxLevel && a.evolves != null)
                {
                    options = new List <string>();
                    for (int i = 0; i < a.evolves.Length; i++)
                    {
                        options.Add(GetNum(i));
                    }
                }
                else
                {
                    options = new List <string>()
                    {
                        stats
                    }
                };
            }
            break;

            case MsgType.StarterAbilities:
            {
                options = new List <string>();
                string[] split = data.Split('/');
                int      p     = int.Parse(split[0]);
                int      x     = int.Parse(split[1]);
                int      z     = int.Parse(split[2]);
                if (p != 0)
                {
                    options.Add(prev);
                }
                if (p != 2)
                {
                    options.Add(next);
                }
                for (int i = 0; i < 3; i++)
                {
                    if (z != p || (z == p && i != x))
                    {
                        options.Add(GetNum(i));
                    }
                }
            }
            break;

            case MsgType.AutoNewCharacter:
                options = new List <string>()
                {
                    ok, next, info
                };
                break;
                #endregion

                #region Area
            case MsgType.PetShop:
            {
                options = new List <string>()
                {
                };
                if (data != null && data.Length > 2)
                {
                    options.Add(mainQuest);
                }
            }
            break;

            case MsgType.Tavern:
            {
                options = new List <string>()
                {
                    bounties, sideQuest, Dice(1),
                };
            }
            break;

            case MsgType.Junctions:
            {
                string[] args1   = data.Split(';');
                int      page    = int.Parse(args1[0]);
                int      total   = int.Parse(args1[1]);
                string[] juncIds = Utils.JSON <string[]>(args1[2]);
                options = new List <string>();
                //
                if (page > 0)
                {
                    options.Add(prev);
                }
                if (juncIds.Length >= 5 && page * 5 < total)
                {
                    options.Add(next);
                }
                for (int i = 0; i < juncIds.Length; i++)
                {
                    options.Add(GetNum(i));
                }
            }
            break;
                #endregion

                #region Arena
            case MsgType.ArenaGameMode:
            {
                options = new List <string>()
                {
                    prev, ok, cancel, next
                };
            }
            break;

            case MsgType.ArenaModifiers:
            {
                //          0       1   2    3    4
                //date = gameMode;page;bool,bool,bool
                string[] args = data.Split(';');

                int.TryParse(args[1], out int i);
                bool.TryParse(args[2].Split(',')[i], out bool b);

                options = new List <string>()
                {
                    uturn, prev,
                    b ? cancel : ok,
                    next,
                    enterFloor
                };
            }
            break;
                #endregion

                #region Social
            case MsgType.OfferList:
            {
                string[] args2 = data.Split('.');
                int      page  = int.Parse(args2[0]);
                int      total = int.Parse(args2[1]);
                Guid[]   guids = Utils.JSON <Guid[]>(args2[3]);
                options = new List <string>();
                if (page > 0)
                {
                    options.Add(prev);
                }
                if ((page + 1) * 5 <= total)
                {
                    options.Add(next);
                }
                if (guids.Length >= 5)
                {
                    options.AddRange(new[] { one, two, three, four, five });
                }
                for (int i = 0; i < guids.Length; i++)
                {
                    options.Add(GetNum(i + 1));
                }
            }
            break;
                #endregion

                #region Specs
            case MsgType.SpecSelection:
            {
                options = new List <string>();
                string[] args = data.Split(';');
                foreach (string s in args)
                {
                    if (int.TryParse(s, out int i))
                    {
                        options.Add(specs[i]);
                    }
                }
            }
            break;

            case MsgType.SpecPerks:
            case MsgType.SpecAbility:
            {
                string[] itemIndexes = data.Split(';');
                options = new List <string>()
                {
                    uturn
                };
                foreach (string s in itemIndexes)
                {
                    if (int.TryParse(s, out int i))
                    {
                        options.Add(GetNum(i));
                    }
                }
            }
            break;

            case MsgType.SpecMain:
                options = new List <string>()
                {
                    EUI.classAbility, EUI.classPerk
                };
                break;
                #endregion

                #region Crates
            case MsgType.ResourceCrateList:
                options = new List <string>()
                {
                    GetNum(0),
                    GetNum(1),
                    GetNum(2),
                    GetNum(3),
                    GetNum(4),
                };
                break;

            case MsgType.ResourceCrateOpening:
            {
                int cAmount = int.Parse(data.Split(';')[1]);
                options = new List <string>();
                for (int i = 0; i < cAmount; i++)
                {
                    options.Add(GetNum(i));
                }
            }
            break;
                #endregion

                #region Quests
            case MsgType.QuestInfo:
            {
                int.TryParse(data, out int index);
                options = new List <string>()
                {
                    uturn
                };
                if (index > 0)
                {
                    options.Add(prev);
                }
                if (index < player.quests.Count - 1)
                {
                    options.Add(next);
                }
            }
            break;

            case MsgType.QuestList:
            {
                int.TryParse(data, out int page);

                options = new List <string>();
                if (page > 0)
                {
                    options.Add(prev);
                }
                int perpage = Items.Quests.Quest.PerPage;
                for (int i = 0; i < perpage && (page * perpage) + i < player.quests.Count; i++)
                {
                    options.Add(GetNum(i));
                }
                if (page < player.quests.Count / Items.Quests.Quest.PerPage)
                {
                    options.Add(next);
                }
            }
            break;

            case MsgType.AcceptQuests:
            {
                //data = id1,id2,id3;id1,id2,id3...
                int questAmount = data.Split(';').Length - 1;
                options = new List <string>();
                for (int i = 0; i < questAmount; i++)
                {
                    options.Add(GetNum(i));
                }
            }
            break;

            case MsgType.DailyQuestBoard:
            {
                options = new List <string>();
                string[] nums = data.Split(';');

                for (int i = 0; i < nums.Length; i++)
                {
                    if (int.TryParse(nums[i], out int k))
                    {
                        options.Add(GetNum(k));
                    }
                }
            }
            break;
                #endregion

                #region Next/Previous Only
            case MsgType.BountyBoard:

                #endregion

                #region Okay/Cancel Only
            case MsgType.NPCRepair:
            case MsgType.ConfirmTransaction:
            case MsgType.ConfirmSkills:
            case MsgType.ConfirmCharDel:
            case MsgType.EndRest:
            case MsgType.ConfirmUpgrade:
            case MsgType.PartyInvite:
            case MsgType.ConfirmOffer:
            case MsgType.InspectOffer:
            case MsgType.DuelOffer:
            case MsgType.ComfirmTile:
            case MsgType.ConfirmEggDiscard:
            case MsgType.DynastyUpgrade:
            case MsgType.DynastyInvite:
                options = new List <string> {
                    ok, cancel
                };
                break;
                #endregion

                #region Other
            case MsgType.Lottery:
                options = new List <string>()
                {
                    ticket
                };
                break;
                #endregion

            default:
                if (OptionsLoad.ContainsKey(type))
                {
                    OptionsLoad[type].Invoke(this);
                }
                break;
            }
        }
Exemplo n.º 16
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);
                }
            }
        }
Exemplo n.º 17
0
        public async Task <UI> Edit(Player player, string content, Embed embed, MsgType type, string data, bool editEmotes = true)
        {
            this.type   = type;
            this.player = player;
            this.data   = data;

            //Edit Message
            IUserMessage msg = await GetUiMessage();

            await msg.ModifyAsync(x =>
            {
                x.Content = content;
                x.Embed   = embed;
            });


            if (editEmotes)
            {
                List <string> oldops = options;
                InitialiseOption();
                VerifyOptions();

                oldops.RemoveAll(e => options.Contains(e));
                _ = msg.RemoveReactionsAsync(Handlers.DiscordBotHandler.Client.CurrentUser, oldops.Select(x => EUI.ToEmote(x)).ToArray());

                LoadOptions(msg);
            }

            return(this);
        }
Exemplo n.º 18
0
 internal Task RemoveReaction(string e, IUserMessage msg = null,
                              SocketSelfUser bot         = null) => RemoveReaction(EUI.ToEmote(e), msg, bot);