/// <summary> /// Game draw method /// </summary> /// <param name="result">Result of game</param> private void Game_Draw(string result) { Enabled = true; profile.Draw(game.Difficult.ToString()); GameDataBus.SaveGameResultInScore(profile, locale); DeleteSubscribes(); GameDataBus.ShowResult(result, locale); GamePanel.Visible = false; }
/// <summary> /// Set russian language /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void RussianItem_Click(object sender, EventArgs e) { locale = CreateLocale(InterfaceLanguage.ru); SetLocale(locale); GameDataBus.SaveGameResultInScore(profile, locale); SetLanguageFlags(locale.Localization); if (game != null) { ((SinglePlayer)game).ChangeBotNameWithLocale(locale); } ShowParameters(); }
/// <summary> /// Click on game field buttons method /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Event</param> private void GameFieldButton_Click(object sender, EventArgs e) { var button = (Button)sender; int i = int.Parse(button.Tag.ToString()); game.PlayerStep(i, out bool isPossible); if (!isPossible) { GameDataBus.ShowImpossibleStepMessage(locale); } UpdateButtons(); game.CheckGameStatus(); if (game.GameInProgress && isPossible) { game.ChangeCurrentPlayer(); } }
/// <summary> /// Game win method /// </summary> /// <param name="result">Result of game</param> private void Game_Win(string result) { Enabled = true; if (game.Winner == game.Player1) { profile.Win(game.Difficult.ToString()); GameDataBus.SaveGameResultInScore(profile, locale); ChangeButtonColor(Color.Green); } else { profile.Lose(game.Difficult.ToString()); GameDataBus.SaveGameResultInScore(profile, locale); ChangeButtonColor(Color.Red); } GameDataBus.ShowResult(result, locale); DeleteSubscribes(); GamePanel.Visible = false; }
/// <summary> /// Main form load event method /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Event</param> private void MainForm_Load(object sender, EventArgs e) { if (!SaveLoadProfile.CheckExistFileSave()) { #pragma warning disable IDE0067 // Dispose objects before losing scope NewProfile addUserForm = new NewProfile(profile, locale); #pragma warning restore IDE0067 // Dispose objects before losing scope addUserForm.ShowDialog(); if (!GameDataBus.ProfileIsCreated) { Close(); return; } profile = GameDataBus.TempProfile; } else { profile = GameDataBus.LoadGameResultInScore(locale); } locale = CreateLocale(profile.PlayerLocale); SetLocale(locale); SetLanguageFlags(locale.Localization); }
/// <summary> /// Show game score method /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Param</param> private void ScoreMenu_Click(object sender, EventArgs e) { GameDataBus.ShowScore(profile, locale); }
/// <summary> /// Main form exit event method /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Event</param> private void ExitMenu_Click(object sender, EventArgs e) { GameDataBus.SaveGameResultInScore(profile, locale); Application.Exit(); }