This commit is contained in:
2021-08-01 17:32:43 -05:00
parent 178cb00253
commit b10f61a489
76 changed files with 1655 additions and 1185 deletions

View File

@@ -0,0 +1,48 @@
using Gameboard.ShogiUI.Sockets.Models;
using PathFinding;
using System;
using System.Collections.Generic;
using System.Numerics;
namespace Gameboard.ShogiUI.Sockets.Utilities
{
public class CoordsToNotationCollection : Dictionary<string, Piece?>, IPlanarCollection<Piece>
{
public delegate void ForEachDelegate(Piece element, Vector2 position);
public CoordsToNotationCollection() : base(81, StringComparer.OrdinalIgnoreCase)
{
}
public CoordsToNotationCollection(Dictionary<string, Piece?> board) : base(board, StringComparer.OrdinalIgnoreCase)
{
}
public Piece? this[Vector2 vector]
{
get => this[NotationHelper.ToBoardNotation(vector)];
set => this[NotationHelper.ToBoardNotation(vector)] = value;
}
public Piece? this[int x, int y]
{
get => this[NotationHelper.ToBoardNotation(x, y)];
set => this[NotationHelper.ToBoardNotation(x, y)] = value;
}
public void ForEachNotNull(ForEachDelegate callback)
{
for (var x = 0; x < 9; x++)
{
for (var y = 0; y < 9; y++)
{
var position = new Vector2(x, y);
var elem = this[position];
if (elem != null)
callback(elem, position);
}
}
}
}
}