before deleting Rules

This commit is contained in:
2021-05-08 10:26:04 -05:00
parent 05a9c71499
commit f8f779e84c
80 changed files with 1109 additions and 832 deletions

View File

@@ -4,6 +4,6 @@ namespace Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Interfaces
{
public interface IRequest
{
ClientAction Action { get; set; }
ClientAction Action { get; }
}
}

View File

@@ -6,13 +6,13 @@ namespace Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages
public class CreateGameRequest : IRequest
{
public ClientAction Action { get; set; }
public string GameName { get; set; }
public string GameName { get; set; } = string.Empty;
public bool IsPrivate { get; set; }
}
public class CreateGameResponse : IResponse
{
public string Action { get; private set; }
public string Action { get; }
public string Error { get; set; }
public Game Game { get; set; }
public string PlayerName { get; set; }
@@ -20,6 +20,9 @@ namespace Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages
public CreateGameResponse(ClientAction action)
{
Action = action.ToString();
Error = string.Empty;
Game = new Game();
PlayerName = string.Empty;
}
}
}

View File

@@ -1,16 +0,0 @@
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Interfaces;
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Types;
namespace Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages
{
public class ErrorResponse : IResponse
{
public string Action { get; private set; }
public string Error { get; set; }
public ErrorResponse(ClientAction action)
{
Action = action.ToString();
}
}
}

View File

@@ -1,11 +0,0 @@
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Interfaces;
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Types;
namespace Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages
{
public class JoinByCode : IRequest
{
public ClientAction Action { get; set; }
public string JoinCode { get; set; }
}
}

View File

@@ -3,6 +3,12 @@ using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Types;
namespace Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages
{
public class JoinByCodeRequest : IRequest
{
public ClientAction Action { get; set; }
public string JoinCode { get; set; }
}
public class JoinGameRequest : IRequest
{
public ClientAction Action { get; set; }
@@ -11,7 +17,7 @@ namespace Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages
public class JoinGameResponse : IResponse
{
public string Action { get; private set; }
public string Action { get; }
public string Error { get; set; }
public string GameName { get; set; }
public string PlayerName { get; set; }

View File

@@ -11,7 +11,7 @@ namespace Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages
public class ListGamesResponse : IResponse
{
public string Action { get; private set; }
public string Action { get; }
public string Error { get; set; }
public ICollection<Game> Games { get; set; }

View File

@@ -1,6 +1,5 @@
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Interfaces;
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Types;
using System.Collections.Generic;
namespace Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages
{
@@ -12,7 +11,7 @@ namespace Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages
public class LoadGameResponse : IResponse
{
public string Action { get; private set; }
public string Action { get; }
public Game Game { get; set; }
public BoardState BoardState { get; set; }
public string Error { get; set; }

View File

@@ -6,8 +6,8 @@ namespace Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages
public class MoveRequest : IRequest
{
public ClientAction Action { get; set; }
public string GameName { get; set; }
public Move Move { get; set; }
public string GameName { get; set; } = string.Empty;
public Move Move { get; set; } = new Move();
}
public class MoveResponse : IResponse
@@ -21,6 +21,10 @@ namespace Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages
public MoveResponse(ClientAction action)
{
Action = action.ToString();
Error = string.Empty;
GameName = string.Empty;
BoardState = new BoardState();
PlayerName = string.Empty;
}
}
}

View File

@@ -1,11 +1,12 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
namespace Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Types
{
public class BoardState
{
public Piece[,] Board { get; set; }
public IReadOnlyCollection<Piece> Player1Hand { get; set; }
public IReadOnlyCollection<Piece> Player2Hand { get; set; }
public Piece[,] Board { get; set; } = new Piece[0, 0];
public IReadOnlyCollection<Piece> Player1Hand { get; set; } = Array.Empty<Piece>();
public IReadOnlyCollection<Piece> Player2Hand { get; set; } = Array.Empty<Piece>();
}
}

View File

@@ -7,7 +7,6 @@
JoinGame,
JoinByCode,
LoadGame,
Move,
KeepAlive
Move
}
}

View File

@@ -1,13 +1,14 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
namespace Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Types
{
public class Game
{
public string GameName { get; set; }
public string GameName { get; set; } = string.Empty;
/// <summary>
/// Players[0] is the session owner, Players[1] is the other guy
/// </summary>
public IReadOnlyList<string> Players { get; set; }
public IReadOnlyList<string> Players { get; set; } = Array.Empty<string>();
}
}

View File

@@ -2,11 +2,11 @@
{
public class Move
{
public string PieceFromCaptured { get; set; }
public WhichPiece? PieceFromCaptured { get; set; }
/// <summary>Board position notation, like A3 or G1</summary>
public string From { get; set; }
public string? From { get; set; }
/// <summary>Board position notation, like A3 or G1</summary>
public string To { get; set; }
public string To { get; set; } = string.Empty;
public bool IsPromotion { get; set; }
}
}

View File

@@ -2,8 +2,8 @@
{
public class Piece
{
public WhichPiece WhichPiece { get; set; }
public bool IsPromoted { get; set; }
public WhichPiece WhichPiece { get; set; }
public WhichPlayer Owner { get; set; }
}
}

View File

@@ -0,0 +1,8 @@
namespace Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Types
{
public enum WhichPlayer
{
Player1,
Player2
}
}