Beispiel #1
0
        private static void Handle(Player player)
        {
            var cli = player.Client;

            if (cli.Account.RaidToken < 1)
            {
                player.SendError("You do not have an Alert to launch.");
                return;
            }

            if (cli.Account.Credits < 1000)
            {
                player.SendError("You do not have the required amount of gold to launch an Alert.");
                return;
            }

            var rnd = new Random();

            cli.Manager.Database.UpdateAlertToken(cli.Account, -1);
            player.AlertToken--;
            player.ForceUpdate(player.AlertToken);

            player.SendHelp("Launching Alert... Good luck!");
            var alertArea = player.Owner.Manager.Resources.Worlds[AlertAreas[rnd.Next(AlertAreas.Length)]];

            DynamicWorld.TryGetWorld(alertArea, player.Client, out var world);
            world = player.Owner.Manager.AddWorld(world ?? new World(alertArea));

            player.Owner.Timers.Add(new WorldTimer(8000, (w, t) => {
                player.Client.Reconnect(new Reconnect {
                    Host        = "",
                    Port        = 2050,
                    GameId      = world.Id,
                    Name        = world.SBName,
                    IsFromArena = false
                });
            }));
        }
        void Handle(Player player, RealmTime time, UnboxRequest packet)
        {
            var acc = player.Client.Account;

            switch (packet.lootboxType)
            {
            case 1:
                if (player.BronzeLootbox >= 1)
                {
                    player.Client.Manager.Database.UpdateBronzeLootbox(acc, -1);
                    player.BronzeLootbox -= 1;
                    player.ForceUpdate(player.BronzeLootbox);
                    player.Unbox(1);
                }
                else
                {
                    player.SendError("You do not have any lootboxes to open!");
                }
                break;

            case 2:
                if (player.SilverLoootbox >= 1)
                {
                    player.Client.Manager.Database.UpdateSilverLootbox(acc, -1);
                    player.SilverLoootbox -= 1;
                    player.ForceUpdate(player.SilverLoootbox);
                    player.Unbox(2);
                }
                else
                {
                    player.SendError("You do not have any lootboxes to open!");
                }
                break;

            case 3:
                if (player.GoldLootbox >= 1)
                {
                    player.Client.Manager.Database.UpdateGoldLootbox(acc, -1);
                    player.GoldLootbox -= 1;
                    player.ForceUpdate(player.GoldLootbox);
                    player.Unbox(3);
                }
                else
                {
                    player.SendError("You do not have any lootboxes to open!");
                }
                break;

            case 4:
                if (player.EliteLootbox >= 1 && player.Onrane >= 5)
                {
                    player.Client.Manager.Database.UpdateEliteLootbox(acc, -1);
                    player.Client.Manager.Database.UpdateOnrane(acc, -5);
                    player.EliteLootbox -= 1;
                    player.Onrane        = player.Client.Account.Onrane - 5;
                    player.ForceUpdate(player.Onrane);
                    player.ForceUpdate(player.EliteLootbox);
                    player.Unbox(4);
                }
                else
                {
                    player.SendError("You do not have any lootboxes to open or you don't have the sufficient amount of onrane!");
                }
                break;

            case 5:
                if (player.Kantos >= 600)
                {
                    player.Client.Manager.Database.UpdateKantos(acc, -600);
                    player.Kantos = player.Client.Account.Kantos - 600;
                    player.ForceUpdate(player.Kantos);
                    player.Unbox(5);
                }
                else
                {
                    player.SendError("You do not have the sufficient amount of Kantos to open this box.");
                }
                break;
            }
        }