Exemple #1
0
        public void SelectCategory(Top100Category category)
        {
            var item = Top100SubList.Items.FirstOrDefault(x => ((Top100CategoryListItem)x.Data).Category == category);

            if (Top100SubList.SelectedItem != item)
            {
                Top100SubList.SelectedItem = item;
            }
        }
        /// <summary>
        /// In the original game the icons were transmitted from the server. However, unless we plan to change
        /// the categories often this is not really necessary
        /// </summary>
        /// <param name="category"></param>
        /// <returns></returns>
        ITextureRef GetCategoryIcon(Top100Category category)
        {
            switch (category)
            {
            case Top100Category.lot_money:
                return(Content.UIGraphics.Get(0x00000B3B00000001));

            case Top100Category.lot_offbeat:
                return(Content.UIGraphics.Get(0x00000B3C00000001));

            case Top100Category.lot_romance:
                return(Content.UIGraphics.Get(0x00000B3D00000001));

            case Top100Category.lot_services:
                return(Content.UIGraphics.Get(0x00000B3E00000001));

            case Top100Category.lot_shopping:
                return(Content.UIGraphics.Get(0x00000B3F00000001));

            case Top100Category.lot_skills:
                return(Content.UIGraphics.Get(0x00000B4000000001));

            case Top100Category.lot_welcome:
                return(Content.UIGraphics.Get(0x00000B4100000001));

            case Top100Category.lot_games:
                return(Content.UIGraphics.Get(0x00000B3A00000001));

            case Top100Category.lot_entertainment:
                return(Content.UIGraphics.Get(0x00000B3900000001));

            case Top100Category.lot_residence:
                return(Content.UIGraphics.Get(0x00000B8400000001));

            case Top100Category.avatar_most_famous:
                return(Content.UIGraphics.Get(0x0000031600000001));

            case Top100Category.avatar_best_karma:
                return(Content.UIGraphics.Get(0x00000ce500000001));

            case Top100Category.avatar_friendliest:
                return(Content.UIGraphics.Get(0x00000ce300000001));

            case Top100Category.avatar_most_infamous:
                return(Content.UIGraphics.Get(0x00000ce400000001));

            case Top100Category.avatar_meanest:
                return(Content.UIGraphics.Get(0x00000ce600000001));

            default:
                return(null);
            }
        }
Exemple #3
0
        public List <Top100Entry> Query(Top100Category category)
        {
            lock (Cache)
            {
                var key   = "top100/" + Context.ShardId + "/" + category.ToString();
                var value = Cache.GetCacheItem(key);

                if (value != null)
                {
                    return((List <Top100Entry>)value.Value);
                }

                using (var db = DAFactory.Get())
                {
                    List <Top100Entry> results = null;

                    if (category.IsLotCategory())
                    {
                        results = db.LotTop100.GetByCategory(Context.ShardId, category.ToLotCategory()).Select(x => new Top100Entry()
                        {
                            Rank = x.rank,
                            //Data service uses lot location as the ID
                            TargetId   = (uint?)x.lot_location,
                            TargetName = x.lot_name
                        }).ToList();
                    }
                    else
                    {
                        //TODO:
                        results = new List <Top100Entry>();
                        for (var i = 0; i < 100; i++)
                        {
                            results.Add(new Top100Entry {
                                Rank = (byte)(i + 1)
                            });
                        }
                    }

                    Cache.Add(key, results, new CacheItemPolicy()
                    {
                        AbsoluteExpiration = DateTime.Now.Add(TimeSpan.FromMinutes(5))
                    });
                    return(results);
                }
            }
        }
Exemple #4
0
        public static bool IsLotCategory(this Top100Category category)
        {
            switch (category)
            {
            case Top100Category.lot_money:
            case Top100Category.lot_offbeat:
            case Top100Category.lot_romance:
            case Top100Category.lot_services:
            case Top100Category.lot_shopping:
            case Top100Category.lot_skills:
            case Top100Category.lot_welcome:
            case Top100Category.lot_games:
            case Top100Category.lot_entertainment:
            case Top100Category.lot_residence:
                return(true);

            default:
                return(false);
            }
        }
Exemple #5
0
        public Top100Domain()
        {
            _Categories = new List <Top100CategoryEntry>();


            var lotCategories = new Top100Category[] { Top100Category.lot_money, Top100Category.lot_offbeat, Top100Category.lot_romance, Top100Category.lot_services, Top100Category.lot_shopping,
                                                       Top100Category.lot_skills, Top100Category.lot_welcome, Top100Category.lot_games, Top100Category.lot_entertainment, Top100Category.lot_residence };
            var lotLabels = new string[] { "Money", "Offbeat", "Romance", "Services", "Shopping", "Skills", "Welcome", "Games", "Entertainment", "Residence" };

            for (var i = 0; i < lotCategories.Length; i++)
            {
                _Categories.Add(new Top100CategoryEntry {
                    Id           = (uint)lotCategories[i],
                    Category     = lotCategories[i],
                    CategoryType = Top100CategoryType.LOT,
                    Name         = lotLabels[i]
                });
            }

            var avatarCategories = new Top100Category[] {
                Top100Category.avatar_most_famous,
                Top100Category.avatar_best_karma,
                Top100Category.avatar_friendliest,
                Top100Category.avatar_most_infamous,
                Top100Category.avatar_meanest
            };
            var avatarLabels = new string[] { "Most Famous", "Best Karma", "Friendliest", "Most Infamous", "Meanest" };

            for (var i = 0; i < avatarCategories.Length; i++)
            {
                _Categories.Add(new Top100CategoryEntry
                {
                    Id           = (uint)avatarCategories[i],
                    Category     = avatarCategories[i],
                    CategoryType = Top100CategoryType.AVATAR,
                    Name         = avatarLabels[i]
                });
            }
        }
Exemple #6
0
        public static LotCategory ToLotCategory(this Top100Category category)
        {
            switch (category)
            {
            case Top100Category.lot_money:
                return(LotCategory.money);

            case Top100Category.lot_offbeat:
                return(LotCategory.offbeat);

            case Top100Category.lot_romance:
                return(LotCategory.romance);

            case Top100Category.lot_services:
                return(LotCategory.services);

            case Top100Category.lot_shopping:
                return(LotCategory.shopping);

            case Top100Category.lot_skills:
                return(LotCategory.skills);

            case Top100Category.lot_welcome:
                return(LotCategory.welcome);

            case Top100Category.lot_games:
                return(LotCategory.games);

            case Top100Category.lot_entertainment:
                return(LotCategory.entertainment);

            case Top100Category.lot_residence:
                return(LotCategory.residence);
            }
            return(LotCategory.none);
        }
Exemple #7
0
 public void Deserialize(IoBuffer input, ISerializationContext context)
 {
     Category = input.GetEnum <Top100Category>();
 }
Exemple #8
0
 public static bool IsAvatarCategory(this Top100Category category)
 {
     return(!category.IsLotCategory());
 }
Exemple #9
0
 public Top100CategoryEntry Get(Top100Category category)
 {
     return(_Categories.FirstOrDefault(x => x.Category == category));
 }
        public void SetCategory(Top100Category category)
        {
            Category = category;

            if (category.IsLotCategory())
            {
                LastLotCategory = category;
            }
            else
            {
                LastAvatarCategory = category;
            }

            View.SelectCategory(category);
            DatabaseService.GetTop100(new GetTop100Request()
            {
                Category = category
            })
            .ContinueWith(x => {
                //Category has been switched
                if (Category != category)
                {
                    return;
                }


                List <Top100ListItem> enriched = null;

                if (category.IsLotCategory())
                {
                    enriched = DataService.EnrichList <Top100ListItem, Top100Entry, Lot>(x.Result.Items, y => y.TargetId, (top100Entry, lot) =>
                    {
                        return(new Top100ListItem()
                        {
                            Top100Entry = top100Entry,
                            Lot = lot
                        });
                    });
                }
                else
                {
                    enriched = DataService.EnrichList <Top100ListItem, Top100Entry, Avatar>(x.Result.Items, z => z.TargetId, (top100Entry, avatar) =>
                    {
                        return(new Top100ListItem()
                        {
                            Top100Entry = top100Entry,
                            Avatar = avatar
                        });
                    });
                }

                //Fill in any gaps
                while (enriched.Count < 100)
                {
                    enriched.Add(new Top100ListItem {
                        Top100Entry = new Top100Entry()
                        {
                            Rank = (byte)(enriched.Count + 1)
                        }
                    });
                }

                enriched = enriched.OrderBy(i => i.Top100Entry.Rank).ToList();
                View.DisplayResults(enriched);
            });
        }