From cab4394752d487fdb9fa5471fe109775f5321831 Mon Sep 17 00:00:00 2001 From: Felix Detig Date: Sat, 12 Feb 2022 14:59:30 +0100 Subject: [PATCH] Refactored TicTacToeBrett.Gewinner --- .../MiniGames/Shared/Models/TicTacToeBrett.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs b/BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs index 006dfe1..fdf616b 100644 --- a/BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs +++ b/BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs @@ -82,14 +82,12 @@ namespace MiniGames.Shared.Models public int Gewinner() { - if (Felder[0, 0] == Felder[0, 1] && Felder[0, 1] == Felder[0, 2] && Felder[0, 0] != LEER) - { - return Felder[0, 0]; - } - - if (Felder[1, 0] == Felder[1, 1] && Felder[1, 1] == Felder[1, 2] && Felder[1, 0] != LEER) + for (int i = 0; i < 3; i++) { - return Felder[1, 0]; + if (Felder[i, 0] == Felder[i, 1] && Felder[i, 1] == Felder[i, 2] && Felder[i, 0] != LEER) + { + return Felder[i, 0]; + } } return LEER;