Skip to content

Commit

Permalink
[#7]: add settlements
Browse files Browse the repository at this point in the history
  • Loading branch information
3k-dome committed Apr 24, 2023
1 parent 3d414de commit efe9109
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
13 changes: 13 additions & 0 deletions catan-lib/Interfaces/ISettlement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using CatanLib.Enums;
using HexagonLib;

namespace CatanLib.Interfaces
{
public interface ISettlement : IVectorizable
{
VertexCoordinate Vertex { get; set; }
bool IsSettlement { get; }
bool IsCity { get; }
PlayerNumber? Belongs { get; }
}
}
40 changes: 40 additions & 0 deletions catan-lib/Parts/Settlement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using CatanLib.Enums;
using CatanLib.Interfaces;
using HexagonLib;

namespace CatanLib.Parts
{
public class Settlement : ISettlement
{
private VertexCoordinate? vertex;
public VertexCoordinate Vertex
{
get => vertex ?? throw new NullReferenceException();
set => vertex ??= value;
}

public bool IsSettlement { get; private set; }

public bool IsCity { get; private set; }

public PlayerNumber? Belongs { get; private set; }

public IEnumerable<float> ToVector()
{

float[] playerEncoding = new float[Enum.GetValues<PlayerNumber>().Length];
if (Belongs != null)
{
playerEncoding[(int)Belongs] = 1;
}

float[] buildingEncoding = new float[] { IsSettlement ? 1 : 0, IsCity ? 1 : 0 };
return Enumerable.Concat(playerEncoding, buildingEncoding);
}

public IEnumerable<string> ToExplainedVector()
{
throw new NotImplementedException();
}
}
}

0 comments on commit efe9109

Please sign in to comment.