public void ResolveCombination(PawnColor[] colors) { Result result = new Result(); PawnColor[] secretCopy = new PawnColor[4]; PawnColor[] colorsCopy = new PawnColor[4]; // Init copies for (int i = 0; i < secret.Colors.Length; i++) { secretCopy[i] = secret.Colors[i]; colorsCopy[i] = colors[i]; } // Well placed for (int i = 0; i < colorsCopy.Length; i++) { if (colorsCopy[i] != null && secret.matchAtIndex(i, colorsCopy[i])) { result.WellPlaced++; secretCopy[i] = null; colorsCopy[i] = null; } } // Bad placed for (int i = 0; i < colorsCopy.Length; i++) { for (int j = 0; j < secretCopy.Length; j++) { if (colorsCopy[i] != null && secretCopy[j] != null && secret.matchAtIndex(j, colorsCopy[i])) { result.BadPlaced++; secretCopy[j] = null; colorsCopy[i] = null; } } } guiM.DisplayResult(result); if (result.WellPlaced == 4) { OnWin(); } }