// Add a new trophy. public void AddTrophy(Trophies trophy) { connection.Insert(trophy); }
} // End of roundToCheck public async void AwardChecker() { loadedGamesPlayed = await GamesPlayed(); Console.WriteLine("Games played: " + loadedGamesPlayed); //**** DEBUGGING ********// Console.WriteLine("Trophies Already Earned: "); foreach (Trophies trophy in localTrophyList) { Console.WriteLine(trophy.TrophyPic); } //**** DEBUGGING ********// //******* NOVICE AWARD ***********// var matchNoviceAward = localTrophyList.Where(Trophies => String.Equals(Trophies.TrophyPic, "noviceAward", StringComparison.CurrentCulture)); Console.WriteLine(matchNoviceAward.Any()); if (roundCount == 2 && matchNoviceAward.Any() == false) { Trophies trophy = new Trophies(); trophy.Trophy = "Novice Award"; trophy.TrophyPic = "noviceAward"; newTrophiesList.Add(trophy); newAward = true; }// End of novice award. //******* Bronze 5 AWARD ***********// var matchBronze5Award = localTrophyList.Where(Trophies => String.Equals(Trophies.TrophyPic, "bronze5Award", StringComparison.CurrentCulture)); Console.WriteLine(matchBronze5Award.Any()); if (roundCount >= 5 && matchBronze5Award.Any() == false) { Trophies trophy = new Trophies(); trophy.Trophy = "Bronze 5 Award"; trophy.TrophyPic = "bronze5Award"; newTrophiesList.Add(trophy); newAward = true; }// End of bronze 5 award. //******* Silver 10 AWARD ***********// var matchSilver10Award = localTrophyList.Where(Trophies => String.Equals(Trophies.TrophyPic, "silver10Award", StringComparison.CurrentCulture)); Console.WriteLine(matchSilver10Award.Any()); if (roundCount >= 10 && matchSilver10Award.Any() == false) { Trophies trophy = new Trophies(); trophy.Trophy = "Silver 10 Award"; trophy.TrophyPic = "silver10Award"; newTrophiesList.Add(trophy); newAward = true; }// End of silver 10 award. //******* Gold 25 AWARD ***********// var matchGold25Award = localTrophyList.Where(Trophies => String.Equals(Trophies.TrophyPic, "gold25Award", StringComparison.CurrentCulture)); Console.WriteLine(matchGold25Award.Any()); if (roundCount >= 25 && matchGold25Award.Any() == false) { Trophies trophy = new Trophies(); trophy.Trophy = "Gold 25 Award"; trophy.TrophyPic = "gold25Award"; newTrophiesList.Add(trophy); newAward = true; }// End of gold 25 award. //******* Platinum 50 AWARD ***********// var matchPlatinum50Award = localTrophyList.Where(Trophies => String.Equals(Trophies.TrophyPic, "platinum50Award", StringComparison.CurrentCulture)); Console.WriteLine(matchPlatinum50Award.Any()); if (roundCount >= 50 && matchPlatinum50Award.Any() == false) { Trophies trophy = new Trophies(); trophy.Trophy = "Platinum 50 Award"; trophy.TrophyPic = "platinum50Award"; newTrophiesList.Add(trophy); newAward = true; }// End of platinum 50 award. //******* Hayden's 100 AWARD ***********// var matchHaydens100Award = localTrophyList.Where(Trophies => String.Equals(Trophies.TrophyPic, "haydens100Award", StringComparison.CurrentCulture)); Console.WriteLine(matchHaydens100Award.Any()); if (roundCount >= 100 && matchHaydens100Award.Any() == false) { Trophies trophy = new Trophies(); trophy.Trophy = "Hayden's 100 Award"; trophy.TrophyPic = "haydens100Award"; newTrophiesList.Add(trophy); newAward = true; }// End of Hayden's 100 award. //******* Multi AWARD ***********// var matchMultiAward = localTrophyList.Where(Trophies => String.Equals(Trophies.TrophyPic, "multiAward", StringComparison.CurrentCulture)); Console.WriteLine(matchMultiAward.Any()); if (playerMode == "multi" && matchMultiAward.Any() == false) { Trophies trophy = new Trophies(); trophy.Trophy = "Multiplayer Award"; trophy.TrophyPic = "multiAward"; newTrophiesList.Add(trophy); newAward = true; }// End of multi award. //******* Multi 20 AWARD ***********// var matchMulti20Award = localTrophyList.Where(Trophies => String.Equals(Trophies.TrophyPic, "multi20Award", StringComparison.CurrentCulture)); Console.WriteLine(matchMulti20Award.Any()); if (playerMode == "multi" && roundCount >= 20 && matchMulti20Award.Any() == false) { Trophies trophy = new Trophies(); trophy.Trophy = "Multiplayer 20 Award"; trophy.TrophyPic = "multi20Award"; newTrophiesList.Add(trophy); newAward = true; }// End of multi award. //******* Played 20 AWARD ***********// var matchPlayed20Award = localTrophyList.Where(Trophies => String.Equals(Trophies.TrophyPic, "played20Award", StringComparison.CurrentCulture)); Console.WriteLine(matchPlayed20Award.Any()); if (loadedGamesPlayed == 20 && matchPlayed20Award.Any() == false) { Trophies trophy = new Trophies(); trophy.Trophy = "Played 20 Games Award"; trophy.TrophyPic = "played20Award"; newTrophiesList.Add(trophy); newAward = true; }// End of played 20 award. //******* Played 50 AWARD ***********// var matchPlayed50Award = localTrophyList.Where(Trophies => String.Equals(Trophies.TrophyPic, "played50Award", StringComparison.CurrentCulture)); Console.WriteLine(matchPlayed50Award.Any()); if (loadedGamesPlayed == 50 && matchPlayed50Award.Any() == false) { Trophies trophy = new Trophies(); trophy.Trophy = "Played 50 Games Award"; trophy.TrophyPic = "played50Award"; newTrophiesList.Add(trophy); newAward = true; }// End of played 50 award. //******* Played 100 AWARD ***********// var matchPlayed100Award = localTrophyList.Where(Trophies => String.Equals(Trophies.TrophyPic, "played100Award", StringComparison.CurrentCulture)); Console.WriteLine(matchPlayed100Award.Any()); if (loadedGamesPlayed == 100 && matchPlayed100Award.Any() == false) { Trophies trophy = new Trophies(); trophy.Trophy = "Played 100 Games Award"; trophy.TrophyPic = "played100Award"; newTrophiesList.Add(trophy); newAward = true; }// End of played 100 award. //******* Pro Hard 20 AWARD ***********// var matchProHard20Award = localTrophyList.Where(Trophies => String.Equals(Trophies.TrophyPic, "proHard20Award", StringComparison.CurrentCulture)); Console.WriteLine(matchProHard20Award.Any()); if (roundCount >= 20 && difFlag == "hard" && matchProHard20Award.Any() == false) { Trophies trophy = new Trophies(); trophy.Trophy = "Pro on Hard 20 Award"; trophy.TrophyPic = "proHard20Award"; newTrophiesList.Add(trophy); newAward = true; }// End of pro on hard 20 award. //******* Goldfish AWARD ***********// var matchGoldfishAward = localTrophyList.Where(Trophies => String.Equals(Trophies.TrophyPic, "goldfishAward", StringComparison.CurrentCulture)); Console.WriteLine(matchGoldfishAward.Any()); if (roundCount == 1 && matchGoldfishAward.Any() == false) { Trophies trophy = new Trophies(); trophy.Trophy = "Goldfish Award"; trophy.TrophyPic = "goldfishAward"; newTrophiesList.Add(trophy); newAward = true; }// End of goldfish award. //**** DEBUGGING ********// Console.WriteLine("Trophies Earned During This Game: "); foreach (Trophies trophy in newTrophiesList) { Console.WriteLine(trophy.TrophyPic); } //**** DEBUGGING ********// if (newAward == true) { awardStack.IsVisible = true; if (newTrophiesList.Count > 1) { newAwardLabel.Text = "You earned new awards!"; } int rowAmount = newTrophiesList.Count; int counter = 0; for (int rowIndex = 0; rowIndex < rowAmount; rowIndex++) // Adds all the Rows { for (int columnIndex = 0; columnIndex < 1; columnIndex++) // Adds all the columns { if (counter == newTrophiesList.Count) // Amount of trophies to display { break; } var trophyStack = new StackLayout { }; var imageTrophy = new Image { HeightRequest = 100, HorizontalOptions = LayoutOptions.Center }; var trophyLabel = new Label { FontAttributes = FontAttributes.Bold, FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), HorizontalOptions = LayoutOptions.Center }; trophyStack.Children.Add(imageTrophy); trophyStack.Children.Add(trophyLabel); //iOS stuff if (Device.RuntimePlatform == Device.iOS) { imageTrophy.Source = newTrophiesList[counter].TrophyPic;//sets the images to go into the grid } //Android stuff if (Device.RuntimePlatform == Device.Android) { imageTrophy.Source = newTrophiesList[counter].TrophyPic;//sets the images to go into the grid } trophyLabel.Text = newTrophiesList[counter].Trophy; awardsGridLayout.Children.Add(trophyStack, columnIndex, rowIndex); counter++; } // End of for column } // End of for row } // End of if newAward == true } // End of award checker.