Before changing Piece[,] to Dictionary<string,Piece>

This commit is contained in:
2021-07-26 06:28:56 -05:00
parent f8f779e84c
commit 178cb00253
73 changed files with 1537 additions and 1418 deletions

View File

@@ -6,13 +6,13 @@ namespace Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages
public class JoinByCodeRequest : IRequest
{
public ClientAction Action { get; set; }
public string JoinCode { get; set; }
public string JoinCode { get; set; } = "";
}
public class JoinGameRequest : IRequest
{
public ClientAction Action { get; set; }
public string GameName { get; set; }
public string GameName { get; set; } = "";
}
public class JoinGameResponse : IResponse
@@ -25,6 +25,9 @@ namespace Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages
public JoinGameResponse(ClientAction action)
{
Action = action.ToString();
Error = "";
GameName = "";
PlayerName = "";
}
}
}

View File

@@ -1,6 +1,7 @@
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Interfaces;
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Types;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages
{
@@ -13,11 +14,13 @@ namespace Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages
{
public string Action { get; }
public string Error { get; set; }
public ICollection<Game> Games { get; set; }
public IReadOnlyList<Game> Games { get; set; }
public ListGamesResponse(ClientAction action)
{
Action = action.ToString();
Error = "";
Games = new Collection<Game>();
}
}
}

View File

@@ -1,19 +1,22 @@
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
{
public class LoadGameRequest : IRequest
{
public ClientAction Action { get; set; }
public string GameName { get; set; }
public string GameName { get; set; } = "";
}
public class LoadGameResponse : IResponse
{
public string Action { get; }
public Game Game { get; set; }
public WhichPlayer PlayerPerspective { get; set; }
public BoardState BoardState { get; set; }
public IList<Move> MoveHistory { get; set; }
public string Error { get; set; }
public LoadGameResponse(ClientAction action)

View File

@@ -8,5 +8,7 @@ namespace Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Types
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>();
public WhichPlayer? PlayerInCheck { get; set; }
public WhichPlayer WhoseTurn { get; set; }
}
}

View File

@@ -1,14 +1,33 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
namespace Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Types
{
public class Game
{
public string Player1 { get; set; } = string.Empty;
public string? Player2 { get; set; } = string.Empty;
public string GameName { get; set; } = string.Empty;
/// <summary>
/// Players[0] is the session owner, Players[1] is the other guy
/// Players[0] is the session owner, Players[1] is the other person.
/// </summary>
public IReadOnlyList<string> Players { get; set; } = Array.Empty<string>();
public IReadOnlyList<string> Players
{
get
{
var list = new List<string>(2) { Player1 };
if (!string.IsNullOrEmpty(Player2)) list.Add(Player2);
return list;
}
}
public Game()
{
}
public Game(string gameName, string player1, string? player2 = null)
{
GameName = gameName;
Player1 = player1;
Player2 = player2;
}
}
}