Exemplo n.º 1
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 4:
                FailedLockpick   = reader.ReadBool();
                _Quality         = (ChestQuality)reader.ReadInt();
                DigTime          = reader.ReadDateTime();
                AncientGuardians = reader.ReadStrongMobileList();
                goto case 3;

            case 3:
                FirstOpenedByOwner = reader.ReadBool();
                TreasureMap        = reader.ReadItem() as TreasureMap;
                goto case 2;

            case 2:
            {
                Guardians = reader.ReadStrongMobileList();
                Temporary = reader.ReadBool();

                goto case 1;
            }

            case 1:
            {
                Owner = reader.ReadMobile();

                goto case 0;
            }

            case 0:
            {
                Level      = reader.ReadInt();
                DeleteTime = reader.ReadDeltaTime();
                m_Lifted   = reader.ReadStrongItemList();

                if (version < 2)
                {
                    Guardians = new List <Mobile>();
                }

                break;
            }
            }

            if (!Temporary)
            {
                Timer = new DeleteTimer(this, DeleteTime);
                Timer.Start();
            }
            else
            {
                Delete();
            }
        }
Exemplo n.º 2
0
        public async Task GiveChest(ChestQuality cq, SocketUser user = null)
        {
            var inv = UserAccounts.GetAccount(user ?? Context.User).Inv;

            inv.AwardChest(cq);
            await Task.CompletedTask;
        }
Exemplo n.º 3
0
        private static ChestQuality GetRandomChest(BattleDifficulty diff)
        {
            ChestQuality[] chests;
            switch (diff)
            {
            case BattleDifficulty.Tutorial:
                chests = new ChestQuality[] { ChestQuality.Wooden };
                return(chests.Random());

            case BattleDifficulty.Easy:
            default:
                chests = new ChestQuality[] { ChestQuality.Wooden, ChestQuality.Wooden, ChestQuality.Normal, ChestQuality.Normal, ChestQuality.Normal, ChestQuality.Normal, ChestQuality.Normal, ChestQuality.Silver };
                break;

            case BattleDifficulty.Medium:
                chests = new ChestQuality[] { ChestQuality.Normal, ChestQuality.Normal, ChestQuality.Normal, ChestQuality.Normal, ChestQuality.Normal, ChestQuality.Silver, ChestQuality.Silver, ChestQuality.Gold };
                break;

            case BattleDifficulty.MediumRare:
                chests = new ChestQuality[] { ChestQuality.Silver, ChestQuality.Silver, ChestQuality.Silver, ChestQuality.Gold, ChestQuality.Gold };
                break;

            case BattleDifficulty.Hard:
                chests = new ChestQuality[] { ChestQuality.Silver, ChestQuality.Gold, ChestQuality.Gold, ChestQuality.Gold, ChestQuality.Gold, ChestQuality.Adept };
                break;
            }
            return(chests.Random());
        }
Exemplo n.º 4
0
        public void AwardChest(ChestQuality chestQuality)
        {
            chests.TryGetValue(chestQuality, out uint nOfChests);

            chests.Remove(chestQuality);
            chests.Add(chestQuality, ++nOfChests);
            UserAccounts.SaveAccounts();
        }
        public async Task GiveChest(ChestQuality cq, SocketUser user = null)
        {
            var account = EntityConverter.ConvertUser(user ?? Context.User);
            var inv     = account.Inv;

            inv.AwardChest(cq);
            UserAccountProvider.StoreUser(account);
            await Task.CompletedTask;
        }
Exemplo n.º 6
0
        public bool OpenChest(ChestQuality chestQuality)
        {
            CheckDaily();
            chests.TryGetValue(chestQuality, out uint nOfChests);

            if (nOfChests == 0)
            {
                return(false);
            }

            chests.Remove(chestQuality);
            chests.Add(chestQuality, nOfChests - 1);
            return(true);
        }
        private async Task OpenChestAsync(SocketCommandContext Context, ChestQuality cq)
        {
            var user = EntityConverter.ConvertUser(Context.User);
            var inv  = user.Inv;

            if (inv.IsFull)
            {
                var emb = new EmbedBuilder();
                emb.WithDescription(":x: Inventory capacity reached!");
                emb.WithColor(Colors.Get("Error"));
                await Context.Channel.SendMessageAsync("", false, emb.Build());

                return;
            }

            if (!inv.OpenChest(cq))
            {
                var emb = new EmbedBuilder();

                if (cq == ChestQuality.Daily)
                {
                    emb.WithDescription($":x: No {cq} Chests remaining! Next Daily Chest in: {DateTime.Today.AddDays(1).Subtract(DateTime.Now):hh\\h\\ mm\\m}");
                }
                else
                {
                    emb.WithDescription($":x: No {cq} Chests remaining!");
                }

                emb.WithColor(Colors.Get("Error"));
                await Context.Channel.SendMessageAsync("", false, emb.Build());

                return;
            }
            var itemName     = "";
            var dailyRewards = new[] { 0, 0, 1, 1, 2 };

            if (cq == ChestQuality.Daily)
            {
                var value = user.LevelNumber;
                itemName = ItemDatabase.GetRandomItem((ItemRarity)(dailyRewards[inv.DailiesInARow % dailyRewards.Length] + Math.Min(2, value / 33)));
            }
            else
            {
                var rarity = ItemDatabase.ChestValues[cq].GenerateReward();
                itemName = ItemDatabase.GetRandomItem(rarity);
            }

            var item = ItemDatabase.GetItem(itemName);

            inv.Add(item.Name);
            UserAccountProvider.StoreUser(user);

            var embed = new EmbedBuilder();

            embed.WithDescription($"Opening {cq} Chest {Inventory.ChestIcons[cq]}...");

            embed.WithColor(Colors.Get("Iodem"));
            var msg = await Context.Channel.SendMessageAsync("", false, embed.Build());

            embed = new EmbedBuilder();
            embed.WithColor(item.Color);
            if (cq == ChestQuality.Daily)
            {
                embed.WithFooter($"Current Reward: {inv.DailiesInARow % dailyRewards.Length + 1}/{dailyRewards.Length} | Overall Streak: {inv.DailiesInARow + 1}");
            }
            embed.WithDescription($"{Inventory.ChestIcons[cq]} You found a {item.Name} {item.IconDisplay}");

            await Task.Delay((int)cq * 700);

            _ = msg.ModifyAsync(m => m.Embed = embed.Build());

            var message = await Context.Channel.AwaitMessage(m => m.Author == Context.User);

            if (message != null && message.Content.Equals("Sell", StringComparison.OrdinalIgnoreCase))
            {
                _ = SellItem(item.Name);
            }
        }
 public async Task OpenChest(ChestQuality cq)
 {
     _ = OpenChestAsync(Context, cq);
     await Task.CompletedTask;
 }
Exemplo n.º 9
0
        private async Task OpenChestAsync(SocketCommandContext Context, ChestQuality cq, uint bonusCount = 0)
        {
            var user = UserAccounts.GetAccount(Context.User);
            var inv  = user.Inv;

            if (inv.IsFull)
            {
                var emb = new EmbedBuilder();
                emb.WithDescription(":x: Inventory capacity reached!");
                emb.WithColor(Colors.Get("Error"));
                await Context.Channel.SendMessageAsync("", false, emb.Build());

                return;
            }

            if (!inv.RemoveBalance(bonusCount))
            {
                var emb = new EmbedBuilder();
                emb.WithDescription(":x: Not enough Funds!");
                emb.WithColor(Colors.Get("Error"));
                await Context.Channel.SendMessageAsync("", false, emb.Build());

                return;
            }

            if (!inv.OpenChest(cq))
            {
                var emb = new EmbedBuilder();

                if (cq == ChestQuality.Daily)
                {
                    emb.WithDescription($":x: No {cq} Chests remaining! Next Daily Chest in: {DateTime.Today.AddDays(1).Subtract(DateTime.Now).ToString(@"hh\h\ mm\m")}");
                }
                else
                {
                    emb.WithDescription($":x: No {cq} Chests remaining!");
                }

                emb.WithColor(Colors.Get("Error"));
                await Context.Channel.SendMessageAsync("", false, emb.Build());

                return;
            }

            double bonus = (bonusCount > 0 ? Math.Log(bonusCount) / Math.Log(5) : 0);
            var    value = user.LevelNumber;

            if (cq != ChestQuality.Daily)
            {
                value = (((uint)cq) + 1) * 11;
            }

            var itemName = ItemDatabase.GetRandomItem(value, bonus, (int)cq == 3 || (int)cq == 4 || ((int)cq == 5 && value >= 40) ? ItemDatabase.RandomItemType.Artifact : ItemDatabase.RandomItemType.Any);
            var item     = ItemDatabase.GetItem(itemName);

            var embed = new EmbedBuilder();

            embed.WithDescription($"Opening {cq} Chest {Inventory.ChestIcons[cq]}...");
            embed.WithColor(Colors.Get("Iodem"));
            var msg = await Context.Channel.SendMessageAsync("", false, embed.Build());

            embed = new EmbedBuilder();
            embed.WithColor(item.Color);
            embed.WithDescription($"{Inventory.ChestIcons[cq]} You found a {item.Name} {item.IconDisplay}");
            await Task.Delay((int)cq * 700);

            _ = msg.ModifyAsync(m => m.Embed = embed.Build());
            inv.Add(item.Name);
        }
Exemplo n.º 10
0
        internal static async Task UserWonBattle(UserAccount userAccount, int winsInARow, int LureCaps, BattleStats battleStats, BattleDifficulty diff, ITextChannel lobbyChannel, IEnumerable <ColossoFighter> winners, bool wasMimic)
        {
            uint oldLevel  = userAccount.LevelNumber;
            var  baseXP    = 20 + 5 * LureCaps + winsInARow / 4;
            var  xpawarded = (uint)new Random().Next(baseXP, baseXP * 2) * Math.Max(3, (uint)Math.Pow((int)diff + 1, 2));

            userAccount.XP += xpawarded;
            userAccount.Inv.AddBalance(xpawarded / 2);
            uint newLevel = userAccount.LevelNumber;

            userAccount.ServerStats.ColossoWins++;
            userAccount.ServerStats.ColossoStreak++;
            userAccount.ServerStats.ColossoHighestStreak = Math.Max(userAccount.ServerStats.ColossoHighestStreak, userAccount.ServerStats.ColossoStreak);
            switch (battleStats.TotalTeamMates)
            {
            case 0:
                userAccount.ServerStats.ColossoHighestRoundEndlessSolo = Math.Max(userAccount.ServerStats.ColossoHighestRoundEndlessSolo, winsInARow);
                break;

            case 1:
                if (winsInARow > userAccount.ServerStats.ColossoHighestRoundEndlessDuo)
                {
                    userAccount.ServerStats.ColossoHighestRoundEndlessDuo      = winsInARow;
                    userAccount.ServerStats.ColossoHighestRoundEndlessDuoNames = string.Join(", ", winners.Select(p => p.Name));
                }
                break;

            case 2:
                if (winsInARow > userAccount.ServerStats.ColossoHighestRoundEndlessTrio)
                {
                    userAccount.ServerStats.ColossoHighestRoundEndlessTrio      = winsInARow;
                    userAccount.ServerStats.ColossoHighestRoundEndlessTrioNames = string.Join(", ", winners.Select(p => p.Name));
                }
                break;

            case 3:
                if (winsInARow > userAccount.ServerStats.ColossoHighestRoundEndlessQuad)
                {
                    userAccount.ServerStats.ColossoHighestRoundEndlessQuad      = winsInARow;
                    userAccount.ServerStats.ColossoHighestRoundEndlessQuadNames = string.Join(", ", winners.Select(p => p.Name));
                }
                break;
            }

            userAccount.BattleStats += battleStats;
            _ = UnlockClasses(userAccount, lobbyChannel);

            if (wasMimic || Global.Random.Next(0, 100) <= 7 + battleStats.TotalTeamMates * 2 + 4 * LureCaps + winsInARow / 10 - 1)
            {
                ChestQuality awardedChest = GetRandomChest(diff);
                userAccount.Inv.AwardChest(awardedChest);
                var embed = new EmbedBuilder();
                embed.WithColor(Colors.Get("Iodem"));
                embed.WithDescription($"{((SocketTextChannel)lobbyChannel).Users.Where(u => u.Id == userAccount.ID).FirstOrDefault().Mention} found a {Inventory.ChestIcons[awardedChest]} {awardedChest} Chest!");
                await lobbyChannel.SendMessageAsync("", false, embed.Build());
            }

            UserAccounts.SaveAccounts();
            if (oldLevel != newLevel)
            {
                var user = (SocketGuildUser)await lobbyChannel.GetUserAsync(userAccount.ID); // Where(s => s. == userAccount.ID).First();

                Leveling.LevelUp(userAccount, user, (SocketTextChannel)lobbyChannel);
            }

            await Task.CompletedTask;
        }
Exemplo n.º 11
0
 internal bool HasChest(ChestQuality cq)
 {
     CheckDaily();
     return(chests[cq] > 0);
 }