Skip to content

Commit

Permalink
Merge pull request #63 from CodebreakerApp/62-breaking-change-analyze…
Browse files Browse the repository at this point in the history
…rs-change-old-algorithm-namespace

62 breaking change analyzers change old algorithm namespace
  • Loading branch information
christiannagel authored Aug 19, 2023
2 parents a5647a4 + ee07526 commit d01ae62
Show file tree
Hide file tree
Showing 16 changed files with 25 additions and 47 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using System.Collections;

using Codebreaker.GameAPIs.Algorithms.Fields;
using Codebreaker.GameAPIs.Analyzers;
using Codebreaker.GameAPIs.Algorithms.Extensions;
using Codebreaker.GameAPIs.Models;

using static Codebreaker.GameAPIs.Models.Colors;

namespace Codebreaker.GameAPIs.Algorithms.Tests;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System.Collections;

using Codebreaker.GameAPIs.Algorithms.Extensions;
using Codebreaker.GameAPIs.Algorithms.Fields;
using Codebreaker.GameAPIs.Analyzers;
using Codebreaker.GameAPIs.Models;

using static Codebreaker.GameAPIs.Models.Colors;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System.Collections;

using Codebreaker.GameAPIs.Algorithms.Extensions;
using Codebreaker.GameAPIs.Algorithms.Fields;
using Codebreaker.GameAPIs.Analyzers;
using Codebreaker.GameAPIs.Models;

using static Codebreaker.GameAPIs.Models.Colors;
using static Codebreaker.GameAPIs.Models.Shapes;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Codebreaker.GameAPIs.Contracts;

namespace Codebreaker.GameAPIs.Algorithms.Tests;
namespace Codebreaker.GameAPIs.Algorithms.Tests;

public class MockColorGame : IGame
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Codebreaker.GameAPIs.Contracts;

namespace Codebreaker.GameAPIs.Algorithms.Tests;
namespace Codebreaker.GameAPIs.Algorithms.Tests;

public class MockShapeGame : IGame
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
global using Xunit;
global using Codebreaker.GameAPIs.Analyzers;
global using Codebreaker.GameAPIs.Contracts;
global using Codebreaker.GameAPIs.Extensions;
global using Codebreaker.GameAPIs.Models;

global using Xunit;
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using Codebreaker.GameAPIs.Algorithms.Fields;
using Codebreaker.GameAPIs.Contracts;
using Codebreaker.GameAPIs.Models;
using Codebreaker.GameAPIs.Algorithms.Extensions;

namespace Codebreaker.GameAPIs.Analyzers;
namespace Codebreaker.GameAPIs.Analyzers;

public class ColorGameGuessAnalyzer : GameGuessAnalyzer<ColorField, ColorResult>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Codebreaker.GameAPIs.Contracts;

namespace Codebreaker.GameAPIs.Analyzers;
namespace Codebreaker.GameAPIs.Analyzers;

/// <summary>
/// Abstract base class for game guess analyzers.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using Codebreaker.GameAPIs.Algorithms.Extensions;
using Codebreaker.GameAPIs.Algorithms.Fields;
using Codebreaker.GameAPIs.Contracts;
using Codebreaker.GameAPIs.Models;

namespace Codebreaker.GameAPIs.Analyzers;
namespace Codebreaker.GameAPIs.Analyzers;

public class ShapeGameGuessAnalyzer : GameGuessAnalyzer<ShapeAndColorField, ShapeAndColorResult>
{
Expand Down Expand Up @@ -79,8 +74,8 @@ protected override ShapeAndColorResult GetCoreResult()
// check white (either the shape or the color is correct on a wrong position)
for (int i = 0; i < guessPegsToCheck.Count; i++)
{
var colorCodes = codesToCheck.Select(c => c.Color).ToArray();
var shapeCodes = codesToCheck.Select(c => c.Shape).ToArray();
string[] colorCodes = codesToCheck.Select(c => c.Color).ToArray();
string[] shapeCodes = codesToCheck.Select(c => c.Shape).ToArray();

if (colorCodes.Contains(guessPegsToCheck[i].Color) || shapeCodes.Contains(guessPegsToCheck[i].Shape))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using Codebreaker.GameAPIs.Algorithms.Extensions;
using Codebreaker.GameAPIs.Algorithms.Fields;
using Codebreaker.GameAPIs.Contracts;
using Codebreaker.GameAPIs.Models;

namespace Codebreaker.GameAPIs.Analyzers;
namespace Codebreaker.GameAPIs.Analyzers;

public class SimpleGameGuessAnalyzer : GameGuessAnalyzer<ColorField, SimpleColorResult>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
namespace Codebreaker.GameAPIs.Extensions;

public static class FieldExtensions
{
public static IEnumerable<T> ToFields<T>(this string[] fieldStrings)
where T : IParsable<T>
{
foreach (var fieldString in fieldStrings)
foreach (string fieldString in fieldStrings)
{
yield return T.Parse(fieldString, default);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using Codebreaker.GameAPIs.Extensions;
using Codebreaker.GameAPIs.Models;
namespace Codebreaker.GameAPIs.Extensions;

namespace Codebreaker.GameAPIs.Algorithms.Extensions;
public static class PegExtensions
{
public static IEnumerable<T> ToPegs<T>(this string[] pegStrings)
where T : IParsable<T>
{
foreach (var pegString in pegStrings)
foreach (string pegString in pegStrings)
{
yield return T.Parse(pegString, default);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace Codebreaker.GameAPIs.Algorithms.Fields;
namespace Codebreaker.GameAPIs.Models;

public class FieldCategories
{
public const string Colors = "colors";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace Codebreaker.GameAPIs.Models;

public readonly partial record struct ColorResult : ISpanFormattable
{
public override string ToString() => ToString(default, default);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace Codebreaker.GameAPIs.Models;

public readonly partial struct SimpleColorResult : IEquatable<SimpleColorResult>
{
public override bool Equals(object? obj)
Expand Down
3 changes: 3 additions & 0 deletions src/services/gameapi/Codebreaker.GameAPIs.Analyzers/Usings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
global using Codebreaker.GameAPIs.Contracts;
global using Codebreaker.GameAPIs.Extensions;
global using Codebreaker.GameAPIs.Models;

0 comments on commit d01ae62

Please sign in to comment.