Example #1
0
        public async Task LoadAllComments(BoardGameDataItem item)
        {
            IEnumerable <Comment> comments = await Client.LoadAllComments(item.GameId, item.TotalComments);

            item.Comments.Clear();
            foreach (Comment comment in comments.OrderByDescending(x => x.Text.Length).Take(500))
            {
                item.Comments.Add(new CommentDataItem()
                {
                    Rating   = comment.Rating,
                    Text     = comment.Text,
                    Username = comment.Username
                });
            }
        }
Example #2
0
        private async void LoadPlays()
        {
            UserPlaysHub.Clear();
            UserPlays.Clear();
            if (string.IsNullOrEmpty(_Username))
            {
                return;
            }

            int MaxPlaysHub = 10;
            IEnumerable <PlayItem> items = await Client.LoadLastPlays(_Username);

            //int ItemsToGet = Math.Min(items.Count(), 50);
            int ItemsToGet = items.Count();

            for (int i = 0; i < ItemsToGet; i++)
            {
                PlayItemDataItem play = new PlayItemDataItem()
                {
                    Name     = items.ElementAt(i).Name,
                    NumPlays = items.ElementAt(i).NumPlays,
                    GameId   = items.ElementAt(i).GameId,
                    PlayDate = items.ElementAt(i).PlayDate,
                };
                UserPlays.Add(play);
                if (i < MaxPlaysHub)
                {
                    UserPlaysHub.Add(play);
                }
            }

            try
            {
                // Separately load games through cache
                foreach (PlayItemDataItem pi in UserPlays)
                {
                    BoardGameDataItem game = await LoadGame(pi.GameId);

                    pi.Thumbnail = game.Thumbnail;
                }
            }
            catch (Exception) { }
        }
Example #3
0
        private void UpdateCollectionForHub()
        {
            UserCollectionHub.Clear();

            List <BoardGameDataItem> OwnedItems = UserCollection.Distinct().Where(x => x.Owned).ToList();
            int amountToTake = Math.Min(HUB_PREVIEW, OwnedItems.Count());

            Random rnd = new Random();

            if (OwnedItems.Count != 0)
            {
                for (int i = 0; i < amountToTake; i++)
                {
                    BoardGameDataItem item = OwnedItems[rnd.Next(0, OwnedItems.Count)];
                    while (UserCollectionHub.Any(x => x.GameId == item.GameId))
                    {
                        item = OwnedItems[rnd.Next(0, OwnedItems.Count)];
                    }

                    UserCollectionHub.Add(item);
                }
            }
        }
Example #4
0
        private async void DoSearch(string query)
        {
            _searchUpdateIsRunning = true;
            cts = new CancellationTokenSource();

            FoundResults.Clear();

            IEnumerable <SearchResult> items = await Client.Search(query);

            foreach (SearchResult sr in items)
            {
                FoundResults.Add(new SearchResultDataItem()
                {
                    Name   = sr.Name,
                    GameId = sr.GameId
                });
            }

            // Separately load games through cache
            foreach (SearchResultDataItem srdi in FoundResults)
            {
                if (cts != null && cts.IsCancellationRequested)
                {
                    break;
                }

                BoardGameDataItem game = await LoadGame(srdi.GameId);

                if (game != null)
                {
                    srdi.Thumbnail = game.Thumbnail;
                }
            }

            cts = null;
            _searchUpdateIsRunning = false;
        }
 public static void RemoveGame(BoardGameDataItem Game)
 {
     StorageManager.Games.Remove(Game);
 }
 public static void AddGame(BoardGameDataItem Game)
 {
     StorageManager.AddGame(Game);
     // await StorageManager.Save<BoardGameDataItem>();
 }
Example #7
0
        public static BoardGameDataItem GetGame()
        {
            BoardGameDataItem demodata = new BoardGameDataItem()
            {
                Description   = @"Werewolves of Miller's Hollow is a game that takes place in a small village which is haunted by werewolves. Each player is secretly assigned a role - Werewolf, Ordinary Townsfolk, or special character such as The Sheriff, The Hunter, the Witch, the Little Girl, The Fortune Teller and so on... There is also a Moderator player who controls the flow of the game. The game alternates between night and day phases. At night, the Werewolves secretly choose a Villager to kill. During the day, the Villager who was killed is revealed and is out of the game. The remaining Villagers (normal and special villagers alike) then deliberate and vote on a player they suspect is a Werewolf, helped (or hindered) by the clues the special characters add to the general deliberation. The chosen player is &quot;lynched&quot;, reveals his/her role and is out of the game. Werewolf is a social game that requires no equipment to play, and can accommodate almost any large group of players.&#10;&#10;The Werewolves of Miller's Hollow/les Loups-Garous de Thiercelieux/Die Werw&ouml;lfe von D&uuml;sterwald is a published version arranged by Herv&#195;&#169; Marly and Philippe des Palli&#195;&#168;res and published by Lui-m&#195;&#170;me, 2001 for 8-23 players. This has been nominated for the 2003 Spiel des Jahres award.&#10;&#10;Werewolves of Miller's Hollow is a separate game from Werewolf, and was split from that entry at the request of Asmodee.&#10;&#10;Expanded by:&#10;&#10; New Moon: The Werewolves of Miller's Hollow&#10;&#10;&#10;&#10;&#10;Re-Implemented by:&#10;&#10; Werewolves of Miller's Hollow: The Village&#10;&#10;&#10;&#10;&#10;Home Page: http://lesloupsgarous.free.fr/&#10;&#10;",
                GameId        = 25821,
                YearPublished = 2012,
                Thumbnail     = @"http://cf.geekdo-images.com/images/pic510856_t.jpg",
                Name          = "The Werewolves of Miller's Hollow",
                MinPlayers    = 8,
                MaxPlayers    = 18,
                Image         = @"http://cf.geekdo-images.com/images/pic510856.jpg"
            };

            demodata.Comments.Add(new CommentDataItem()
            {
                Rating   = 0,
                Username = "******",
                Text     = "I expected so much and instead we got an average LCG. Simple for newcomers but if you own AGoT LCG don't even bother with this one. I give this a 4 as they could have done so much more both mechanically and it is Star Wars! An average card game I just don't want to play (some neat art though)."
            });
            demodata.Comments.Add(new CommentDataItem()
            {
                Rating   = 8,
                Username = "******",
                Text     = "eh.."
            });

            demodata.PlayerPollResults.Add(new PlayerPollResultDataItem()
            {
                NumPlayers            = 1,
                Best                  = 10,
                Recommended           = 20,
                NotRecommended        = 5,
                NumPlayersIsAndHigher = false
            });
            demodata.PlayerPollResults.Add(new PlayerPollResultDataItem()
            {
                NumPlayers            = 2,
                Best                  = 10,
                Recommended           = 20,
                NotRecommended        = 5,
                NumPlayersIsAndHigher = false
            });
            demodata.PlayerPollResults.Add(new PlayerPollResultDataItem()
            {
                NumPlayers            = 3,
                Best                  = 15,
                Recommended           = 28,
                NotRecommended        = 5,
                NumPlayersIsAndHigher = false
            });
            demodata.PlayerPollResults.Add(new PlayerPollResultDataItem()
            {
                NumPlayers            = 4,
                Best                  = 10,
                Recommended           = 120,
                NotRecommended        = 5,
                NumPlayersIsAndHigher = false
            });
            demodata.PlayerPollResults.Add(new PlayerPollResultDataItem()
            {
                NumPlayers            = 4,
                Best                  = 0,
                Recommended           = 0,
                NotRecommended        = 132,
                NumPlayersIsAndHigher = true
            });

            return(demodata);
        }
Example #8
0
        public async void LoadCollection()
        {
            UserCollection.Clear();


            if (string.IsNullOrEmpty(_Username))
            {
                return;
            }

            LoadCollectionFromCache();

            Messenger.Default.Send <CollectionLoadingMessage>(new CollectionLoadingMessage()
            {
                isQuick = true
            });

            IEnumerable <Boardgame> items = await Client.LoadCollection(_Username);

            foreach (Boardgame item in items)
            {
                BoardGameDataItem cdi = BoardGameStorage.LoadGame(item.GameId);
                if (cdi == null)// Add to main store
                {
                    cdi = new BoardGameDataItem();
                    cdi.IsFullyLoaded = false; // Indicate Loadgame should get individual results from API
                    BoardGameStorage.AddGame(cdi);
                }

                cdi.Name            = item.Name;
                cdi.NumPlays        = item.NumPlays;
                cdi.Thumbnail       = item.Thumbnail;
                cdi.YearPublished   = item.YearPublished;
                cdi.GameId          = item.GameId;
                cdi.ForTrade        = item.ForTrade;
                cdi.Owned           = item.Owned;
                cdi.PreOrdered      = item.PreOrdered;
                cdi.Want            = item.Want;
                cdi.PreviouslyOwned = item.PreviousOwned;
                cdi.WantToBuy       = item.WantToBuy;
                cdi.WantToPlay      = item.WantToPlay;
                cdi.Wishlist        = item.WishList;
                cdi.Rating          = item.Rating;
                cdi.AverageRating   = item.AverageRating;
                cdi.BGGRating       = item.BGGRating;
                cdi.Image           = item.Image;
                cdi.MaxPlayers      = item.MaxPlayers;
                cdi.MinPlayers      = item.MinPlayers;
                cdi.PlayingTime     = item.PlayingTime;
                cdi.IsExpansion     = item.IsExpansion;
                cdi.Rank            = item.Rank;
                cdi.UserComment     = item.UserComment;

                if (cdi.IsValidCollectionMember)
                {
                    cdi.IsCollectionItem = true;
                    if (UserCollection.Contains(cdi))
                    {
                        UserCollection.Remove(cdi);
                    }

                    UserCollection.Add(cdi);
                }
            }

            UpdateCollectionForHub();

            Messenger.Default.Send <CollectionLoadedMessage>(new CollectionLoadedMessage()
            {
                isQuick = true
            });

            LoadCollectionFully();
        }
Example #9
0
        /// <summary>
        /// Loads a game, first from cache, if not found from the BGG Service
        /// </summary>
        /// <param name="GameId"></param>
        /// <param name="ForceReload"></param>
        /// <returns></returns>
        public async Task <BoardGameDataItem> LoadGame(int GameId, bool ForceReload = false)
        {
            BoardGameDataItem bgdi = BoardGameStorage.LoadGame(GameId);

            // If Force reload, the item should be removed from the storage and fetched anew.
            if (bgdi != null)
            {
                if (ForceReload)
                {
                    BoardGameStorage.RemoveGame(bgdi);
                    bgdi = null;
                }
                else if (bgdi.DataVersion < BoardGameDataItem.CurrentDataVersion)
                {
                    BoardGameStorage.RemoveGame(bgdi);
                    bgdi = null;
                }
            }

            if (bgdi == null || !bgdi.IsFullyLoaded)
            {
                Boardgame game = await Client.LoadGame(GameId);

                if (game != null)
                {
                    #region Filling values
                    if (bgdi == null)
                    {
                        bgdi = new BoardGameDataItem();
                        BoardGameStorage.AddGame(bgdi);
                    }
                    else
                    {
                        bgdi.DisableUpdate = true;
                    }

                    bgdi.Description   = WebUtility.HtmlDecode(game.Description);
                    bgdi.GameId        = game.GameId;
                    bgdi.Image         = game.Image;
                    bgdi.MaxPlayers    = game.MaxPlayers;
                    bgdi.MinPlayers    = game.MinPlayers;
                    bgdi.Name          = game.Name;
                    bgdi.Thumbnail     = game.Thumbnail;
                    bgdi.YearPublished = game.YearPublished;
                    bgdi.PlayingTime   = game.PlayingTime;
                    bgdi.AverageRating = game.AverageRating;
                    bgdi.Rank          = game.Rank;
                    bgdi.BGGRating     = game.BGGRating;
                    bgdi.FetchDate     = DateTime.Now;
                    bgdi.IsExpansion   = game.IsExpansion;
                    bgdi.TotalComments = game.TotalComments;
                    bgdi.IsFullyLoaded = true;

                    foreach (string publisher in game.Publishers)
                    {
                        bgdi.Publishers.Add(publisher);
                    }
                    foreach (string designer in game.Designers)
                    {
                        bgdi.Designers.Add(designer);
                    }
                    foreach (string artist in game.Artists)
                    {
                        bgdi.Artists.Add(artist);
                    }

                    foreach (Comment comment in game.Comments.OrderByDescending(x => x.Text.Length))
                    {
                        bgdi.Comments.Add(new CommentDataItem()
                        {
                            Rating   = comment.Rating,
                            Text     = comment.Text,
                            Username = comment.Username
                        });
                    }

                    foreach (PlayerPollResult result in game.PlayerPollResults.OrderBy(x => x.NumPlayers + (x.NumPlayersIsAndHigher ? 1 : 0))) // add one to 4+ , making it 5 and the highest
                    {
                        bgdi.PlayerPollResults.Add(new PlayerPollResultDataItem()
                        {
                            Best                  = result.Best,
                            NumPlayers            = result.NumPlayers,
                            NumPlayersIsAndHigher = result.NumPlayersIsAndHigher,
                            NotRecommended        = result.NotRecommended,
                            Recommended           = result.Recommended
                        });
                    }

                    //if (BoardGameStorage.LoadGame(GameId) == null) // a different thread could have inserted the game by now!


                    bgdi.DisableUpdate = false;
                    #endregion
                }
                else
                {
                    return(null);
                }
            }
            return(bgdi);
        }