All the code
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
namespace Websockets.ServiceModels.Types
|
||||
{
|
||||
public enum ClientAction
|
||||
{
|
||||
ListGames,
|
||||
CreateGame,
|
||||
JoinGame,
|
||||
JoinByCode,
|
||||
LoadGame,
|
||||
Move,
|
||||
KeepAlive
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Websockets.ServiceModels.Types
|
||||
{
|
||||
public class Coords
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Websockets.ServiceModels.Types
|
||||
{
|
||||
public class Game
|
||||
{
|
||||
public string GameName { get; set; }
|
||||
public string[] Players { get; set; }
|
||||
}
|
||||
}
|
||||
33
Gameboard.ShogiUI.Sockets.ServiceModels/Socket/Types/Move.cs
Normal file
33
Gameboard.ShogiUI.Sockets.ServiceModels/Socket/Types/Move.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
namespace Websockets.ServiceModels.Types
|
||||
{
|
||||
public class Move
|
||||
{
|
||||
public string PieceFromCaptured { get; set; }
|
||||
public Coords From { get; set; }
|
||||
public Coords To { get; set; }
|
||||
public bool IsPromotion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Toggles perspective of this move. (ie from player 1 to player 2)
|
||||
/// </summary>
|
||||
public static Move ConvertPerspective(Move m)
|
||||
{
|
||||
var convertedMove = new Move
|
||||
{
|
||||
To = new Coords
|
||||
{
|
||||
X = 8 - m.To.X,
|
||||
Y = 8 - m.To.Y
|
||||
},
|
||||
From = new Coords
|
||||
{
|
||||
X = 8 - m.From.X,
|
||||
Y = 8 - m.From.Y
|
||||
},
|
||||
IsPromotion = m.IsPromotion,
|
||||
PieceFromCaptured = m.PieceFromCaptured
|
||||
};
|
||||
return convertedMove;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user