public void AddUserPlayByVerification(UserPlays up) { if (!userPlaysList.Contains(up)) { userPlaysList.Add(up); } }
User() { updated = DateTime.Now; currentPetStatus = new Pet(); tasks = new List <Task> (); games = new List <Game> (); userDoesList = new List <UserDoes> (); cachedUserDoesQueue = new Queue <UserDoes>(); userPlaysList = new List <UserPlays> (); cachedUserPlaysQueue = new Queue <UserPlays> (); // tempUserDoes = new UserDoes (); tempUserPlays = new UserPlays(); }
bool setUserPlaysFromCurrentList() { foreach (UserPlays up in userPlaysList) { if (up.UserId == this.Id && up.GameId == currentGame.Id) { Debug.Log("Existed userPlays: " + up.ToString()); tempUserPlays = up; return(true); } } return(false); }
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) { } }
public void saveScore() { if (tempUserPlays.Record < tempUserPlays.Score) { tempUserPlays.Record = tempUserPlays.Score; } tempUserPlays.Score = currentGame.CurrentScore; UserPlays userPlays = tempUserPlays; // separate in memory. int savedPosition = -1; for (int i = 0; i < userPlaysList.Count; i++) { UserPlays tempUp = userPlaysList[i]; if (userPlays.GameId == tempUp.GameId && userPlays.UserId == tempUp.UserId && userPlays.Score < tempUp.Score) { savedPosition = i; } } if (savedPosition != -1) // replace { Debug.Log("Replacing existed UserPlays"); userPlaysList[savedPosition] = userPlays; } else // add { Debug.Log("Adding UserPlays"); userPlaysList.Add(userPlays); cachedUserPlaysQueue.Enqueue(userPlays); } this.tempUserPlays = new UserPlays(); }