squash a bunch of commits

This commit is contained in:
2022-10-30 12:03:16 -05:00
parent 09b72c1858
commit 93027e8c57
222 changed files with 6157 additions and 3201 deletions

View 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;
}
}

View 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; }
}

View File

@@ -0,0 +1,13 @@
using System;
namespace Shogi.Contracts.Api;
public class CreateTokenResponse
{
public Guid OneTimeToken { get; }
public CreateTokenResponse(Guid token)
{
OneTimeToken = token;
}
}

View 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; }
}

View 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; }
}

View File

@@ -0,0 +1,8 @@
using Shogi.Contracts.Types;
namespace Shogi.Contracts.Api;
public class ReadSessionResponse
{
public Session Session { get; set; }
}

View 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>

View 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;
}
}

View File

@@ -0,0 +1,9 @@
using Shogi.Contracts.Types;
namespace Shogi.Contracts.Socket
{
public interface ISocketRequest
{
SocketAction Action { get; }
}
}

View 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; }
}

View 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;
}
}

View 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; }
}
}

View 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; }
}
}

View 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; }
}
}

View 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; }
}
}

View File

@@ -0,0 +1,8 @@
namespace Shogi.Contracts.Types
{
public class SessionMetadata
{
public string Name { get; set; }
public int PlayerCount { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace Shogi.Contracts.Types
{
public enum SocketAction
{
SessionCreated,
SessionJoined,
PieceMoved
}
}

View 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;
}
}

View File

@@ -0,0 +1,8 @@
namespace Shogi.Contracts.Types
{
public enum WhichPlayer
{
Player1,
Player2
}
}

View File

@@ -0,0 +1,14 @@
namespace Shogi.Contracts.Types
{
public enum WhichPiece
{
King,
GoldGeneral,
SilverGeneral,
Bishop,
Rook,
Knight,
Lance,
Pawn
}
}