private void CheckCountOfStones(int totalCountOfStones, int currentCountOfStonesInFirstHeap, int currentCountOfStonesInSecondHeap, int currentCountOfStonesInThirdHeap) { if (currentCountOfStonesInFirstHeap + currentCountOfStonesInSecondHeap + currentCountOfStonesInThirdHeap == totalCountOfStones) { if (isCreated == false) { GameTimer.Stop(); this.Hide(); WinnerForm winnerForm = new WinnerForm(form, minutes, seconds, form); winnerForm.ShowDialog(); this.Close(); isCreated = true; } } if (currentCountOfStonesInFirstHeap + currentCountOfStonesInSecondHeap + currentCountOfStonesInThirdHeap > totalCountOfStones) { if (isCreated == false) { GameTimer.Stop(); this.Hide(); LoserForm loseForm = new LoserForm(form, minutes, seconds, form); loseForm.ShowDialog(); this.Close(); isCreated = true; } } }
private void CheckCountOfStones(int currentCountOfStones, int totalCountOfStones) { if (currentCountOfStones == totalCountOfStones) { GameTimer.Stop(); this.Hide(); WinnerForm winnerForm = new WinnerForm(form, minutes, seconds, form); winnerForm.ShowDialog(); this.Close(); } if (currentCountOfStones > totalCountOfStones) { GameTimer.Stop(); this.Hide(); LoserForm loseForm = new LoserForm(form, minutes, seconds, form); loseForm.ShowDialog(); this.Close(); } }
private void TurnTimer_Tick(object sender, EventArgs e) { if (MyTurn == false) { TurnTimer.Stop(); Cursor = Cursors.Default; Random random = new Random(); int choise = random.Next(1, 2); if (choise == 1) { currentCountOfStones = currentCountOfStones * Times; labelCurrentCountOfStones.Text = currentCountOfStones.ToString(); } else { currentCountOfStones += Plus; labelCurrentCountOfStones.Text = currentCountOfStones.ToString(); } if (currentCountOfStones == totalCountOfStones) { GameTimer.Stop(); this.Hide(); LoserForm loseForm = new LoserForm(form, minutes, seconds, form); loseForm.ShowDialog(); this.Close(); } if (currentCountOfStones > totalCountOfStones) { GameTimer.Stop(); this.Hide(); WinnerForm winnerForm = new WinnerForm(form, minutes, seconds, form); winnerForm.ShowDialog(); this.Close(); } labelWhosTurn.Text = "ВАШ ХОД"; labelWhosTurn.ForeColor = Color.LimeGreen; MyTurn = true; } }
private void TurnTimer_Tick(object sender, EventArgs e) { Cursor = Cursors.Default; TurnTimer.Stop(); if (MyTurn == false) { Cursor = Cursors.Default; Random random = new Random(); int choise = random.Next(1, 4); int choiseOfHeap = random.Next(1, 3); if (choise == 1) { if (choiseOfHeap == 1) { currentCountOfStonesInFirstHeap += Plus; labelCurrentCountOfStonesInFirstHeap.Text = currentCountOfStonesInFirstHeap.ToString(); } else if (choiseOfHeap == 2) { currentCountOfStonesInSecondHeap += Plus; labelCurrentCountOfStonesInSecondHeap.Text = currentCountOfStonesInSecondHeap.ToString(); } else if (choiseOfHeap == 3) { currentCountOfStonesInThirdHeap += Plus; labelCurrentCountOfStonesInThirdHeap.Text = currentCountOfStonesInThirdHeap.ToString(); } } else if (choise == 2) { if (choiseOfHeap == 1) { currentCountOfStonesInFirstHeap = Times * currentCountOfStonesInFirstHeap; labelCurrentCountOfStonesInFirstHeap.Text = currentCountOfStonesInFirstHeap.ToString(); } else if (choiseOfHeap == 2) { currentCountOfStonesInSecondHeap = Times * currentCountOfStonesInSecondHeap; labelCurrentCountOfStonesInSecondHeap.Text = currentCountOfStonesInSecondHeap.ToString(); } else if (choiseOfHeap == 3) { currentCountOfStonesInThirdHeap = Times * currentCountOfStonesInThirdHeap; labelCurrentCountOfStonesInThirdHeap.Text = currentCountOfStonesInThirdHeap.ToString(); } } else if (choise == 3) { if (choiseOfHeap == 1) { if (currentCountOfStonesInFirstHeap - Minus > 2) { currentCountOfStonesInFirstHeap = currentCountOfStonesInFirstHeap - Minus; labelCurrentCountOfStonesInFirstHeap.Text = currentCountOfStonesInFirstHeap.ToString(); } else { choise = random.Next(1, 3); ChoiseOfHeapD(choise, choiseOfHeap, ref currentCountOfStonesInFirstHeap, ref currentCountOfStonesInSecondHeap); } } else if (choiseOfHeap == 2) { if (currentCountOfStonesInSecondHeap - Minus > 2) { currentCountOfStonesInSecondHeap = currentCountOfStonesInSecondHeap - Minus; labelCurrentCountOfStonesInSecondHeap.Text = currentCountOfStonesInSecondHeap.ToString(); } else { choise = random.Next(1, 3); ChoiseOfHeapD(choise, choiseOfHeap, ref currentCountOfStonesInFirstHeap, ref currentCountOfStonesInSecondHeap); } } else if (choiseOfHeap == 3) { if (currentCountOfStonesInThirdHeap - Minus > 2) { currentCountOfStonesInThirdHeap = currentCountOfStonesInThirdHeap - Minus; labelCurrentCountOfStonesInThirdHeap.Text = currentCountOfStonesInThirdHeap.ToString(); } else { choise = random.Next(1, 3); ChoiseOfHeapD(choise, choiseOfHeap, ref currentCountOfStonesInFirstHeap, ref currentCountOfStonesInSecondHeap); } } } else if (choise == 4) { if (choiseOfHeap == 1) { if (currentCountOfStonesInFirstHeap / Divide > 2) { currentCountOfStonesInFirstHeap = currentCountOfStonesInFirstHeap / Divide; labelCurrentCountOfStonesInFirstHeap.Text = currentCountOfStonesInFirstHeap.ToString(); } else { choise = random.Next(1, 3); ChoiseOfHeapM(choise, choiseOfHeap, ref currentCountOfStonesInFirstHeap, ref currentCountOfStonesInSecondHeap); } } else if (choiseOfHeap == 2) { if (currentCountOfStonesInSecondHeap / Divide > 2) { currentCountOfStonesInSecondHeap = currentCountOfStonesInSecondHeap / Divide; labelCurrentCountOfStonesInSecondHeap.Text = currentCountOfStonesInSecondHeap.ToString(); } else { choise = random.Next(1, 3); ChoiseOfHeapM(choise, choiseOfHeap, ref currentCountOfStonesInFirstHeap, ref currentCountOfStonesInSecondHeap); } } else if (choiseOfHeap == 3) { if (currentCountOfStonesInThirdHeap / Divide > 2) { currentCountOfStonesInThirdHeap = currentCountOfStonesInThirdHeap / Divide; labelCurrentCountOfStonesInThirdHeap.Text = currentCountOfStonesInThirdHeap.ToString(); } else { choise = random.Next(1, 3); ChoiseOfHeapM(choise, choiseOfHeap, ref currentCountOfStonesInFirstHeap, ref currentCountOfStonesInSecondHeap); } } } } if (currentCountOfStonesInFirstHeap + currentCountOfStonesInSecondHeap + currentCountOfStonesInThirdHeap == totalCountOfStones) { if (isCreated == false) { GameTimer.Stop(); this.Hide(); LoserForm loseForm = new LoserForm(form, minutes, seconds, form); loseForm.ShowDialog(); this.Close(); isCreated = true; } } if (currentCountOfStonesInFirstHeap + currentCountOfStonesInSecondHeap + currentCountOfStonesInThirdHeap > totalCountOfStones) { if (isCreated == false) { GameTimer.Stop(); this.Hide(); WinnerForm winnerForm = new WinnerForm(form, minutes, seconds, form); winnerForm.ShowDialog(); this.Close(); isCreated = true; } } labelWhosTurn.Text = "ВАШ ХОД"; labelWhosTurn.ForeColor = Color.LimeGreen; MyTurn = true; }