/// <summary> /// ViewScoreBoard function. /// </summary> /// <returns>The string of the scoreboard.</returns> public string ViewScoreBoard() { string scoreboard = string.Empty; int ranking = 1; ScoreboardItemLogic logic = ScoreboardItemLogic.CreateRealLogic(); foreach (scoreboard_items item in logic.GetOrderedScoreboard()) { scoreboard += $"{ranking} {item.sbItem_playerName} {item.sbItem_score} {item.sbItem_time} \n"; ranking++; } return(scoreboard); }
/// <summary> /// GameLogic_GameOver function. /// </summary> /// <param name="sender">sender object.</param> /// <param name="e">GameOverEventArgs event arguments.</param> private void GameLogic_GameOver(object sender, GameOverEventArgs e) { GameOverWindow window = new GameOverWindow(); window.Owner = Application.Current.MainWindow; if (window.ShowDialog() == true) { ScoreboardItemLogic logic = ScoreboardItemLogic.CreateRealLogic(); scoreboard_items newScore = new scoreboard_items(); newScore.sbItem_id = logic.GetAll().Count() + 1; newScore.sbItem_playerName = window.PlayerName.Text; newScore.sbItem_score = e.FinalScore; newScore.sbItem_time = e.FinalTime; try { logic.Insert(newScore); } catch (ArgumentNullException) { } } }