Browse Source

Refactored TicTacToeBrett.Gewinner

feature/tictactoe
Felix Detig 3 years ago
parent
commit
8e15fb5e7b
  1. 20
      BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs

20
BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs

@ -80,24 +80,24 @@ namespace MiniGames.Shared.Models
return true;
}
protected bool dreiGleichGefuellt(int a, int b, int c)
{
return a != LEER && a == b && b == c;
}
public int Gewinner()
{
for (int i = 0; i < 3; i++)
{
if (Felder[i, 0] == Felder[i, 1] && Felder[i, 1] == Felder[i, 2] && Felder[i, 0] != LEER)
if (dreiGleichGefuellt(Felder[i, 0], Felder[i, 1], Felder[i, 2]))
{
return Felder[i, 0];
}
}
if (Felder[0, 0] == Felder[1, 0] && Felder[1, 0] == Felder[2, 0] && Felder[0, 0] != LEER)
{
return Felder[0, 0];
}
if (Felder[0, 1] == Felder[1, 1] && Felder[1, 1] == Felder[2, 1] && Felder[0, 1] != LEER)
{
return Felder[0, 1];
if (dreiGleichGefuellt(Felder[0, i], Felder[1, i], Felder[2, i]))
{
return Felder[0, i];
}
}
return LEER;

Loading…
Cancel
Save