Ejemplo n.º 1
0
 public static Models.GameContext.Warehouse GetVaultByUser(string account)
 {
     using (var c = new GameDbContext())
     {
         return c.Vaults.Find(account);
     }
 }
Ejemplo n.º 2
0
        public static List<Models.GameContext.Guild> GetRankings(int topNumber = 0, Models.GameContext.GuildRankingOrderBy orderBy = GuildRankingOrderBy.Score)
        {
            List<Models.GameContext.Guild> guilds = new List<Models.GameContext.Guild>();

            using (var context = new GameDbContext())
            {
                guilds = context.Guilds.ToList();

                if(orderBy == GuildRankingOrderBy.Name)
                {
                    guilds = guilds.OrderByDescending(x => x.G_Name).ToList();
                }

                if(orderBy == GuildRankingOrderBy.Score)
                {
                    guilds = guilds.OrderByDescending(x => x.G_Score).ToList();
                }

                if(topNumber > 0)
                {
                    guilds = guilds.Take(topNumber).ToList();
                }
            }

            return guilds;
        }
Ejemplo n.º 3
0
        public static List<Models.GameContext.Item> GetVaultItemsToList(string account)
        {
            List<Models.GameContext.Item> list = new List<Models.GameContext.Item>();

            using (var c = new GameDbContext())
            {
                var bau = c.Vaults.Find(account);
                if (bau != null)
                {
                    int len = bau.Items.Length;
                    int lts = 16;
                    for (int i = 0; i < len; i = i + lts)
                    {
                        byte[] temp = new byte[lts];
                        if (len < i + lts)
                        {
                            lts = len - i;
                        }

                        Array.Copy(bau.Items, i, temp, 0, lts);
                        string hex_tmp = Models.GameContext.Item.ByteArrayToString(temp);
                        list.Add(Item.CreateFromHex(Models.GameContext.Item.ByteArrayToString(temp)));
                    }
                }
            }
            return list;
        }
Ejemplo n.º 4
0
 public static ICollection<Models.GameContext.Character> GetCharsByUser(string user)
 {
     using (var c = new GameDbContext())
     {
         return c.Characters.Where(a => a.AccountID == user).ToArray<Models.GameContext.Character>();
     }
 }
Ejemplo n.º 5
0
 public static Models.GameContext.Guild Get(string name)
 {
     using (var c = new GameDbContext())
     {
         var guild = c.Guilds.Where(a => a.G_Name == name).FirstOrDefault();
         return guild;
     }
 }
Ejemplo n.º 6
0
 public static Models.GameContext.Account VerifyLogin(string user, string pass)
 {
     using (var db = new GameDbContext())
     {
         var u = db.Accounts.Where(x => x.memb___id == user && x.memb__pwd == pass).FirstOrDefault();
         return u;
     }
 }
Ejemplo n.º 7
0
 public static void Update(Models.GameContext.Account user)
 {
     using (var c = new GameDbContext())
     {
         c.Entry(user).State = System.Data.Entity.EntityState.Modified;
         c.SaveChanges();
     }
 }
Ejemplo n.º 8
0
 public static void Create(Models.GameContext.Account user)
 {
     using (var c = new GameDbContext())
     {
         c.Accounts.Add(user);
         c.SaveChanges();
     }
 }
Ejemplo n.º 9
0
 public static Models.GameContext.Character Get(string name)
 {
     using (var c = new GameDbContext())
     {
         var person = c.Characters.Where(a => a.Name == name).FirstOrDefault();
         return person;
     }
 }
Ejemplo n.º 10
0
        public static List<Models.GameContext.Character> GetRankings(int topNumber = 0, Models.GameContext.CharacterRankingType rankType = CharacterRankingType.All, Models.GameContext.CharacterRankingOrderBy orderBy = CharacterRankingOrderBy.Resets)
        {
            List<Models.GameContext.Character> chars = new List<Models.GameContext.Character>();

            if (topNumber > 0)
            {
                if (topNumber > 300)
                    topNumber = 300;
            }

            using (var context = new GameDbContext())
            {
                if(rankType != CharacterRankingType.All)
                {
                    int firstClass, lastClass;
                    switch (rankType)
                    {
                        case CharacterRankingType.OnlyBk:
                            firstClass = 16;
                            lastClass = 19;
                            break;
                        case CharacterRankingType.OnlySm:
                            firstClass = 0;
                            lastClass = 3;
                            break;
                        case CharacterRankingType.OnlyElf:
                            firstClass = 32;
                            lastClass = 35;
                            break;
                        case CharacterRankingType.OnlySum:
                            firstClass = 80;
                            lastClass = 83;
                            break;
                        case CharacterRankingType.OnlyMg:
                            firstClass = 48;
                            lastClass = 50;
                            break;
                        case CharacterRankingType.OnlyDl:
                            firstClass = 64;
                            lastClass = 66;
                            break;
                        case CharacterRankingType.OnlyRf:
                            firstClass = 96;
                            lastClass = 98;
                            break;
                        default:
                            return null;
                    }

                    if (orderBy == CharacterRankingOrderBy.Resets)
                    {
                        chars = context.Characters.Where(cr => cr.Class >= firstClass && cr.Class <= lastClass).OrderByDescending(c => c.Resets)
                                     .ThenByDescending(c => c.GrandResets)
                                     .ThenByDescending(c => c.cLevel).Take(topNumber).ToList();
                    }

                    if (orderBy == CharacterRankingOrderBy.GResets)
                    {
                        chars = context.Characters.Where(cr => cr.Class >= firstClass && cr.Class <= lastClass).OrderByDescending(c => c.GrandResets)
                                     .ThenByDescending(c => c.Resets)
                                     .ThenByDescending(c => c.cLevel).Take(topNumber).ToList();
                    }

                    if (orderBy == CharacterRankingOrderBy.Level)
                    {
                        chars = context.Characters.Where(cr => cr.Class >= firstClass && cr.Class <= lastClass).OrderByDescending(c => c.cLevel)
                                     .ThenByDescending(c => c.Resets)
                                     .ThenByDescending(c => c.Experience).Take(topNumber).ToList();
                    }

                    if (orderBy == CharacterRankingOrderBy.Exp)
                    {
                        chars = context.Characters.Where(cr => cr.Class >= firstClass && cr.Class <= lastClass).OrderByDescending(c => c.Experience)
                                     .ThenByDescending(c => c.cLevel)
                                     .ThenByDescending(c => c.Resets).Take(topNumber).ToList();
                    }

                    if (orderBy == CharacterRankingOrderBy.Zen)
                    {
                        chars = context.Characters.Where(cr => cr.Class >= firstClass && cr.Class <= lastClass).OrderByDescending(c => c.Money).Take(topNumber).ToList();
                    }
                }
                else
                {
                    if (orderBy == CharacterRankingOrderBy.Resets)
                    {
                        chars = context.Characters.OrderByDescending(c => c.Resets)
                                     .ThenByDescending(c => c.GrandResets)
                                     .ThenByDescending(c => c.cLevel).Take(topNumber).ToList();
                    }

                    if (orderBy == CharacterRankingOrderBy.GResets)
                    {
                        chars = context.Characters.OrderByDescending(c => c.GrandResets)
                                     .ThenByDescending(c => c.Resets)
                                     .ThenByDescending(c => c.cLevel).Take(topNumber).ToList();
                    }

                    if (orderBy == CharacterRankingOrderBy.Level)
                    {
                        chars = context.Characters.OrderByDescending(c => c.cLevel)
                                     .ThenByDescending(c => c.Resets)
                                     .ThenByDescending(c => c.Experience).Take(topNumber).ToList();
                    }

                    if (orderBy == CharacterRankingOrderBy.Exp)
                    {
                        chars = context.Characters.OrderByDescending(c => c.Experience)
                                     .ThenByDescending(c => c.cLevel)
                                     .ThenByDescending(c => c.Resets).Take(topNumber).ToList();
                    }

                    if (orderBy == CharacterRankingOrderBy.Zen)
                    {
                        chars = context.Characters.OrderByDescending(c => c.Money).Take(topNumber).ToList();
                    }
                }
            }

            return chars;
        }
Ejemplo n.º 11
0
        public static bool IsCharacterFromUser(string user, string character)
        {
            using (var c = new GameDbContext())
            {
                AccountCharacter ac = c.AccountChars.Find(user);

                if (ac.GameID1 != null && ac.GameID1.Equals(character))
                    return true;
                if (ac.GameID2 != null && ac.GameID2.Equals(character))
                    return true;
                if (ac.GameID3 != null && ac.GameID3.Equals(character))
                    return true;
                if (ac.GameID4 != null && ac.GameID4.Equals(character))
                    return true;
                if (ac.GameID5 != null && ac.GameID5.Equals(character))
                    return true;
            }
            return false;
        }