diff --git a/BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs b/BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs index 646f1a4..59468c8 100644 --- a/BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs +++ b/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;