forked from overengineering/sharpasonne
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Lee Richardson
committed
Jan 17, 2018
1 parent
4046fb4
commit 6495903
Showing
15 changed files
with
104 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ class City : IFeature | |
public IImmutableSet<Segment> Connections { get; } | ||
public bool HasShield { get; } | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ public Field(IImmutableSet<Segment> connections) | |
|
||
public IImmutableSet<Segment> Connections { get; } | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ class Monastery : IFeature | |
{ | ||
public IImmutableSet<Segment> Connections { get; } | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ internal class Road : IFeature | |
{ | ||
public IImmutableSet<Segment> Connections { get; } | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ public interface IFeature | |
{ | ||
IImmutableSet<Segment> Connections { get; } | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ public enum Orientation | |
Bottom, | ||
Left, | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ public Point(int x, int y) | |
this.Y = y; | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,5 @@ public enum Segment | |
Left, | ||
LeftTop, | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using System.Linq; | ||
using System.Security.Cryptography; | ||
using Sharpasonne.GameActions; | ||
using Sharpasonne.Rules; | ||
using Xunit; | ||
using Moq; | ||
using Optional.Unsafe; | ||
using Sharpasonne.Models; | ||
using Sharpasonne.Models.Features; | ||
|
||
namespace Sharpasonne.Tests.Rules | ||
{ | ||
public class UniqueTileInstanceRuleTests : UnitTest | ||
{ | ||
[Fact] | ||
public void When_BoardIsEmpty_Then_True() | ||
{ | ||
AssertPlaceTileTrue<UniqueTileInstanceRule>(new Engine(), MakePlaceTile(0, 0)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Linq; | ||
using Optional.Unsafe; | ||
using Sharpasonne.GameActions; | ||
using Sharpasonne.Models; | ||
using Xunit; | ||
|
||
namespace Sharpasonne.Tests.Rules | ||
{ | ||
public abstract class UnitTest | ||
{ | ||
protected void AssertPlaceTileTrue<TRule>(Engine engine, PlaceTileGameAction action) | ||
where TRule : IRule<PlaceTileGameAction>, new() | ||
{ | ||
Assert.True(new TRule().Verify(engine, action)); | ||
} | ||
|
||
public PlaceTileGameAction MakePlaceTile( | ||
int x, | ||
int y) | ||
{ | ||
var tile = new TileBuilder() | ||
.CreateTile(Enumerable.Empty<IFeature>()) | ||
.ValueOrFailure(); | ||
|
||
return new PlaceTileGameAction( | ||
new Point(x, y), | ||
new Placement(tile, Orientation.Top) | ||
); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ public interface IEngine | |
{ | ||
Board Board { get; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ namespace Sharpasonne | |
public interface IGameAction | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Sharpasonne.GameActions; | ||
|
||
namespace Sharpasonne.Rules | ||
{ | ||
abstract class AdjecentTileRule : IRule<PlaceTileGameAction> | ||
{ | ||
public abstract bool Verify<T1>(IEngine engine, T1 gameAction) where T1 : PlaceTileGameAction; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Sharpasonne.GameActions; | ||
|
||
namespace Sharpasonne.Rules | ||
{ | ||
abstract class MatchingAdjecentFeatureRule : IRule<PlaceTileGameAction> | ||
{ | ||
public abstract bool Verify<T1>(IEngine engine, T1 gameAction) where T1 : PlaceTileGameAction; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Sharpasonne.GameActions; | ||
|
||
namespace Sharpasonne.Rules | ||
{ | ||
public class UniqueTileInstanceRule : IRule<PlaceTileGameAction> | ||
{ | ||
public bool Verify<T1>(IEngine engine, T1 gameAction) where T1 : PlaceTileGameAction | ||
{ | ||
return true; | ||
} | ||
} | ||
} |