squash a bunch of commits
This commit is contained in:
17
Shogi.Contracts/Api/Commands/CreateGuestTokenResponse.cs
Normal file
17
Shogi.Contracts/Api/Commands/CreateGuestTokenResponse.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
|
||||
namespace Shogi.Contracts.Api;
|
||||
|
||||
public class CreateGuestTokenResponse
|
||||
{
|
||||
public string UserId { get; }
|
||||
public string DisplayName { get; }
|
||||
public Guid OneTimeToken { get; }
|
||||
|
||||
public CreateGuestTokenResponse(string userId, string displayName, Guid oneTimeToken)
|
||||
{
|
||||
UserId = userId;
|
||||
DisplayName = displayName;
|
||||
OneTimeToken = oneTimeToken;
|
||||
}
|
||||
}
|
||||
10
Shogi.Contracts/Api/Commands/CreateSessionCommand.cs
Normal file
10
Shogi.Contracts/Api/Commands/CreateSessionCommand.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Shogi.Contracts.Api;
|
||||
|
||||
public class CreateSessionCommand
|
||||
{
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public bool IsPrivate { get; set; }
|
||||
}
|
||||
13
Shogi.Contracts/Api/Commands/CreateTokenResponse.cs
Normal file
13
Shogi.Contracts/Api/Commands/CreateTokenResponse.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace Shogi.Contracts.Api;
|
||||
|
||||
public class CreateTokenResponse
|
||||
{
|
||||
public Guid OneTimeToken { get; }
|
||||
|
||||
public CreateTokenResponse(Guid token)
|
||||
{
|
||||
OneTimeToken = token;
|
||||
}
|
||||
}
|
||||
10
Shogi.Contracts/Api/Commands/MovePieceCommand.cs
Normal file
10
Shogi.Contracts/Api/Commands/MovePieceCommand.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Shogi.Contracts.Types;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Shogi.Contracts.Api;
|
||||
|
||||
public class MovePieceCommand
|
||||
{
|
||||
[Required]
|
||||
public Move Move { get; set; }
|
||||
}
|
||||
10
Shogi.Contracts/Api/Queries/ReadAllSessionsResponse.cs
Normal file
10
Shogi.Contracts/Api/Queries/ReadAllSessionsResponse.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Shogi.Contracts.Types;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Shogi.Contracts.Api;
|
||||
|
||||
public class ReadAllSessionsResponse
|
||||
{
|
||||
public IList<SessionMetadata> PlayerHasJoinedSessions { get; set; }
|
||||
public IList<SessionMetadata> AllOtherSessions { get; set; }
|
||||
}
|
||||
8
Shogi.Contracts/Api/Queries/ReadSessionResponse.cs
Normal file
8
Shogi.Contracts/Api/Queries/ReadSessionResponse.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using Shogi.Contracts.Types;
|
||||
|
||||
namespace Shogi.Contracts.Api;
|
||||
|
||||
public class ReadSessionResponse
|
||||
{
|
||||
public Session Session { get; set; }
|
||||
}
|
||||
13
Shogi.Contracts/Shogi.Contracts.csproj
Normal file
13
Shogi.Contracts/Shogi.Contracts.csproj
Normal file
@@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<EnableNETAnalyzers>true</EnableNETAnalyzers>
|
||||
<AnalysisLevel>5</AnalysisLevel>
|
||||
<Nullable>enable</Nullable>
|
||||
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
|
||||
<Title>Shogi Service Models</Title>
|
||||
<Description>Contains DTOs use for http requests to Shogi backend services.</Description>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
13
Shogi.Contracts/Socket/CreateGame.cs
Normal file
13
Shogi.Contracts/Socket/CreateGame.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Shogi.Contracts.Types;
|
||||
|
||||
namespace Shogi.Contracts.Socket;
|
||||
|
||||
public class SessionCreatedSocketMessage : ISocketResponse
|
||||
{
|
||||
public SocketAction Action { get; }
|
||||
|
||||
public SessionCreatedSocketMessage()
|
||||
{
|
||||
Action = SocketAction.SessionCreated;
|
||||
}
|
||||
}
|
||||
9
Shogi.Contracts/Socket/ISocketRequest.cs
Normal file
9
Shogi.Contracts/Socket/ISocketRequest.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using Shogi.Contracts.Types;
|
||||
|
||||
namespace Shogi.Contracts.Socket
|
||||
{
|
||||
public interface ISocketRequest
|
||||
{
|
||||
SocketAction Action { get; }
|
||||
}
|
||||
}
|
||||
13
Shogi.Contracts/Socket/ISocketResponse.cs
Normal file
13
Shogi.Contracts/Socket/ISocketResponse.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Shogi.Contracts.Types;
|
||||
|
||||
namespace Shogi.Contracts.Socket;
|
||||
|
||||
public interface ISocketResponse
|
||||
{
|
||||
SocketAction Action { get; }
|
||||
}
|
||||
|
||||
public class SocketResponse : ISocketResponse
|
||||
{
|
||||
public SocketAction Action { get; set; }
|
||||
}
|
||||
18
Shogi.Contracts/Socket/Move.cs
Normal file
18
Shogi.Contracts/Socket/Move.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Shogi.Contracts.Types;
|
||||
|
||||
namespace Shogi.Contracts.Socket;
|
||||
|
||||
public class MoveResponse : ISocketResponse
|
||||
{
|
||||
public SocketAction Action { get; }
|
||||
public string SessionName { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// The player that made the move.
|
||||
/// </summary>
|
||||
public string PlayerName { get; set; } = string.Empty;
|
||||
|
||||
public MoveResponse()
|
||||
{
|
||||
Action = SocketAction.PieceMoved;
|
||||
}
|
||||
}
|
||||
14
Shogi.Contracts/Types/BoardState.cs
Normal file
14
Shogi.Contracts/Types/BoardState.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Shogi.Contracts.Types
|
||||
{
|
||||
public class BoardState
|
||||
{
|
||||
public Dictionary<string, Piece?> Board { get; set; } = new Dictionary<string, Piece?>();
|
||||
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; }
|
||||
}
|
||||
}
|
||||
12
Shogi.Contracts/Types/Move.cs
Normal file
12
Shogi.Contracts/Types/Move.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Shogi.Contracts.Types
|
||||
{
|
||||
public class Move
|
||||
{
|
||||
public WhichPiece? PieceFromCaptured { get; set; }
|
||||
/// <summary>Board position notation, like A3 or G1</summary>
|
||||
public string? From { get; set; }
|
||||
/// <summary>Board position notation, like A3 or G1</summary>
|
||||
public string To { get; set; } = string.Empty;
|
||||
public bool IsPromotion { get; set; }
|
||||
}
|
||||
}
|
||||
9
Shogi.Contracts/Types/Piece.cs
Normal file
9
Shogi.Contracts/Types/Piece.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Shogi.Contracts.Types
|
||||
{
|
||||
public class Piece
|
||||
{
|
||||
public bool IsPromoted { get; set; }
|
||||
public WhichPiece WhichPiece { get; set; }
|
||||
public WhichPlayer Owner { get; set; }
|
||||
}
|
||||
}
|
||||
10
Shogi.Contracts/Types/Session.cs
Normal file
10
Shogi.Contracts/Types/Session.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Shogi.Contracts.Types
|
||||
{
|
||||
public class Session
|
||||
{
|
||||
public string Player1 { get; set; }
|
||||
public string? Player2 { get; set; }
|
||||
public string SessionName { get; set; }
|
||||
public BoardState BoardState { get; set; }
|
||||
}
|
||||
}
|
||||
8
Shogi.Contracts/Types/SessionMetadata.cs
Normal file
8
Shogi.Contracts/Types/SessionMetadata.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Shogi.Contracts.Types
|
||||
{
|
||||
public class SessionMetadata
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int PlayerCount { get; set; }
|
||||
}
|
||||
}
|
||||
9
Shogi.Contracts/Types/SocketAction.cs
Normal file
9
Shogi.Contracts/Types/SocketAction.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Shogi.Contracts.Types
|
||||
{
|
||||
public enum SocketAction
|
||||
{
|
||||
SessionCreated,
|
||||
SessionJoined,
|
||||
PieceMoved
|
||||
}
|
||||
}
|
||||
9
Shogi.Contracts/Types/User.cs
Normal file
9
Shogi.Contracts/Types/User.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Shogi.Contracts.Types
|
||||
{
|
||||
public class User
|
||||
{
|
||||
public string Id { get; set; } = string.Empty;
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
8
Shogi.Contracts/Types/WhichPerspective.cs
Normal file
8
Shogi.Contracts/Types/WhichPerspective.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Shogi.Contracts.Types
|
||||
{
|
||||
public enum WhichPlayer
|
||||
{
|
||||
Player1,
|
||||
Player2
|
||||
}
|
||||
}
|
||||
14
Shogi.Contracts/Types/WhichPiece.cs
Normal file
14
Shogi.Contracts/Types/WhichPiece.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace Shogi.Contracts.Types
|
||||
{
|
||||
public enum WhichPiece
|
||||
{
|
||||
King,
|
||||
GoldGeneral,
|
||||
SilverGeneral,
|
||||
Bishop,
|
||||
Rook,
|
||||
Knight,
|
||||
Lance,
|
||||
Pawn
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user