├── docs ├── styles │ ├── main.css │ ├── main.js │ └── search-worker.js ├── images │ └── logo.ico ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 ├── README.md ├── search-stopwords.json └── index.html ├── Directory.Build.targets ├── src ├── ChessSharpWeb │ ├── Views │ │ ├── _ViewStart.cshtml │ │ ├── _ViewImports.cshtml │ │ ├── Shared │ │ │ ├── _ValidationScriptsPartial.cshtml │ │ │ ├── Error.cshtml │ │ │ ├── _LoginPartial.cshtml │ │ │ └── _Layout.cshtml │ │ ├── Home │ │ │ ├── About.cshtml │ │ │ └── Index.cshtml │ │ └── Game │ │ │ └── Id.cshtml │ ├── Areas │ │ └── Identity │ │ │ └── Pages │ │ │ └── _ViewStart.cshtml │ ├── wwwroot │ │ ├── favicon.ico │ │ ├── lib │ │ │ ├── jquery-validation-unobtrusive │ │ │ │ ├── LICENSE.txt │ │ │ │ └── jquery.validate.unobtrusive.min.js │ │ │ ├── jquery-validation │ │ │ │ └── LICENSE.md │ │ │ ├── bootstrap │ │ │ │ ├── LICENSE │ │ │ │ └── dist │ │ │ │ │ └── css │ │ │ │ │ └── bootstrap-reboot.min.css │ │ │ └── jquery │ │ │ │ └── LICENSE.txt │ │ └── css │ │ │ └── site.css │ ├── appsettings.Development.json │ ├── Models │ │ ├── ErrorViewModel.cs │ │ └── Game.cs │ ├── libman.json │ ├── appsettings.json │ ├── Data │ │ ├── ApplicationDbContext.cs │ │ └── Migrations │ │ │ └── 20200101134800_Initial-Migration.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Controllers │ │ ├── HomeController.cs │ │ └── GameController.cs │ ├── ChessSharpWeb.csproj │ ├── Startup.cs │ └── Hubs │ │ └── ChessHub.cs ├── ChessSharpUno │ ├── ChessSharpUno │ │ ├── GlobalUsings.cs │ │ ├── Platforms │ │ │ ├── WebAssembly │ │ │ │ ├── WasmScripts │ │ │ │ │ └── AppManifest.js │ │ │ │ ├── LinkerConfig.xml │ │ │ │ ├── Program.cs │ │ │ │ ├── manifest.webmanifest │ │ │ │ ├── wwwroot │ │ │ │ │ ├── staticwebapp.config.json │ │ │ │ │ └── web.config │ │ │ │ └── WasmCSS │ │ │ │ │ └── Fonts.css │ │ │ ├── Android │ │ │ │ ├── environment.conf │ │ │ │ ├── Resources │ │ │ │ │ ├── values │ │ │ │ │ │ ├── Strings.xml │ │ │ │ │ │ └── Styles.xml │ │ │ │ │ └── AboutResources.txt │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── MainActivity.Android.cs │ │ │ │ ├── Assets │ │ │ │ │ └── AboutAssets.txt │ │ │ │ └── Main.Android.cs │ │ │ ├── iOS │ │ │ │ ├── Entitlements.plist │ │ │ │ ├── Main.iOS.cs │ │ │ │ ├── Info.plist │ │ │ │ └── Media.xcassets │ │ │ │ │ └── LaunchImages.launchimage │ │ │ │ │ └── Contents.json │ │ │ ├── MacCatalyst │ │ │ │ ├── Entitlements.plist │ │ │ │ ├── Main.maccatalyst.cs │ │ │ │ ├── Info.plist │ │ │ │ └── Media.xcassets │ │ │ │ │ └── LaunchImages.launchimage │ │ │ │ │ └── Contents.json │ │ │ ├── Desktop │ │ │ │ └── Program.cs │ │ │ └── Windows │ │ │ │ └── Properties │ │ │ │ └── PublishProfiles │ │ │ │ ├── win-x64.pubxml │ │ │ │ ├── win-x86.pubxml │ │ │ │ └── win-arm64.pubxml │ │ ├── Assets │ │ │ ├── Images │ │ │ │ ├── BlackKing.png │ │ │ │ ├── BlackPawn.png │ │ │ │ ├── BlackQueen.png │ │ │ │ ├── BlackRook.png │ │ │ │ ├── WhiteKing.png │ │ │ │ ├── WhitePawn.png │ │ │ │ ├── WhiteQueen.png │ │ │ │ ├── WhiteRook.png │ │ │ │ ├── BlackBishop.png │ │ │ │ ├── BlackKnight.png │ │ │ │ ├── WhiteBishop.png │ │ │ │ └── WhiteKnight.png │ │ │ ├── SharedAssets.md │ │ │ └── Icons │ │ │ │ └── icon.svg │ │ ├── BoardSquareStatus.cs │ │ ├── ReadMe.md │ │ ├── MainPage.xaml.cs │ │ ├── MainPage.xaml │ │ ├── App.xaml │ │ ├── app.manifest │ │ ├── Package.appxmanifest │ │ ├── ChessSharpUno.csproj │ │ ├── Properties │ │ │ └── launchSettings.json │ │ ├── ChessBoardGrid.cs │ │ ├── BoardSquare.cs │ │ ├── App.xaml.cs │ │ └── Strings │ │ │ └── en │ │ │ └── Resources.resw │ └── .vscode │ │ ├── extensions.json │ │ ├── settings.json │ │ ├── tasks.json │ │ └── launch.json ├── ChessUI │ ├── Resources │ │ ├── BlackKing.png │ │ ├── BlackPawn.png │ │ ├── BlackRook.png │ │ ├── WhiteKing.png │ │ ├── WhitePawn.png │ │ ├── WhiteRook.png │ │ ├── BlackBishop.png │ │ ├── BlackKnight.png │ │ ├── BlackQueen.png │ │ ├── WhiteBishop.png │ │ ├── WhiteKnight.png │ │ └── WhiteQueen.png │ ├── InputBox.cs │ ├── Program.cs │ ├── ChessUI.csproj │ ├── InputBox.Designer.cs │ └── Form1.resx ├── ChessSharp │ ├── IDeepCloneable.cs │ ├── Pieces │ │ ├── PawnMoveType.cs │ │ ├── PawnPromotion.cs │ │ ├── Queen.cs │ │ ├── Rook.cs │ │ ├── Piece.cs │ │ ├── Bishop.cs │ │ ├── Knight.cs │ │ ├── King.cs │ │ └── Pawn.cs │ ├── ExtensionMethods.cs │ ├── Player.cs │ ├── ChessSharp.csproj │ ├── SquareData │ │ ├── File.cs │ │ ├── Rank.cs │ │ └── Square.cs │ ├── GameState.cs │ ├── Move.cs │ ├── LibraryDiagram.cd │ └── ChessUtilities.cs ├── Chess.sln.DotSettings ├── ChessSharp.UnitTests │ ├── ChessSharp.UnitTests.csproj │ └── PiecesTests │ │ └── PieceTests.cs └── Chess.sln ├── Documentation ├── toc.yml ├── images │ └── logo.ico ├── index.md ├── .gitignore ├── README.md ├── docfx.json └── api │ ├── toc.yml │ ├── ChessSharp.SquareData.yml │ ├── ChessSharp.yml │ ├── ChessSharp.Pieces.yml │ ├── ChessSharp.Player.yml │ ├── ChessSharp.Pieces.PawnPromotion.yml │ └── .manifest ├── appveyor.yml ├── .github └── dependabot.yml ├── global.json ├── nuget.config ├── Directory.Build.props ├── azure-pipelines.yml ├── Directory.Packages.props ├── .vsconfig ├── README.md ├── .gitattributes └── .gitignore /docs/styles/main.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Directory.Build.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /docs/images/logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/docs/images/logo.ico -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/GlobalUsings.cs: -------------------------------------------------------------------------------- 1 | global using Microsoft.Extensions.Logging; 2 | -------------------------------------------------------------------------------- /Documentation/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Home 2 | href: index.md 3 | - name: API documentation 4 | href: api/ 5 | -------------------------------------------------------------------------------- /Documentation/images/logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/Documentation/images/logo.ico -------------------------------------------------------------------------------- /src/ChessSharpUno/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "unoplatform.vscode" 4 | ], 5 | } 6 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/Areas/Identity/Pages/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "/Views/Shared/_Layout.cshtml"; 3 | } 4 | -------------------------------------------------------------------------------- /src/ChessUI/Resources/BlackKing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessUI/Resources/BlackKing.png -------------------------------------------------------------------------------- /src/ChessUI/Resources/BlackPawn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessUI/Resources/BlackPawn.png -------------------------------------------------------------------------------- /src/ChessUI/Resources/BlackRook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessUI/Resources/BlackRook.png -------------------------------------------------------------------------------- /src/ChessUI/Resources/WhiteKing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessUI/Resources/WhiteKing.png -------------------------------------------------------------------------------- /src/ChessUI/Resources/WhitePawn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessUI/Resources/WhitePawn.png -------------------------------------------------------------------------------- /src/ChessUI/Resources/WhiteRook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessUI/Resources/WhiteRook.png -------------------------------------------------------------------------------- /src/ChessSharp/IDeepCloneable.cs: -------------------------------------------------------------------------------- 1 | namespace ChessSharp; 2 | 3 | interface IDeepCloneable 4 | { 5 | T DeepClone(); 6 | } 7 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessSharpWeb/wwwroot/favicon.ico -------------------------------------------------------------------------------- /src/ChessUI/Resources/BlackBishop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessUI/Resources/BlackBishop.png -------------------------------------------------------------------------------- /src/ChessUI/Resources/BlackKnight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessUI/Resources/BlackKnight.png -------------------------------------------------------------------------------- /src/ChessUI/Resources/BlackQueen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessUI/Resources/BlackQueen.png -------------------------------------------------------------------------------- /src/ChessUI/Resources/WhiteBishop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessUI/Resources/WhiteBishop.png -------------------------------------------------------------------------------- /src/ChessUI/Resources/WhiteKnight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessUI/Resources/WhiteKnight.png -------------------------------------------------------------------------------- /src/ChessUI/Resources/WhiteQueen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessUI/Resources/WhiteQueen.png -------------------------------------------------------------------------------- /docs/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/docs/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /docs/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/docs/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /docs/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/docs/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /docs/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/docs/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/WebAssembly/WasmScripts/AppManifest.js: -------------------------------------------------------------------------------- 1 | var UnoAppManifest = { 2 | displayName: "ChessSharpUno" 3 | } 4 | -------------------------------------------------------------------------------- /Documentation/index.md: -------------------------------------------------------------------------------- 1 | # Welcome to ChessSharp documentation 2 | 3 | ChessSharp is an open-source .NET library written in C# that handles the chess logic. -------------------------------------------------------------------------------- /src/ChessSharpWeb/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using ChessSharpWeb 2 | @using ChessSharpWeb.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | os: Visual Studio 2019 2 | build_script: 3 | - ps: dotnet --version 4 | - ps: dotnet build src 5 | - ps: dotnet test src/ChessSharp.UnitTests 6 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # ChessSharp documentation 2 | 3 | ChessSharp documentation is generated using docFX. Visit to view documentation. -------------------------------------------------------------------------------- /docs/styles/main.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information. 2 | -------------------------------------------------------------------------------- /Documentation/.gitignore: -------------------------------------------------------------------------------- 1 | ############### 2 | # folder # 3 | ############### 4 | /**/DROP/ 5 | /**/TEMP/ 6 | /**/packages/ 7 | /**/bin/ 8 | /**/obj/ 9 | _site 10 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Assets/Images/BlackKing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessSharpUno/ChessSharpUno/Assets/Images/BlackKing.png -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Assets/Images/BlackPawn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessSharpUno/ChessSharpUno/Assets/Images/BlackPawn.png -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Assets/Images/BlackQueen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessSharpUno/ChessSharpUno/Assets/Images/BlackQueen.png -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Assets/Images/BlackRook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessSharpUno/ChessSharpUno/Assets/Images/BlackRook.png -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Assets/Images/WhiteKing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessSharpUno/ChessSharpUno/Assets/Images/WhiteKing.png -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Assets/Images/WhitePawn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessSharpUno/ChessSharpUno/Assets/Images/WhitePawn.png -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Assets/Images/WhiteQueen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessSharpUno/ChessSharpUno/Assets/Images/WhiteQueen.png -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Assets/Images/WhiteRook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessSharpUno/ChessSharpUno/Assets/Images/WhiteRook.png -------------------------------------------------------------------------------- /Documentation/README.md: -------------------------------------------------------------------------------- 1 | # ChessSharp documentation 2 | 3 | ChessSharp documentation is generated using docFX. Visit to view documentation. -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Assets/Images/BlackBishop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessSharpUno/ChessSharpUno/Assets/Images/BlackBishop.png -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Assets/Images/BlackKnight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessSharpUno/ChessSharpUno/Assets/Images/BlackKnight.png -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Assets/Images/WhiteBishop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessSharpUno/ChessSharpUno/Assets/Images/WhiteBishop.png -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Assets/Images/WhiteKnight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Youssef1313/ChessSharp/HEAD/src/ChessSharpUno/ChessSharpUno/Assets/Images/WhiteKnight.png -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Generated by https://github.com/richlander/dependadotnet 2 | version: 2 3 | updates: 4 | - package-ecosystem: nuget 5 | directory: "/src" 6 | schedule: 7 | interval: daily 8 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/BoardSquareStatus.cs: -------------------------------------------------------------------------------- 1 | namespace ChessSharpUno; 2 | 3 | public enum BoardSquareStatus 4 | { 5 | Unselected, 6 | Selected, 7 | ValidMove, 8 | InCheck, 9 | } 10 | -------------------------------------------------------------------------------- /src/ChessSharpUno/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "explorer.fileNesting.enabled": true, 3 | "explorer.fileNesting.expand": false, 4 | "explorer.fileNesting.patterns": { 5 | "*.xaml": "$(capture).xaml.cs" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /global.json: -------------------------------------------------------------------------------- 1 | { 2 | // To update the version of Uno please update the version of the Uno.Sdk here. See https://aka.platform.uno/upgrade-uno-packages for more information. 3 | "msbuild-sdks": { 4 | "Uno.Sdk": "5.2.95" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace ChessSharpWeb.Models; 2 | 3 | public class ErrorViewModel 4 | { 5 | public string RequestId { get; set; } = null!; 6 | 7 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 8 | } 9 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/Android/environment.conf: -------------------------------------------------------------------------------- 1 | # See this for more details: http://developer.xamarin.com/guides/android/advanced_topics/garbage_collection/ 2 | MONO_GC_PARAMS=bridge-implementation=tarjan,nursery-size=32m,soft-heap-limit=256m -------------------------------------------------------------------------------- /src/ChessSharp/Pieces/PawnMoveType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ChessSharp.Pieces; 4 | 5 | [Flags] 6 | internal enum PawnMoveType 7 | { 8 | Invalid = 0, 9 | OneStep = 1, 10 | TwoSteps = 2, 11 | Capture = 4, 12 | Promotion = 8 13 | } -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/Android/Resources/values/Strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello World, Click Me! 4 | ChessSharpUno 5 | 6 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/iOS/Entitlements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/MacCatalyst/Entitlements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/Views/Home/About.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "About"; 3 | } 4 | 5 |

About ChessSharp

6 |

An open source chess project written in C#. Check out our repository on GitHub.

-------------------------------------------------------------------------------- /src/ChessSharp/ExtensionMethods.cs: -------------------------------------------------------------------------------- 1 | using ChessSharp.Pieces; 2 | 3 | namespace ChessSharp; 4 | 5 | internal static class ExtensionMethods 6 | { 7 | public static bool Contains(this PawnMoveType moveType1, PawnMoveType moveType2) => 8 | (moveType1 & moveType2) == moveType2; 9 | } -------------------------------------------------------------------------------- /src/ChessSharp/Player.cs: -------------------------------------------------------------------------------- 1 | namespace ChessSharp; 2 | 3 | /// Represents a player. 4 | public enum Player 5 | { 6 | /// Represents the white player. 7 | White, 8 | /// Represents the black player. 9 | Black 10 | } -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/Android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/ReadMe.md: -------------------------------------------------------------------------------- 1 | # Getting Started 2 | 3 | Welcome to the Uno Platform! 4 | 5 | To discover how to get started with your new app: https://aka.platform.uno/get-started 6 | 7 | For more information on how to use the Uno.Sdk or upgrade Uno Platform packages in your solution: https://aka.platform.uno/using-uno-sdk -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/WebAssembly/LinkerConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/WebAssembly/Program.cs: -------------------------------------------------------------------------------- 1 | namespace ChessSharpUno; 2 | 3 | public class Program 4 | { 5 | private static App? _app; 6 | 7 | public static int Main(string[] args) 8 | { 9 | Microsoft.UI.Xaml.Application.Start(_ => _app = new App()); 10 | 11 | return 0; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/WebAssembly/manifest.webmanifest: -------------------------------------------------------------------------------- 1 | { 2 | "background_color": "#ffffff", 3 | "description": "ChessSharpUno", 4 | "display": "standalone", 5 | "name": "ChessSharpUno", 6 | "short_name": "ChessSharpUno", 7 | "start_url": "/index.html", 8 | "theme_color": "#ffffff", 9 | "scope": "/" 10 | } 11 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/libman.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0", 3 | "defaultProvider": "unpkg", 4 | "libraries": [ 5 | { 6 | "library": "@microsoft/signalr@latest", 7 | "destination": "wwwroot/js/signalr", 8 | "files": [ 9 | "dist/browser/signalr.js", 10 | "dist/browser/signalr.min.js" 11 | ] 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /src/ChessSharp/ChessSharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netstandard2.1 4 | MIT 5 | 1.1.0 6 | Youssef Victor 7 | enable 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/Models/Game.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity; 2 | 3 | namespace ChessSharpWeb.Models; 4 | 5 | public class Game 6 | { 7 | public int Id { get; set; } 8 | public IdentityUser WhitePlayer { get; set; } = null!; 9 | public IdentityUser? BlackPlayer { get; set; } 10 | public string GameBoardJson { get; set; } = null!; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/ChessUI/InputBox.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace ChessUI; 5 | 6 | public partial class InputBox : Form 7 | { 8 | public string? UserInput { get; private set; } 9 | 10 | public InputBox() 11 | { 12 | InitializeComponent(); 13 | } 14 | 15 | private void button1_Click(object sender, EventArgs e) 16 | { 17 | UserInput = textBox1.Text; 18 | Close(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/MainPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.UI.Xaml.Controls; 2 | 3 | namespace ChessSharpUno; 4 | 5 | public sealed partial class MainPage : Page 6 | { 7 | public MainPage() 8 | { 9 | this.InitializeComponent(); 10 | whoseTurnTextBlock.Text = chessBoard.WhoseTurn; 11 | } 12 | 13 | private void chessBoard_MoveMade() 14 | { 15 | whoseTurnTextBlock.Text = chessBoard.WhoseTurn; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/iOS/Main.iOS.cs: -------------------------------------------------------------------------------- 1 | using UIKit; 2 | 3 | namespace ChessSharpUno.iOS; 4 | public class EntryPoint 5 | { 6 | // This is the main entry point of the application. 7 | public static void Main(string[] args) 8 | { 9 | // if you want to use a different Application Delegate class from "AppDelegate" 10 | // you can specify it here. 11 | UIApplication.Main(args, null, typeof(App)); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings": { 3 | "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-ChessSharpWeb-36C52245-0984-480E-A138-9575F40D628D;Trusted_Connection=True;MultipleActiveResultSets=true" 4 | }, 5 | "Logging": { 6 | "LogLevel": { 7 | "Default": "Information", 8 | "Microsoft": "Warning", 9 | "Microsoft.Hosting.Lifetime": "Information" 10 | } 11 | }, 12 | "AllowedHosts": "*" 13 | } 14 | -------------------------------------------------------------------------------- /src/ChessSharp/Pieces/PawnPromotion.cs: -------------------------------------------------------------------------------- 1 | namespace ChessSharp.Pieces; 2 | 3 | /// Represents the promotion of the pawn. 4 | public enum PawnPromotion 5 | { 6 | /// Promote the pawn to a knight. 7 | Knight, 8 | /// Promote the pawn to a bishop. 9 | Bishop, 10 | /// Promote the pawn to a rook. 11 | Rook, 12 | /// Promote the pawn to a queen. 13 | Queen, 14 | } -------------------------------------------------------------------------------- /src/ChessSharp/Pieces/Queen.cs: -------------------------------------------------------------------------------- 1 | namespace ChessSharp.Pieces; 2 | 3 | /// Represents a queen . 4 | public class Queen : Piece 5 | { 6 | internal Queen(Player player) : base(player) { } 7 | 8 | internal override bool IsValidGameMove(Move move, ChessGame board) 9 | { 10 | return new Rook(move.Player).IsValidGameMove(move, board) || 11 | new Bishop(move.Player).IsValidGameMove(move, board); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/Data/ApplicationDbContext.cs: -------------------------------------------------------------------------------- 1 | using ChessSharpWeb.Models; 2 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore; 4 | 5 | namespace ChessSharpWeb.Data; 6 | 7 | public class ApplicationDbContext : IdentityDbContext 8 | { 9 | public ApplicationDbContext(DbContextOptions options) 10 | : base(options) 11 | { 12 | } 13 | 14 | public DbSet Games { get; set; } = null!; 15 | } 16 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/MacCatalyst/Main.maccatalyst.cs: -------------------------------------------------------------------------------- 1 | using UIKit; 2 | 3 | namespace ChessSharpUno.MacCatalyst; 4 | public class EntryPoint 5 | { 6 | // This is the main entry point of the application. 7 | public static void Main(string[] args) 8 | { 9 | // if you want to use a different Application Delegate class from "AppDelegate" 10 | // you can specify it here. 11 | UIApplication.Main(args, null, typeof(App)); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Chess.sln.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | True 3 | True -------------------------------------------------------------------------------- /src/ChessSharp.UnitTests/ChessSharp.UnitTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/Android/MainActivity.Android.cs: -------------------------------------------------------------------------------- 1 | using Android.App; 2 | using Android.Content.PM; 3 | using Android.OS; 4 | using Android.Views; 5 | using Android.Widget; 6 | 7 | namespace ChessSharpUno.Droid; 8 | [Activity( 9 | MainLauncher = true, 10 | ConfigurationChanges = global::Uno.UI.ActivityHelper.AllConfigChanges, 11 | WindowSoftInputMode = SoftInput.AdjustNothing | SoftInput.StateHidden 12 | )] 13 | public class MainActivity : Microsoft.UI.Xaml.ApplicationActivity 14 | { 15 | } 16 | -------------------------------------------------------------------------------- /src/ChessUI/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace ChessUI; 5 | 6 | static class Program 7 | { 8 | /// 9 | /// The main entry point for the application. 10 | /// 11 | [STAThread] 12 | static void Main() 13 | { 14 | Application.SetHighDpiMode(HighDpiMode.SystemAware); 15 | Application.EnableVisualStyles(); 16 | Application.SetCompatibleTextRenderingDefault(false); 17 | Application.Run(new Form1()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /nuget.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Hosting; 3 | 4 | namespace ChessSharpWeb; 5 | 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | CreateHostBuilder(args).Build().Run(); 11 | } 12 | 13 | public static IHostBuilder CreateHostBuilder(string[] args) => 14 | Host.CreateDefaultBuilder(args) 15 | .ConfigureWebHostDefaults(webBuilder => 16 | { 17 | webBuilder.UseStartup(); 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/MainPage.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/Desktop/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Uno.UI.Runtime.Skia; 3 | 4 | namespace ChessSharpUno; 5 | public class Program 6 | { 7 | [STAThread] 8 | public static void Main(string[] args) 9 | { 10 | App.InitializeLogging(); 11 | 12 | var host = SkiaHostBuilder.Create() 13 | .App(() => new App()) 14 | .UseX11() 15 | .UseLinuxFrameBuffer() 16 | .UseMacOS() 17 | .UseWindows() 18 | .Build(); 19 | 20 | host.Run(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /src/ChessSharp/SquareData/File.cs: -------------------------------------------------------------------------------- 1 | namespace ChessSharp.SquareData; 2 | 3 | 4 | /// Represents a square file. 5 | public enum File 6 | { 7 | /// Represents the A file. 8 | A, 9 | /// Represents the B file. 10 | B, 11 | /// Represents the C file. 12 | C, 13 | /// Represents the D file. 14 | D, 15 | /// Represents the E file. 16 | E, 17 | /// Represents the F file. 18 | F, 19 | /// Represents the G file. 20 | G, 21 | /// Represents the H file. 22 | H 23 | } 24 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 |
6 |

ChessSharp

7 |

Welcome to ChessSharp!

8 |
9 | 10 |
11 |
12 |

Invite a friend to game

13 |

14 | Click the button below to invite a friend to game! 15 |

16 | 17 |

Create game

18 |
19 |
20 |

Join a game

21 |

Ask your friend who created the game to give you the game link.

22 |
23 |
-------------------------------------------------------------------------------- /src/ChessSharp/Pieces/Rook.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ChessSharp.Pieces; 4 | 5 | /// Represents a rook . 6 | public class Rook : Piece 7 | { 8 | internal Rook(Player player) : base(player) { } 9 | 10 | 11 | internal override bool IsValidGameMove(Move move, ChessGame board) 12 | { 13 | if (move == null) 14 | { 15 | throw new ArgumentNullException(nameof(move)); 16 | } 17 | 18 | if (board == null) 19 | { 20 | throw new ArgumentNullException(nameof(board)); 21 | } 22 | 23 | return (move.GetAbsDeltaX() == 0 || move.GetAbsDeltaY() == 0) && !board.IsTherePieceInBetween(move.Source, move.Destination); 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/ChessSharp/SquareData/Rank.cs: -------------------------------------------------------------------------------- 1 | namespace ChessSharp.SquareData; 2 | 3 | 4 | /// Represents a square rank. 5 | public enum Rank 6 | { 7 | /// Represents the first rank. 8 | First, 9 | /// Represents the second rank. 10 | Second, 11 | /// Represents the third rank. 12 | Third, 13 | /// Represents the forth rank. 14 | Forth, 15 | /// Represents the fifth rank. 16 | Fifth, 17 | /// Represents the sixth rank. 18 | Sixth, 19 | /// Represents the seventh rank. 20 | Seventh, 21 | /// Represents the eighth rank. 22 | Eighth 23 | } 24 | -------------------------------------------------------------------------------- /src/ChessSharp/Pieces/Piece.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace ChessSharp.Pieces; 5 | 6 | /// Represents the base class of the pieces. 7 | public abstract class Piece 8 | { 9 | 10 | /// Gets the owner of the piece. 11 | public Player Owner { get; } 12 | 13 | internal abstract bool IsValidGameMove(Move move, ChessGame board); 14 | 15 | 16 | public override bool Equals([NotNullWhen(true)] object? obj) => 17 | obj is Piece p && p.GetType() == GetType() && Owner == p.Owner; 18 | 19 | public override int GetHashCode() => HashCode.Combine(GetType(), Owner); 20 | 21 | protected Piece(Player player) => Owner = player; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/WebAssembly/wwwroot/staticwebapp.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationFallback": { 3 | "rewrite": "/index.html", 4 | "exclude": [ 5 | "*.{css,js}", 6 | "*.{png}", 7 | "*.{c,h,wasm,clr,pdb,dat,txt}" 8 | ] 9 | }, 10 | "routes": [ 11 | { 12 | "route": "/package_*", 13 | "headers": { 14 | "cache-control": "public, immutable, max-age=31536000" 15 | } 16 | }, 17 | { 18 | "route": "/*.ttf", 19 | "headers": { 20 | "cache-control": "public, immutable, max-age=31536000" 21 | } 22 | }, 23 | { 24 | "route": "/*", 25 | "headers": { 26 | "cache-control": "must-revalidate, max-age=3600" 27 | } 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /src/ChessSharp/GameState.cs: -------------------------------------------------------------------------------- 1 | namespace ChessSharp; 2 | 3 | /// Specifies the state of the game. 4 | public enum GameState 5 | { 6 | /// The game is still in progress. 7 | NotCompleted, 8 | /// The game is over and white has won. 9 | WhiteWinner, 10 | /// The game is over and black has won. 11 | BlackWinner, 12 | /// The game is over and ended in a draw. 13 | Draw, 14 | /// The game is over and ended in a stalemate. 15 | Stalemate, 16 | /// The game is not over and white is in check. 17 | WhiteInCheck, 18 | /// The game is not over and black is in check. 19 | BlackInCheck 20 | } -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/App.xaml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:60652", 7 | "sslPort": 44312 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "ChessSharpWeb": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/ChessSharp/Pieces/Bishop.cs: -------------------------------------------------------------------------------- 1 | namespace ChessSharp.Pieces; 2 | 3 | /// Represents a bishop . 4 | public class Bishop : Piece 5 | { 6 | internal Bishop(Player player) : base(player) { } 7 | 8 | 9 | internal override bool IsValidGameMove(Move move, ChessGame board) 10 | { 11 | // No need to do null checks here, this method isn't public and isn't annotated with nullable. 12 | // If the caller try to pass a possible null reference, the compiler should issue a warning. 13 | // TODO: Should I add [NotNull] attribute to the arguments? What's the benefit? 14 | // The arguments are already non-nullable. 15 | return move.GetAbsDeltaX() == move.GetAbsDeltaY() && !board.IsTherePieceInBetween(move.Source, move.Destination); 16 | } 17 | } -------------------------------------------------------------------------------- /src/ChessSharp/Pieces/Knight.cs: -------------------------------------------------------------------------------- 1 | namespace ChessSharp.Pieces; 2 | 3 | /// Represents a knight . 4 | public class Knight : Piece 5 | { 6 | internal Knight(Player player) : base(player) { } 7 | 8 | internal override bool IsValidGameMove(Move move, ChessGame board) 9 | { 10 | // No need to do null checks here, this method isn't public and isn't annotated with nullable. 11 | // If the caller try to pass a possible null reference, the compiler should issue a warning. 12 | // TODO: Should I add [NotNull] attribute to the arguments? What's the benefit? 13 | // The arguments are already non-nullable. 14 | 15 | int deltaX = move.GetAbsDeltaX(); 16 | int deltaY = move.GetAbsDeltaY(); 17 | return (deltaX == 1 && deltaY == 2) || (deltaX == 2 && deltaY == 1); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using Microsoft.AspNetCore.Mvc; 3 | using Microsoft.Extensions.Logging; 4 | using ChessSharpWeb.Models; 5 | 6 | namespace ChessSharpWeb.Controllers; 7 | 8 | public class HomeController : Controller 9 | { 10 | private readonly ILogger _logger; 11 | 12 | public HomeController(ILogger logger) 13 | { 14 | _logger = logger; 15 | } 16 | 17 | public IActionResult Index() 18 | { 19 | return View(); 20 | } 21 | 22 | public IActionResult About() 23 | { 24 | return View(); 25 | } 26 | 27 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 28 | public IActionResult Error() 29 | { 30 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/Android/Assets/AboutAssets.txt: -------------------------------------------------------------------------------- 1 | To add cross-platform image assets for your Uno Platform app, use the Assets folder 2 | in the shared project instead. Assets in this folder are Android-only assets. 3 | 4 | Any raw assets you want to be deployed with your application can be placed in 5 | this directory (and child directories) and given a Build Action of "AndroidAsset". 6 | 7 | These files will be deployed with you package and will be accessible using Android's 8 | AssetManager, like this: 9 | 10 | public class ReadAsset : Activity 11 | { 12 | protected override void OnCreate (Bundle bundle) 13 | { 14 | base.OnCreate (bundle); 15 | 16 | InputStream input = Assets.Open ("my_asset.txt"); 17 | } 18 | } 19 | 20 | Additionally, some Android functions will automatically load asset files: 21 | 22 | Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); 23 | -------------------------------------------------------------------------------- /src/ChessUI/ChessUI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinExe 5 | net8.0-windows 6 | true 7 | ChessUI.Program 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | True 17 | True 18 | Resources.resx 19 | 20 | 21 | 22 | 23 | 24 | ResXFileCodeGenerator 25 | Resources.Designer.cs 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/MacCatalyst/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIDeviceFamily 6 | 7 | 2 8 | 9 | LSApplicationCategoryType 10 | public.app-category.utilities 11 | UISupportedInterfaceOrientations 12 | 13 | UIInterfaceOrientationPortrait 14 | UIInterfaceOrientationLandscapeLeft 15 | UIInterfaceOrientationLandscapeRight 16 | 17 | XSAppIconAssets 18 | Assets.xcassets/icon.appiconset 19 | 20 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/ChessSharpWeb.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | aspnet-ChessSharpWeb-36C52245-0984-480E-A138-9575F40D628D 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

12 | Request ID: @Model.RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

26 | -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | enable 5 | true 6 | 12 7 | 8 | 14 | $(NoWarn);NU1507;NETSDK1201;PRI257 15 | 16 | 17 | 18 | 4.1.14 19 | 6.0.18 20 | 5.0.13 21 | 5.2.13 22 | 23 | 24 | -------------------------------------------------------------------------------- /Documentation/docfx.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": 3 | [ 4 | { 5 | "src": 6 | [ 7 | { 8 | "files": [ "ChessSharp/ChessSharp.csproj" ], 9 | "src": "../src" 10 | } 11 | ], 12 | "dest": "api", 13 | "disableGitFeatures": false, 14 | "disableDefaultFilter": false 15 | } 16 | ], 17 | "build": 18 | { 19 | "content": [{ "files": [ "api/**.yml", "toc.yml", "index.md" ]}], 20 | "resource": 21 | [ 22 | { 23 | "files": [ "images/**" ], 24 | "exclude": [ "obj/**" ] 25 | } 26 | ], 27 | "globalMetadata": { "_appLogoPath": "images/logo.ico", "_appFaviconPath": "images/logo.ico" }, 28 | "dest": "../docs", 29 | "globalMetadataFiles": [], 30 | "fileMetadataFiles": [], 31 | "template": [ "statictoc" ], 32 | "postProcessors": [], 33 | "markdownEngineName": "markdig", 34 | "noLangKeyword": false, 35 | "keepFileLink": false, 36 | "cleanupCacheHistory": false, 37 | "disableGitFeatures": false 38 | } 39 | } -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/WebAssembly/WasmCSS/Fonts.css: -------------------------------------------------------------------------------- 1 | /** 2 | When adding fonts here, make sure to add them using a base64 data uri, otherwise 3 | fonts loading are delayed, and text may get displayed incorrectly. 4 | */ 5 | 6 | /* https://github.com/unoplatform/uno/issues/3954 */ 7 | @font-face { 8 | font-family: 'Segoe UI'; 9 | src: local('Segoe UI'), local('-apple-system'), local('BlinkMacSystemFont'), local('Inter'), local('Cantarell'), local('Ubuntu'), local('Roboto'), local('Open Sans'), local('Noto Sans'), local('Helvetica Neue'), local('sans-serif'); 10 | } 11 | 12 | @font-face { 13 | font-family: 'Roboto'; 14 | src: url(./Uno.Fonts.Roboto/Fonts/Roboto-Light.ttf) format('truetype'); 15 | font-weight: 300; 16 | } 17 | 18 | @font-face { 19 | font-family: 'Roboto'; 20 | src: url(./Uno.Fonts.Roboto/Fonts/Roboto-Regular.ttf) format('truetype'); 21 | font-weight: 400; 22 | } 23 | 24 | @font-face { 25 | font-family: 'Roboto'; 26 | src: url(./Uno.Fonts.Roboto/Fonts/Roboto-Medium.ttf) format('truetype'); 27 | font-weight: 500; 28 | } 29 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/Android/Resources/values/Styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | # .NET Desktop 2 | # Build and run tests for .NET Desktop or Windows classic desktop solutions. 3 | # Add steps that publish symbols, save build artifacts, and more: 4 | # https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net 5 | 6 | #trigger: 7 | #- master 8 | 9 | pool: 10 | vmImage: 'windows-latest' 11 | 12 | variables: 13 | solution: '**/*.sln' 14 | buildPlatform: 'Any CPU' 15 | buildConfiguration: 'Release' 16 | 17 | #steps: 18 | #- task: DotNetCoreCLI@2 19 | # displayName: Build 20 | # inputs: 21 | # command: build 22 | # projects: '**/*.sln' 23 | # arguments: '--configuration Release' # Update this to match your need 24 | 25 | steps: 26 | - task: NuGetToolInstaller@1 27 | 28 | - task: NuGetCommand@2 29 | inputs: 30 | restoreSolution: '$(solution)' 31 | 32 | - task: VSBuild@1 33 | inputs: 34 | solution: '$(solution)' 35 | platform: '$(buildPlatform)' 36 | configuration: '$(buildConfiguration)' 37 | 38 | - task: VSTest@2 39 | inputs: 40 | platform: '$(buildPlatform)' 41 | configuration: '$(buildConfiguration)' 42 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/Views/Shared/_LoginPartial.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Identity 2 | @inject SignInManager SignInManager 3 | @inject UserManager UserManager 4 | 5 | 27 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Assets/SharedAssets.md: -------------------------------------------------------------------------------- 1 | # Shared Assets 2 | 3 | See documentation about assets here: https://github.com/unoplatform/uno/blob/master/doc/articles/features/working-with-assets.md 4 | 5 | ## Here is a cheat sheet 6 | 7 | 1. Add the image file to the `Assets` directory of a shared project. 8 | 2. Set the build action to `Content`. 9 | 3. (Recommended) Provide an asset for various scales/dpi 10 | 11 | ### Examples 12 | 13 | ```text 14 | \Assets\Images\logo.scale-100.png 15 | \Assets\Images\logo.scale-200.png 16 | \Assets\Images\logo.scale-400.png 17 | 18 | \Assets\Images\scale-100\logo.png 19 | \Assets\Images\scale-200\logo.png 20 | \Assets\Images\scale-400\logo.png 21 | ``` 22 | 23 | ### Table of scales 24 | 25 | | Scale | WinUI | iOS/MacCatalyst | Android | 26 | |-------|:-----------:|:---------------:|:-------:| 27 | | `100` | scale-100 | @1x | mdpi | 28 | | `125` | scale-125 | N/A | N/A | 29 | | `150` | scale-150 | N/A | hdpi | 30 | | `200` | scale-200 | @2x | xhdpi | 31 | | `300` | scale-300 | @3x | xxhdpi | 32 | | `400` | scale-400 | N/A | xxxhdpi | 33 | -------------------------------------------------------------------------------- /Documentation/api/toc.yml: -------------------------------------------------------------------------------- 1 | ### YamlMime:TableOfContent 2 | - uid: ChessSharp 3 | name: ChessSharp 4 | items: 5 | - uid: ChessSharp.ChessUtilities 6 | name: ChessUtilities 7 | - uid: ChessSharp.GameBoard 8 | name: GameBoard 9 | - uid: ChessSharp.GameState 10 | name: GameState 11 | - uid: ChessSharp.Move 12 | name: Move 13 | - uid: ChessSharp.Piece 14 | name: Piece 15 | - uid: ChessSharp.Player 16 | name: Player 17 | - uid: ChessSharp.Pieces 18 | name: ChessSharp.Pieces 19 | items: 20 | - uid: ChessSharp.Pieces.Bishop 21 | name: Bishop 22 | - uid: ChessSharp.Pieces.King 23 | name: King 24 | - uid: ChessSharp.Pieces.Knight 25 | name: Knight 26 | - uid: ChessSharp.Pieces.Pawn 27 | name: Pawn 28 | - uid: ChessSharp.Pieces.PawnPromotion 29 | name: PawnPromotion 30 | - uid: ChessSharp.Pieces.Queen 31 | name: Queen 32 | - uid: ChessSharp.Pieces.Rook 33 | name: Rook 34 | - uid: ChessSharp.SquareData 35 | name: ChessSharp.SquareData 36 | items: 37 | - uid: ChessSharp.SquareData.File 38 | name: File 39 | - uid: ChessSharp.SquareData.Rank 40 | name: Rank 41 | - uid: ChessSharp.SquareData.Square 42 | name: Square 43 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/Windows/Properties/PublishProfiles/win-x64.pubxml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | FileSystem 8 | x64 9 | win-x64 10 | bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\ 11 | true 12 | False 13 | False 14 | True 15 | 16 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/Windows/Properties/PublishProfiles/win-x86.pubxml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | FileSystem 8 | x86 9 | win-x86 10 | bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\ 11 | true 12 | False 13 | False 14 | True 15 | 16 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/Windows/Properties/PublishProfiles/win-arm64.pubxml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | FileSystem 8 | arm64 9 | win-arm64 10 | bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\ 11 | true 12 | False 13 | False 14 | True 15 | 16 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Directory.Packages.props: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2018 Twitter, Inc. 4 | Copyright (c) 2011-2018 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Documentation/api/ChessSharp.SquareData.yml: -------------------------------------------------------------------------------- 1 | ### YamlMime:ManagedReference 2 | items: 3 | - uid: ChessSharp.SquareData 4 | commentId: N:ChessSharp.SquareData 5 | id: ChessSharp.SquareData 6 | children: 7 | - ChessSharp.SquareData.File 8 | - ChessSharp.SquareData.Rank 9 | - ChessSharp.SquareData.Square 10 | langs: 11 | - csharp 12 | - vb 13 | name: ChessSharp.SquareData 14 | nameWithType: ChessSharp.SquareData 15 | fullName: ChessSharp.SquareData 16 | type: Namespace 17 | assemblies: 18 | - ChessSharp 19 | references: 20 | - uid: ChessSharp.SquareData.File 21 | commentId: T:ChessSharp.SquareData.File 22 | parent: ChessSharp.SquareData 23 | name: File 24 | nameWithType: File 25 | fullName: ChessSharp.SquareData.File 26 | - uid: ChessSharp.SquareData.Rank 27 | commentId: T:ChessSharp.SquareData.Rank 28 | parent: ChessSharp.SquareData 29 | name: Rank 30 | nameWithType: Rank 31 | fullName: ChessSharp.SquareData.Rank 32 | - uid: ChessSharp.SquareData.Square 33 | commentId: T:ChessSharp.SquareData.Square 34 | parent: ChessSharp.SquareData 35 | name: Square 36 | nameWithType: Square 37 | fullName: ChessSharp.SquareData.Square 38 | - uid: ChessSharp.SquareData 39 | commentId: N:ChessSharp.SquareData 40 | name: ChessSharp.SquareData 41 | nameWithType: ChessSharp.SquareData 42 | fullName: ChessSharp.SquareData 43 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Assets/Icons/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 14 | 16 | 35 | 42 | 43 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/Android/Main.Android.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Android.App; 6 | using Android.Content; 7 | using Android.OS; 8 | using Android.Runtime; 9 | using Android.Views; 10 | using Android.Widget; 11 | using Com.Nostra13.Universalimageloader.Core; 12 | using Microsoft.UI.Xaml.Media; 13 | 14 | namespace ChessSharpUno.Droid; 15 | [global::Android.App.ApplicationAttribute( 16 | Label = "@string/ApplicationName", 17 | Icon = "@mipmap/icon", 18 | LargeHeap = true, 19 | HardwareAccelerated = true, 20 | Theme = "@style/AppTheme" 21 | )] 22 | public class Application : Microsoft.UI.Xaml.NativeApplication 23 | { 24 | public Application(IntPtr javaReference, JniHandleOwnership transfer) 25 | : base(() => new App(), javaReference, transfer) 26 | { 27 | ConfigureUniversalImageLoader(); 28 | } 29 | 30 | private static void ConfigureUniversalImageLoader() 31 | { 32 | // Create global configuration and initialize ImageLoader with this config 33 | ImageLoaderConfiguration config = new ImageLoaderConfiguration 34 | .Builder(Context) 35 | .Build(); 36 | 37 | ImageLoader.Instance.Init(config); 38 | 39 | ImageSource.DefaultImageLoader = ImageLoader.Instance.LoadImageAsync; 40 | } 41 | } 42 | 43 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/app.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 21 | true/PM 22 | PerMonitorV2, PerMonitor 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Package.appxmanifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 13 | 14 | 15 | ChessSharpUno 16 | ChessSharpUno 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 32 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | LSRequiresIPhoneOS 6 | 7 | UIDeviceFamily 8 | 9 | 1 10 | 2 11 | 12 | UIRequiredDeviceCapabilities 13 | 14 | armv7 15 | arm64 16 | 17 | UISupportedInterfaceOrientations 18 | 19 | UIInterfaceOrientationPortrait 20 | UIInterfaceOrientationLandscapeLeft 21 | UIInterfaceOrientationLandscapeRight 22 | 23 | UISupportedInterfaceOrientations~ipad 24 | 25 | UIInterfaceOrientationPortrait 26 | UIInterfaceOrientationPortraitUpsideDown 27 | UIInterfaceOrientationLandscapeLeft 28 | UIInterfaceOrientationLandscapeRight 29 | 30 | UIViewControllerBasedStatusBarAppearance 31 | 32 | XSAppIconAssets 33 | Assets.xcassets/icon.appiconset 34 | UIApplicationSupportsIndirectInputEvents 35 | 36 | 37 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/iOS/Media.xcassets/LaunchImages.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images": [ 3 | { 4 | "orientation": "portrait", 5 | "extent": "full-screen", 6 | "minimum-system-version": "7.0", 7 | "scale": "2x", 8 | "size": "640x960", 9 | "idiom": "iphone" 10 | }, 11 | { 12 | "orientation": "portrait", 13 | "extent": "full-screen", 14 | "minimum-system-version": "7.0", 15 | "subtype": "retina4", 16 | "scale": "2x", 17 | "size": "640x1136", 18 | "idiom": "iphone" 19 | }, 20 | { 21 | "orientation": "portrait", 22 | "extent": "full-screen", 23 | "minimum-system-version": "7.0", 24 | "scale": "1x", 25 | "size": "768x1024", 26 | "idiom": "ipad" 27 | }, 28 | { 29 | "orientation": "landscape", 30 | "extent": "full-screen", 31 | "minimum-system-version": "7.0", 32 | "scale": "1x", 33 | "size": "1024x768", 34 | "idiom": "ipad" 35 | }, 36 | { 37 | "orientation": "portrait", 38 | "extent": "full-screen", 39 | "minimum-system-version": "7.0", 40 | "scale": "2x", 41 | "size": "1536x2048", 42 | "idiom": "ipad" 43 | }, 44 | { 45 | "orientation": "landscape", 46 | "extent": "full-screen", 47 | "minimum-system-version": "7.0", 48 | "scale": "2x", 49 | "size": "2048x1536", 50 | "idiom": "ipad" 51 | } 52 | ], 53 | "properties": {}, 54 | "info": { 55 | "version": 1, 56 | "author": "" 57 | } 58 | } -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/MacCatalyst/Media.xcassets/LaunchImages.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images": [ 3 | { 4 | "orientation": "portrait", 5 | "extent": "full-screen", 6 | "minimum-system-version": "7.0", 7 | "scale": "2x", 8 | "size": "640x960", 9 | "idiom": "iphone" 10 | }, 11 | { 12 | "orientation": "portrait", 13 | "extent": "full-screen", 14 | "minimum-system-version": "7.0", 15 | "subtype": "retina4", 16 | "scale": "2x", 17 | "size": "640x1136", 18 | "idiom": "iphone" 19 | }, 20 | { 21 | "orientation": "portrait", 22 | "extent": "full-screen", 23 | "minimum-system-version": "7.0", 24 | "scale": "1x", 25 | "size": "768x1024", 26 | "idiom": "ipad" 27 | }, 28 | { 29 | "orientation": "landscape", 30 | "extent": "full-screen", 31 | "minimum-system-version": "7.0", 32 | "scale": "1x", 33 | "size": "1024x768", 34 | "idiom": "ipad" 35 | }, 36 | { 37 | "orientation": "portrait", 38 | "extent": "full-screen", 39 | "minimum-system-version": "7.0", 40 | "scale": "2x", 41 | "size": "1536x2048", 42 | "idiom": "ipad" 43 | }, 44 | { 45 | "orientation": "landscape", 46 | "extent": "full-screen", 47 | "minimum-system-version": "7.0", 48 | "scale": "2x", 49 | "size": "2048x1536", 50 | "idiom": "ipad" 51 | } 52 | ], 53 | "properties": {}, 54 | "info": { 55 | "version": 1, 56 | "author": "" 57 | } 58 | } -------------------------------------------------------------------------------- /src/ChessSharp.UnitTests/PiecesTests/PieceTests.cs: -------------------------------------------------------------------------------- 1 | using ChessSharp.Pieces; 2 | using ChessSharp.SquareData; 3 | using NUnit.Framework; 4 | 5 | namespace ChessSharp.UnitTests; 6 | 7 | [TestFixture] 8 | public class PieceTests 9 | { 10 | [Test] 11 | public void PieceEquals_SameOwnerButDifferentPieceType_ReturnsFalse() 12 | { 13 | var game = new ChessGame(); 14 | var p1 = game[File.A, Rank.First]; // White rook. 15 | Assert.True(p1 is Rook && p1.Owner == Player.White); 16 | 17 | var p2 = game[File.B, Rank.First]; // White Knight 18 | Assert.True(p2 is Knight && p2.Owner == Player.White); 19 | 20 | Assert.False(p1!.Equals(p2)); 21 | Assert.False(p2!.Equals(p1)); 22 | } 23 | 24 | [Test] 25 | public void PieceEquals_SameReference_ReturnsTrue() 26 | { 27 | var game = new ChessGame(); 28 | var p1 = game[File.A, Rank.First]; // White rook. 29 | Assert.True(p1 is Rook && p1.Owner == Player.White); 30 | 31 | Assert.True(ReferenceEquals(p1, p1)); 32 | Assert.True(p1!.Equals(p1)); 33 | } 34 | 35 | [Test] 36 | public void PieceEquals_DifferentReferenceButSameOwnerAndType_ReturnsTrue() 37 | { 38 | var game = new ChessGame(); 39 | var p1 = game[File.A, Rank.First]; // White rook. 40 | Assert.True(p1 is Rook && p1.Owner == Player.White); 41 | 42 | game = new ChessGame(); 43 | var p2 = game[File.A, Rank.First]; // White rook. 44 | Assert.True(p2 is Rook && p2.Owner == Player.White); 45 | 46 | Assert.False(ReferenceEquals(p1, p2)); 47 | Assert.True(p1!.Equals(p2)); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Documentation/api/ChessSharp.yml: -------------------------------------------------------------------------------- 1 | ### YamlMime:ManagedReference 2 | items: 3 | - uid: ChessSharp 4 | commentId: N:ChessSharp 5 | id: ChessSharp 6 | children: 7 | - ChessSharp.ChessUtilities 8 | - ChessSharp.GameBoard 9 | - ChessSharp.GameState 10 | - ChessSharp.Move 11 | - ChessSharp.Piece 12 | - ChessSharp.Player 13 | langs: 14 | - csharp 15 | - vb 16 | name: ChessSharp 17 | nameWithType: ChessSharp 18 | fullName: ChessSharp 19 | type: Namespace 20 | assemblies: 21 | - ChessSharp 22 | references: 23 | - uid: ChessSharp.ChessUtilities 24 | commentId: T:ChessSharp.ChessUtilities 25 | name: ChessUtilities 26 | nameWithType: ChessUtilities 27 | fullName: ChessSharp.ChessUtilities 28 | - uid: ChessSharp.GameBoard 29 | commentId: T:ChessSharp.GameBoard 30 | parent: ChessSharp 31 | name: GameBoard 32 | nameWithType: GameBoard 33 | fullName: ChessSharp.GameBoard 34 | - uid: ChessSharp.GameState 35 | commentId: T:ChessSharp.GameState 36 | parent: ChessSharp 37 | name: GameState 38 | nameWithType: GameState 39 | fullName: ChessSharp.GameState 40 | - uid: ChessSharp.Move 41 | commentId: T:ChessSharp.Move 42 | parent: ChessSharp 43 | name: Move 44 | nameWithType: Move 45 | fullName: ChessSharp.Move 46 | - uid: ChessSharp.Piece 47 | commentId: T:ChessSharp.Piece 48 | parent: ChessSharp 49 | name: Piece 50 | nameWithType: Piece 51 | fullName: ChessSharp.Piece 52 | - uid: ChessSharp.Player 53 | commentId: T:ChessSharp.Player 54 | parent: ChessSharp 55 | name: Player 56 | nameWithType: Player 57 | fullName: ChessSharp.Player 58 | - uid: ChessSharp 59 | commentId: N:ChessSharp 60 | name: ChessSharp 61 | nameWithType: ChessSharp 62 | fullName: ChessSharp 63 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/ChessSharpUno.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0-windows10.0.19041;net8.0-desktop;net8.0-browserwasm 4 | 5 | Exe 6 | true 7 | 8 | 9 | ChessSharpUno 10 | 11 | com.companyname.ChessSharpUno 12 | 13 | 1.0 14 | 1 15 | 25 | 26 | 27 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright JS Foundation and other contributors, https://js.foundation/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /src/ChessSharpUno/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build-wasm", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/ChessSharpUno/ChessSharpUno.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/property:TargetFramework=net8.0-browserwasm", 13 | "/consoleloggerparameters:NoSummary" 14 | ], 15 | "problemMatcher": "$msCompile" 16 | }, 17 | { 18 | "label": "publish-wasm", 19 | "command": "dotnet", 20 | "type": "process", 21 | "args": [ 22 | "publish", 23 | "${workspaceFolder}/ChessSharpUno/ChessSharpUno.csproj", 24 | "/property:GenerateFullPaths=true", 25 | "/property:TargetFramework=net8.0-browserwasm", 26 | "/consoleloggerparameters:NoSummary" 27 | ], 28 | "problemMatcher": "$msCompile" 29 | }, 30 | { 31 | "label": "build-desktop", 32 | "command": "dotnet", 33 | "type": "process", 34 | "args": [ 35 | "build", 36 | "${workspaceFolder}/ChessSharpUno/ChessSharpUno.csproj", 37 | "/property:GenerateFullPaths=true", 38 | "/property:TargetFramework=net8.0-desktop", 39 | "/consoleloggerparameters:NoSummary" 40 | ], 41 | "problemMatcher": "$msCompile" 42 | }, 43 | { 44 | "label": "publish-desktop", 45 | "command": "dotnet", 46 | "type": "process", 47 | "args": [ 48 | "publish", 49 | "${workspaceFolder}/ChessSharpUno/ChessSharpUno.csproj", 50 | "/property:GenerateFullPaths=true", 51 | "/property:TargetFramework=net8.0-desktop", 52 | "/consoleloggerparameters:NoSummary" 53 | ], 54 | "problemMatcher": "$msCompile" 55 | } 56 | ] 57 | } 58 | -------------------------------------------------------------------------------- /docs/search-stopwords.json: -------------------------------------------------------------------------------- 1 | [ 2 | "a", 3 | "able", 4 | "about", 5 | "across", 6 | "after", 7 | "all", 8 | "almost", 9 | "also", 10 | "am", 11 | "among", 12 | "an", 13 | "and", 14 | "any", 15 | "are", 16 | "as", 17 | "at", 18 | "be", 19 | "because", 20 | "been", 21 | "but", 22 | "by", 23 | "can", 24 | "cannot", 25 | "could", 26 | "dear", 27 | "did", 28 | "do", 29 | "does", 30 | "either", 31 | "else", 32 | "ever", 33 | "every", 34 | "for", 35 | "from", 36 | "get", 37 | "got", 38 | "had", 39 | "has", 40 | "have", 41 | "he", 42 | "her", 43 | "hers", 44 | "him", 45 | "his", 46 | "how", 47 | "however", 48 | "i", 49 | "if", 50 | "in", 51 | "into", 52 | "is", 53 | "it", 54 | "its", 55 | "just", 56 | "least", 57 | "let", 58 | "like", 59 | "likely", 60 | "may", 61 | "me", 62 | "might", 63 | "most", 64 | "must", 65 | "my", 66 | "neither", 67 | "no", 68 | "nor", 69 | "not", 70 | "of", 71 | "off", 72 | "often", 73 | "on", 74 | "only", 75 | "or", 76 | "other", 77 | "our", 78 | "own", 79 | "rather", 80 | "said", 81 | "say", 82 | "says", 83 | "she", 84 | "should", 85 | "since", 86 | "so", 87 | "some", 88 | "than", 89 | "that", 90 | "the", 91 | "their", 92 | "them", 93 | "then", 94 | "there", 95 | "these", 96 | "they", 97 | "this", 98 | "tis", 99 | "to", 100 | "too", 101 | "twas", 102 | "us", 103 | "wants", 104 | "was", 105 | "we", 106 | "were", 107 | "what", 108 | "when", 109 | "where", 110 | "which", 111 | "while", 112 | "who", 113 | "whom", 114 | "why", 115 | "will", 116 | "with", 117 | "would", 118 | "yet", 119 | "you", 120 | "your" 121 | ] 122 | -------------------------------------------------------------------------------- /.vsconfig: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0", 3 | "components": [ 4 | "Microsoft.VisualStudio.Component.CoreEditor", 5 | "Microsoft.VisualStudio.Workload.CoreEditor", 6 | "Microsoft.NetCore.Component.SDK", 7 | "Microsoft.NetCore.Component.DevelopmentTools", 8 | "Microsoft.Net.ComponentGroup.DevelopmentPrerequisites", 9 | "Microsoft.VisualStudio.Component.TextTemplating", 10 | "Microsoft.VisualStudio.ComponentGroup.WebToolsExtensions", 11 | "Microsoft.NetCore.Component.Web", 12 | "Microsoft.VisualStudio.Component.IISExpress", 13 | "Component.Microsoft.Web.LibraryManager", 14 | "Microsoft.VisualStudio.ComponentGroup.Web", 15 | "Microsoft.VisualStudio.Component.Web", 16 | "Microsoft.VisualStudio.ComponentGroup.Web.Client", 17 | "Microsoft.VisualStudio.Workload.NetWeb", 18 | "Microsoft.VisualStudio.ComponentGroup.Azure.Prerequisites", 19 | "Microsoft.VisualStudio.Workload.Azure", 20 | "Microsoft.VisualStudio.ComponentGroup.WebToolsExtensions.TemplateEngine", 21 | "Microsoft.VisualStudio.Component.Windows10SDK.19041", 22 | "Microsoft.VisualStudio.ComponentGroup.MSIX.Packaging", 23 | "Microsoft.VisualStudio.Component.ManagedDesktop.Prerequisites", 24 | "Microsoft.VisualStudio.Component.Debugger.JustInTime", 25 | "Microsoft.VisualStudio.Workload.ManagedDesktop", 26 | "Microsoft.Component.NetFX.Native", 27 | "Microsoft.VisualStudio.Component.Graphics", 28 | "Microsoft.VisualStudio.Component.Merq", 29 | "Component.Xamarin.RemotedSimulator", 30 | "Microsoft.VisualStudio.Component.MonoDebugger", 31 | "Microsoft.VisualStudio.ComponentGroup.Maui.All", 32 | "Component.Android.SDK34", 33 | "Component.Android.SDK33", 34 | "Component.OpenJDK", 35 | "Microsoft.VisualStudio.Workload.NetCrossPlat", 36 | "Microsoft.VisualStudio.Workload.NetCoreTools" 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /Documentation/api/ChessSharp.Pieces.yml: -------------------------------------------------------------------------------- 1 | ### YamlMime:ManagedReference 2 | items: 3 | - uid: ChessSharp.Pieces 4 | commentId: N:ChessSharp.Pieces 5 | id: ChessSharp.Pieces 6 | children: 7 | - ChessSharp.Pieces.Bishop 8 | - ChessSharp.Pieces.King 9 | - ChessSharp.Pieces.Knight 10 | - ChessSharp.Pieces.Pawn 11 | - ChessSharp.Pieces.PawnPromotion 12 | - ChessSharp.Pieces.Queen 13 | - ChessSharp.Pieces.Rook 14 | langs: 15 | - csharp 16 | - vb 17 | name: ChessSharp.Pieces 18 | nameWithType: ChessSharp.Pieces 19 | fullName: ChessSharp.Pieces 20 | type: Namespace 21 | assemblies: 22 | - ChessSharp 23 | references: 24 | - uid: ChessSharp.Pieces.Bishop 25 | commentId: T:ChessSharp.Pieces.Bishop 26 | name: Bishop 27 | nameWithType: Bishop 28 | fullName: ChessSharp.Pieces.Bishop 29 | - uid: ChessSharp.Pieces.King 30 | commentId: T:ChessSharp.Pieces.King 31 | name: King 32 | nameWithType: King 33 | fullName: ChessSharp.Pieces.King 34 | - uid: ChessSharp.Pieces.Knight 35 | commentId: T:ChessSharp.Pieces.Knight 36 | name: Knight 37 | nameWithType: Knight 38 | fullName: ChessSharp.Pieces.Knight 39 | - uid: ChessSharp.Pieces.Pawn 40 | commentId: T:ChessSharp.Pieces.Pawn 41 | name: Pawn 42 | nameWithType: Pawn 43 | fullName: ChessSharp.Pieces.Pawn 44 | - uid: ChessSharp.Pieces.PawnPromotion 45 | commentId: T:ChessSharp.Pieces.PawnPromotion 46 | parent: ChessSharp.Pieces 47 | name: PawnPromotion 48 | nameWithType: PawnPromotion 49 | fullName: ChessSharp.Pieces.PawnPromotion 50 | - uid: ChessSharp.Pieces.Queen 51 | commentId: T:ChessSharp.Pieces.Queen 52 | name: Queen 53 | nameWithType: Queen 54 | fullName: ChessSharp.Pieces.Queen 55 | - uid: ChessSharp.Pieces.Rook 56 | commentId: T:ChessSharp.Pieces.Rook 57 | name: Rook 58 | nameWithType: Rook 59 | fullName: ChessSharp.Pieces.Rook 60 | - uid: ChessSharp.Pieces 61 | commentId: N:ChessSharp.Pieces 62 | name: ChessSharp.Pieces 63 | nameWithType: ChessSharp.Pieces 64 | fullName: ChessSharp.Pieces 65 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:8080", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | // This profile is first in order for dotnet run to pick it up by default 12 | "ChessSharpUno (WebAssembly)": { 13 | "commandName": "Project", 14 | "dotnetRunMessages": true, 15 | "launchBrowser": true, 16 | "applicationUrl": "http://localhost:5000", 17 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 18 | "environmentVariables": { 19 | "ASPNETCORE_ENVIRONMENT": "Development" 20 | } 21 | }, 22 | "ChessSharpUno (WebAssembly IIS Express)": { 23 | "commandName": "IISExpress", 24 | "launchBrowser": true, 25 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 26 | "environmentVariables": { 27 | "ASPNETCORE_ENVIRONMENT": "Development" 28 | } 29 | }, 30 | // Note: In order to select this profile, you'll need to comment the `Packaged` profile below until this is fixed: https://aka.platform.uno/wasdk-maui-debug-profile-issue 31 | "ChessSharpUno (WinAppSDK Unpackaged)": { 32 | "commandName": "Project", 33 | "compatibleTargetFramework": "windows" 34 | }, 35 | "ChessSharpUno (WinAppSDK Packaged)": { 36 | "commandName": "MsixPackage", 37 | "compatibleTargetFramework": "windows" 38 | }, 39 | "ChessSharpUno (Desktop)": { 40 | "commandName": "Project", 41 | "compatibleTargetFramework": "desktop" 42 | }, 43 | "ChessSharpUno (Desktop WSL2)": { 44 | "commandName": "WSL2", 45 | "commandLineArgs": "{ProjectDir}/bin/Debug/net8.0-desktop/ChessSharpUno.dll", 46 | "distributionName": "", 47 | "compatibleTargetFramework": "desktop" 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/Android/Resources/AboutResources.txt: -------------------------------------------------------------------------------- 1 | To add cross-platform image assets for your Uno Platform app, use the Assets folder 2 | in the shared project instead. Resources in this folder are Android-only. 3 | 4 | Images, layout descriptions, binary blobs and string dictionaries can be included 5 | in your application as resource files. Various Android APIs are designed to 6 | operate on the resource IDs instead of dealing with images, strings or binary blobs 7 | directly. 8 | 9 | For example, a sample Android app that contains a user interface layout (main.axml), 10 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) 11 | would keep its resources in the "Resources" directory of the application: 12 | 13 | Resources/ 14 | drawable/ 15 | icon.png 16 | 17 | layout/ 18 | main.axml 19 | 20 | values/ 21 | strings.xml 22 | 23 | In order to get the build system to recognize Android resources, set the build action to 24 | "AndroidResource". The native Android APIs do not operate directly with filenames, but 25 | instead operate on resource IDs. When you compile an Android application that uses resources, 26 | the build system will package the resources for distribution and generate a class called "R" 27 | (this is an Android convention) that contains the tokens for each one of the resources 28 | included. For example, for the above Resources layout, this is what the R class would expose: 29 | 30 | public class R { 31 | public class drawable { 32 | public const int icon = 0x123; 33 | } 34 | 35 | public class layout { 36 | public const int main = 0x456; 37 | } 38 | 39 | public class strings { 40 | public const int first_string = 0xabc; 41 | public const int second_string = 0xbcd; 42 | } 43 | } 44 | 45 | You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main 46 | to reference the layout/main.axml file, or R.strings.first_string to reference the first 47 | string in the dictionary file values/strings.xml. 48 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/Data/Migrations/20200101134800_Initial-Migration.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | namespace ChessSharpWeb.Data.Migrations; 4 | 5 | public partial class InitialMigration : Migration 6 | { 7 | protected override void Up(MigrationBuilder migrationBuilder) 8 | { 9 | migrationBuilder.CreateTable( 10 | name: "Games", 11 | columns: table => new 12 | { 13 | Id = table.Column(nullable: false) 14 | .Annotation("SqlServer:Identity", "1, 1"), 15 | WhitePlayerId = table.Column(nullable: true), 16 | BlackPlayerId = table.Column(nullable: true), 17 | GameBoardJson = table.Column(nullable: true) 18 | }, 19 | constraints: table => 20 | { 21 | table.PrimaryKey("PK_Games", x => x.Id); 22 | table.ForeignKey( 23 | name: "FK_Games_AspNetUsers_BlackPlayerId", 24 | column: x => x.BlackPlayerId, 25 | principalTable: "AspNetUsers", 26 | principalColumn: "Id", 27 | onDelete: ReferentialAction.Restrict); 28 | table.ForeignKey( 29 | name: "FK_Games_AspNetUsers_WhitePlayerId", 30 | column: x => x.WhitePlayerId, 31 | principalTable: "AspNetUsers", 32 | principalColumn: "Id", 33 | onDelete: ReferentialAction.Restrict); 34 | }); 35 | 36 | migrationBuilder.CreateIndex( 37 | name: "IX_Games_BlackPlayerId", 38 | table: "Games", 39 | column: "BlackPlayerId"); 40 | 41 | migrationBuilder.CreateIndex( 42 | name: "IX_Games_WhitePlayerId", 43 | table: "Games", 44 | column: "WhitePlayerId"); 45 | } 46 | 47 | protected override void Down(MigrationBuilder migrationBuilder) 48 | { 49 | migrationBuilder.DropTable( 50 | name: "Games"); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | @ViewData["Title"] - ChessSharp 7 | 8 | 9 | 10 | 11 |
12 | 32 |
33 |
34 |
35 | @RenderBody() 36 |
37 |
38 | 39 |
40 |
41 |

© @DateTime.Now.Year - ChessSharp

42 |
43 |
44 | 45 | 46 | @RenderSection("Scripts", required: false) 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/ChessSharp/Move.cs: -------------------------------------------------------------------------------- 1 | using ChessSharp.Pieces; 2 | using ChessSharp.SquareData; 3 | using System; 4 | using System.Diagnostics.CodeAnalysis; 5 | 6 | namespace ChessSharp; 7 | 8 | /// Represents a game move. 9 | public class Move : IDeepCloneable 10 | { 11 | /// Gets the source of the . 12 | public Square Source { get; } 13 | /// Gets the destination of the . 14 | public Square Destination { get; } 15 | /// Gets the of the . 16 | public Player Player { get; } 17 | /// Gets a nullable of the . 18 | public PawnPromotion? PromoteTo { get; } 19 | 20 | public Move DeepClone() 21 | { 22 | return new Move(Source, Destination, Player, PromoteTo); 23 | } 24 | 25 | public override bool Equals([NotNullWhen(true)] object? obj) => 26 | obj is Move move && 27 | move.Source == Source && 28 | move.Destination == Destination; // TODO: Is not checking promote to intended? 29 | 30 | public override int GetHashCode() => HashCode.Combine(Source, Destination, Player); 31 | 32 | /// Initializes a new instance of the class with the given arguments. 33 | /// The source of the . 34 | /// The destination of the . 35 | /// The of the . 36 | /// Optional nullable of the . Default value is null. 37 | public Move(Square source, Square destination, Player player, PawnPromotion? promoteTo = null) => 38 | (Source, Destination, Player, PromoteTo) = (source, destination, player, promoteTo); 39 | 40 | internal int GetAbsDeltaX() => Math.Abs(GetDeltaX()); 41 | 42 | internal int GetAbsDeltaY() => Math.Abs(GetDeltaY()); 43 | 44 | internal int GetDeltaX() => Destination.File - Source.File; 45 | 46 | internal int GetDeltaY() => Destination.Rank - Source.Rank; 47 | } 48 | -------------------------------------------------------------------------------- /docs/styles/search-worker.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | importScripts('lunr.min.js'); 3 | 4 | var lunrIndex; 5 | 6 | var stopWords = null; 7 | var searchData = {}; 8 | 9 | lunr.tokenizer.separator = /[\s\-\.]+/; 10 | 11 | var stopWordsRequest = new XMLHttpRequest(); 12 | stopWordsRequest.open('GET', '../search-stopwords.json'); 13 | stopWordsRequest.onload = function () { 14 | if (this.status != 200) { 15 | return; 16 | } 17 | stopWords = JSON.parse(this.responseText); 18 | buildIndex(); 19 | } 20 | stopWordsRequest.send(); 21 | 22 | var searchDataRequest = new XMLHttpRequest(); 23 | 24 | searchDataRequest.open('GET', '../index.json'); 25 | searchDataRequest.onload = function () { 26 | if (this.status != 200) { 27 | return; 28 | } 29 | searchData = JSON.parse(this.responseText); 30 | 31 | buildIndex(); 32 | 33 | postMessage({ e: 'index-ready' }); 34 | } 35 | searchDataRequest.send(); 36 | 37 | onmessage = function (oEvent) { 38 | var q = oEvent.data.q; 39 | var hits = lunrIndex.search(q); 40 | var results = []; 41 | hits.forEach(function (hit) { 42 | var item = searchData[hit.ref]; 43 | results.push({ 'href': item.href, 'title': item.title, 'keywords': item.keywords }); 44 | }); 45 | postMessage({ e: 'query-ready', q: q, d: results }); 46 | } 47 | 48 | function buildIndex() { 49 | if (stopWords !== null && !isEmpty(searchData)) { 50 | lunrIndex = lunr(function () { 51 | this.pipeline.remove(lunr.stopWordFilter); 52 | this.ref('href'); 53 | this.field('title', { boost: 50 }); 54 | this.field('keywords', { boost: 20 }); 55 | 56 | for (var prop in searchData) { 57 | if (searchData.hasOwnProperty(prop)) { 58 | this.add(searchData[prop]); 59 | } 60 | } 61 | 62 | var docfxStopWordFilter = lunr.generateStopWordFilter(stopWords); 63 | lunr.Pipeline.registerFunction(docfxStopWordFilter, 'docfxStopWordFilter'); 64 | this.pipeline.add(docfxStopWordFilter); 65 | this.searchPipeline.add(docfxStopWordFilter); 66 | }); 67 | } 68 | } 69 | 70 | function isEmpty(obj) { 71 | if(!obj) return true; 72 | 73 | for (var prop in obj) { 74 | if (obj.hasOwnProperty(prop)) 75 | return false; 76 | } 77 | 78 | return true; 79 | } 80 | })(); 81 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Welcome to ChessSharp 👋 2 | 3 | [![Build status](https://ci.appveyor.com/api/projects/status/fbrec04diyk4vf2s/branch/master?svg=true)](https://ci.appveyor.com/project/Youssef1313/chesssharp/branch/master) 4 | 5 | ChessSharp is a chess library built in C#. The repository includes a simple WinForms application that consumes the library. 6 | 7 | ## Install the package 8 | 9 | - To install the package from Package Manager Console, run the following command: 10 | 11 | ``` 12 | Install-Package ChessSharp 13 | ``` 14 | 15 | - To install the package from .NET CLI, run the following command: 16 | 17 | ``` 18 | dotnet add package ChessSharp 19 | ``` 20 | 21 | - To install using the PackageReference, add the following XML node into your project file. For more information about PackageReference, see [NuGet package reference format](https://docs.microsoft.com/nuget/consume-packages/package-references-in-project-files). 22 | 23 | ```xml 24 | 25 | ``` 26 | 27 | ## Repository structure 28 | 29 | The repository consists of three folders: 30 | 31 | - `Documentation` folder: This folder is generated by [docFX](https://github.com/dotnet/docfx). 32 | - `docs` folder: This is the actual website (defaultly called `_site`) generated by docFX. It's rendered by GitHub pages in [https://youssef1313.github.io/ChessSharp/](https://youssef1313.github.io/ChessSharp/). 33 | - `src` folder: This folder contains the actual source code and contains four folders: 34 | - `ChessSharp.UnitTests`: *Currently, there are no unit tests for the library.* 35 | - `ChessSharp`: The source code of the library. 36 | - `ChessUI`: a WinForms project that consumes the library. 37 | - `ChessSharpWeb`: an ASP.NET Core MVC project that consumes the library. **Not completed, and not working currently.** 38 | 39 | ## Screenshot of the UI (WinForms) project 40 | 41 | ![Screenshot](https://user-images.githubusercontent.com/31348972/62772795-c8ecb300-baa0-11e9-80a0-fc334f643547.png) 42 | 43 | ## 🤝 Contributing 44 | 45 | Contributions, issues, bug reports, and feature requests are welcome! 46 | 47 | Feel free to check the [issues page](https://github.com/Youssef1313/ChessSharp/issues). 48 | 49 | Can you make ChessSharp better ? Feel free to open a pull request. 50 | 51 | ## Show your support 52 | 53 | Give a ⭐️ if this project helped you! 54 | 55 | ### Please note that this project is *still under development*, but it's working well! 56 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Identity; 3 | using Microsoft.AspNetCore.Hosting; 4 | using Microsoft.EntityFrameworkCore; 5 | using ChessSharpWeb.Data; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.DependencyInjection; 8 | using Microsoft.Extensions.Hosting; 9 | using Microsoft.AspNetCore.Http; 10 | using ChessWebsite; 11 | 12 | namespace ChessSharpWeb; 13 | 14 | public class Startup 15 | { 16 | public Startup(IConfiguration configuration) 17 | { 18 | Configuration = configuration; 19 | } 20 | 21 | public IConfiguration Configuration { get; } 22 | 23 | // This method gets called by the runtime. Use this method to add services to the container. 24 | public void ConfigureServices(IServiceCollection services) 25 | { 26 | services.AddDbContext(options => 27 | options.UseSqlServer( 28 | Configuration.GetConnectionString("DefaultConnection"))); 29 | services.AddDefaultIdentity(options => options.SignIn.RequireConfirmedAccount = true) 30 | .AddEntityFrameworkStores(); 31 | services.AddControllersWithViews(); 32 | services.AddRazorPages(); 33 | // My added services. 34 | services.AddSingleton(); 35 | services.AddSignalR(); 36 | } 37 | 38 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 39 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 40 | { 41 | if (env.IsDevelopment()) 42 | { 43 | app.UseDeveloperExceptionPage(); 44 | app.UseDatabaseErrorPage(); 45 | } 46 | else 47 | { 48 | app.UseExceptionHandler("/Home/Error"); 49 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 50 | app.UseHsts(); 51 | } 52 | app.UseHttpsRedirection(); 53 | app.UseStaticFiles(); 54 | 55 | app.UseRouting(); 56 | 57 | app.UseAuthentication(); 58 | app.UseAuthorization(); 59 | 60 | app.UseEndpoints(endpoints => 61 | { 62 | endpoints.MapControllerRoute( 63 | name: "default", 64 | pattern: "{controller=Home}/{action=Index}/{id?}"); 65 | endpoints.MapRazorPages(); 66 | endpoints.MapHub("/chesshub"); 67 | }); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/Views/Game/Id.cshtml: -------------------------------------------------------------------------------- 1 | 2 | @{ 3 | ViewData["Title"] = "Id"; 4 | } 5 | 6 | @section scripts { 7 | 8 | 9 | 61 | } 62 | 63 |

White player: @Model.WhitePlayer.UserName

64 |

Black player: @((Model.BlackPlayer == null) ? "waiting for opponent to enter." : Model.BlackPlayer.UserName)

65 |

Use this page link to invite a friend.

66 | 67 |
68 | -------------------------------------------------------------------------------- /src/ChessSharpUno/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "Uno Platform Mobile", 9 | "type": "Uno", 10 | "request": "launch", 11 | // any Uno* task will do, this is simply to satisfy vscode requirement when a launch.json is present 12 | "preLaunchTask": "Uno: android | Debug | android-x64" 13 | }, 14 | { 15 | // Use IntelliSense to find out which attributes exist for C# debugging 16 | // Use hover for the description of the existing attributes 17 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 18 | "name": "Debug (Chrome, WebAssembly)", 19 | "type": "chrome", 20 | "request": "launch", 21 | "url": "http://localhost:5000", 22 | "webRoot": "${workspaceFolder}/ChessSharpUno", 23 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 24 | "timeout": 30000, 25 | "preLaunchTask": "build-wasm", 26 | "server": { 27 | "runtimeExecutable": "dotnet", 28 | "program": "run", 29 | "args": ["--no-build","-f","net8.0-browserwasm","--launch-profile", "ChessSharpUno (WebAssembly)"], 30 | "outputCapture": "std", 31 | "timeout": 30000, 32 | "cwd": "${workspaceFolder}/ChessSharpUno" 33 | } 34 | }, 35 | { 36 | // Use IntelliSense to find out which attributes exist for C# debugging 37 | // Use hover for the description of the existing attributes 38 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 39 | "name": "Uno Platform Desktop (Debug)", 40 | "type": "coreclr", 41 | "request": "launch", 42 | "preLaunchTask": "build-desktop", 43 | // If you have changed target frameworks, make sure to update the program path. 44 | "program": "${workspaceFolder}/ChessSharpUno/bin/Debug/net8.0-desktop/ChessSharpUno.dll", 45 | "args": [], 46 | "launchSettingsProfile": "ChessSharpUno (Desktop)", 47 | "env": { 48 | "DOTNET_MODIFIABLE_ASSEMBLIES": "debug" 49 | }, 50 | "cwd": "${workspaceFolder}/ChessSharpUno", 51 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console 52 | "console": "internalConsole", 53 | "stopAtEntry": false 54 | }, 55 | ] 56 | } 57 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/Controllers/GameController.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Security.Claims; 3 | using System.Threading.Tasks; 4 | 5 | using ChessSharp; 6 | using ChessSharpWeb.Data; 7 | using ChessSharpWeb.Models; 8 | using Microsoft.AspNetCore.Authorization; 9 | using Microsoft.AspNetCore.Http; 10 | using Microsoft.AspNetCore.Mvc; 11 | using Microsoft.EntityFrameworkCore; 12 | using Newtonsoft.Json; 13 | 14 | namespace ChessSharpWeb.Controllers; 15 | 16 | public class GameController : Controller 17 | { 18 | private readonly ApplicationDbContext _context; 19 | private readonly string _loggedUserId; 20 | 21 | public GameController(ApplicationDbContext context, IHttpContextAccessor httpContextAccessor) 22 | { 23 | _context = context; 24 | _loggedUserId = httpContextAccessor.HttpContext!.User.FindFirst(ClaimTypes.NameIdentifier)!.Value; 25 | } 26 | 27 | // GET: Game 28 | //public ActionResult Index() 29 | //{ 30 | // return View(); 31 | //} 32 | 33 | // GET: Game/Create 34 | [Authorize] 35 | public async Task Create() 36 | { 37 | var settings = new JsonSerializerSettings 38 | { 39 | TypeNameHandling = TypeNameHandling.All 40 | }; 41 | 42 | DbSet games = _context.Games; 43 | var gameBoard = new GameBoard(); 44 | var createdGame = new Game 45 | { 46 | WhitePlayer = _context.Users.First(u => u.Id == _loggedUserId), 47 | BlackPlayer = null, 48 | GameBoardJson = JsonConvert.SerializeObject(gameBoard, settings) 49 | }; 50 | games.Add(createdGame); 51 | await _context.SaveChangesAsync(); 52 | return RedirectToAction("Id", "Game", new { id = createdGame.Id }); 53 | } 54 | 55 | [Authorize] 56 | public async Task Id(int id) 57 | { 58 | var games = _context.Games; 59 | var game = games.Include(g => g.WhitePlayer) 60 | .Include(g => g.BlackPlayer) 61 | .FirstOrDefault(g => g.Id == id); 62 | if (game == null) 63 | { 64 | return NotFound(); 65 | } 66 | 67 | // Opponent entered. 68 | if (game.BlackPlayer == null && game.WhitePlayer.Id != _loggedUserId) 69 | { 70 | game.BlackPlayer = _context.Users.First(u => u.Id == _loggedUserId); 71 | await _context.SaveChangesAsync(); 72 | } 73 | if (game.WhitePlayer.Id == _loggedUserId || game.BlackPlayer!.Id == _loggedUserId) 74 | { 75 | ViewBag.UserId = _loggedUserId; 76 | return View(game); 77 | } 78 | 79 | return NotFound(); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /src/ChessUI/InputBox.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace ChessUI 2 | { 3 | partial class InputBox 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 33 | this.ClientSize = new System.Drawing.Size(250, 150); 34 | this.Text = "Promotion"; 35 | this.MaximizeBox = false; 36 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; 37 | this.label1 = new System.Windows.Forms.Label(); 38 | this.textBox1 = new System.Windows.Forms.TextBox(); 39 | this.button1 = new System.Windows.Forms.Button(); 40 | // 41 | // label1 42 | // 43 | this.label1.Text = "Promote to what ?"; 44 | this.label1.Name = "label1"; 45 | this.label1.Location = new System.Drawing.Point(10, 10); 46 | // 47 | // textBox1 48 | // 49 | this.textBox1.Name = "textBox1"; 50 | this.textBox1.Size = new System.Drawing.Size(230, 20); 51 | this.textBox1.Location = new System.Drawing.Point(10, 50); 52 | // 53 | // button1 54 | // 55 | this.button1.Name = "button1"; 56 | this.button1.Location = new System.Drawing.Point(10, 90); 57 | this.button1.Text = "OK"; 58 | this.button1.Click += button1_Click; 59 | 60 | this.Controls.Add(label1); 61 | this.Controls.Add(textBox1); 62 | this.Controls.Add(button1); 63 | } 64 | 65 | private System.Windows.Forms.Label label1; 66 | private System.Windows.Forms.TextBox textBox1; 67 | private System.Windows.Forms.Button button1; 68 | 69 | #endregion 70 | } 71 | } -------------------------------------------------------------------------------- /Documentation/api/ChessSharp.Player.yml: -------------------------------------------------------------------------------- 1 | ### YamlMime:ManagedReference 2 | items: 3 | - uid: ChessSharp.Player 4 | commentId: T:ChessSharp.Player 5 | id: Player 6 | parent: ChessSharp 7 | children: 8 | - ChessSharp.Player.Black 9 | - ChessSharp.Player.White 10 | langs: 11 | - csharp 12 | - vb 13 | name: Player 14 | nameWithType: Player 15 | fullName: ChessSharp.Player 16 | type: Enum 17 | source: 18 | remote: 19 | path: src/ChessSharp/Player.cs 20 | branch: master 21 | repo: https://github.com/Youssef1313/ChessSharp.git 22 | id: Player 23 | path: ../src/ChessSharp/Player.cs 24 | startLine: 3 25 | assemblies: 26 | - ChessSharp 27 | namespace: ChessSharp 28 | summary: Represents a player. 29 | example: [] 30 | syntax: 31 | content: public enum Player 32 | content.vb: Public Enum Player 33 | modifiers.csharp: 34 | - public 35 | - enum 36 | modifiers.vb: 37 | - Public 38 | - Enum 39 | - uid: ChessSharp.Player.White 40 | commentId: F:ChessSharp.Player.White 41 | id: White 42 | parent: ChessSharp.Player 43 | langs: 44 | - csharp 45 | - vb 46 | name: White 47 | nameWithType: Player.White 48 | fullName: ChessSharp.Player.White 49 | type: Field 50 | source: 51 | remote: 52 | path: src/ChessSharp/Player.cs 53 | branch: master 54 | repo: https://github.com/Youssef1313/ChessSharp.git 55 | id: White 56 | path: ../src/ChessSharp/Player.cs 57 | startLine: 6 58 | assemblies: 59 | - ChessSharp 60 | namespace: ChessSharp 61 | summary: Represents the white player. 62 | example: [] 63 | syntax: 64 | content: White = 0 65 | return: 66 | type: ChessSharp.Player 67 | modifiers.csharp: 68 | - public 69 | - const 70 | modifiers.vb: 71 | - Public 72 | - Const 73 | - uid: ChessSharp.Player.Black 74 | commentId: F:ChessSharp.Player.Black 75 | id: Black 76 | parent: ChessSharp.Player 77 | langs: 78 | - csharp 79 | - vb 80 | name: Black 81 | nameWithType: Player.Black 82 | fullName: ChessSharp.Player.Black 83 | type: Field 84 | source: 85 | remote: 86 | path: src/ChessSharp/Player.cs 87 | branch: master 88 | repo: https://github.com/Youssef1313/ChessSharp.git 89 | id: Black 90 | path: ../src/ChessSharp/Player.cs 91 | startLine: 8 92 | assemblies: 93 | - ChessSharp 94 | namespace: ChessSharp 95 | summary: Represents the black player. 96 | example: [] 97 | syntax: 98 | content: Black = 1 99 | return: 100 | type: ChessSharp.Player 101 | modifiers.csharp: 102 | - public 103 | - const 104 | modifiers.vb: 105 | - Public 106 | - Const 107 | references: 108 | - uid: ChessSharp 109 | commentId: N:ChessSharp 110 | name: ChessSharp 111 | nameWithType: ChessSharp 112 | fullName: ChessSharp 113 | - uid: ChessSharp.Player 114 | commentId: T:ChessSharp.Player 115 | parent: ChessSharp 116 | name: Player 117 | nameWithType: Player 118 | fullName: ChessSharp.Player 119 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Provide sufficient contrast against white background */ 11 | a { 12 | color: #0366d6; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 22 | color: #fff; 23 | background-color: #1b6ec2; 24 | border-color: #1861ac; 25 | } 26 | 27 | /* Sticky footer styles 28 | -------------------------------------------------- */ 29 | html { 30 | font-size: 14px; 31 | } 32 | @media (min-width: 768px) { 33 | html { 34 | font-size: 16px; 35 | } 36 | } 37 | 38 | .border-top { 39 | border-top: 1px solid #e5e5e5; 40 | } 41 | .border-bottom { 42 | border-bottom: 1px solid #e5e5e5; 43 | } 44 | 45 | .box-shadow { 46 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 47 | } 48 | 49 | button.accept-policy { 50 | font-size: 1rem; 51 | line-height: inherit; 52 | } 53 | 54 | /* Sticky footer styles 55 | -------------------------------------------------- */ 56 | html { 57 | position: relative; 58 | min-height: 100%; 59 | } 60 | 61 | body { 62 | /* Margin bottom by footer height */ 63 | margin-bottom: 60px; 64 | } 65 | .footer { 66 | position: absolute; 67 | bottom: 0; 68 | width: 100%; 69 | white-space: nowrap; 70 | line-height: 60px; /* Vertically center the text there */ 71 | } 72 | 73 | /* My changes starts here */ 74 | .square { 75 | height: 70px; 76 | width: 70px; 77 | display: inline-block; 78 | margin: 0; 79 | background-size: contain; 80 | } 81 | 82 | .dark-square { 83 | background-color: #b58863; 84 | } 85 | 86 | .light-square { 87 | background-color: #f0d9b5; 88 | } 89 | 90 | .rank { 91 | font-size: 0; 92 | } 93 | 94 | .WhitePawn { 95 | background-image: url(Images/WhitePawn.png); 96 | } 97 | 98 | .WhiteKnight { 99 | background-image: url(Images/WhiteKnight.png); 100 | } 101 | 102 | .WhiteBishop { 103 | background-image: url(Images/WhiteBishop.png); 104 | } 105 | 106 | .WhiteRook { 107 | background-image: url(Images/WhiteRook.png); 108 | } 109 | 110 | .WhiteQueen { 111 | background-image: url(Images/WhiteQueen.png); 112 | } 113 | 114 | .WhiteKing { 115 | background-image: url(Images/WhiteKing.png); 116 | } 117 | 118 | .BlackPawn { 119 | background-image: url(Images/BlackPawn.png); 120 | } 121 | 122 | .BlackKnight { 123 | background-image: url(Images/BlackKnight.png); 124 | } 125 | 126 | .BlackBishop { 127 | background-image: url(Images/BlackBishop.png); 128 | } 129 | 130 | .BlackRook { 131 | background-image: url(Images/BlackRook.png); 132 | } 133 | 134 | .BlackQueen { 135 | background-image: url(Images/BlackQueen.png); 136 | } 137 | 138 | .BlackKing { 139 | background-image: url(Images/BlackKing.png); 140 | } 141 | 142 | -------------------------------------------------------------------------------- /src/ChessSharp/Pieces/King.cs: -------------------------------------------------------------------------------- 1 | using ChessSharp.SquareData; 2 | 3 | namespace ChessSharp.Pieces; 4 | 5 | /// Represents a king . 6 | public class King : Piece 7 | { 8 | internal King(Player player) : base(player) { } 9 | 10 | internal override bool IsValidGameMove(Move move, ChessGame board) 11 | { 12 | // No need to do null checks here, this method isn't public and isn't annotated with nullable. 13 | // If the caller try to pass a possible null reference, the compiler should issue a warning. 14 | // TODO: Should I add [NotNull] attribute to the arguments? What's the benefit? 15 | // The arguments are already non-nullable. 16 | 17 | int absDeltaX = move.GetAbsDeltaX(); 18 | int absDeltaY = move.GetAbsDeltaY(); 19 | 20 | // Regular king move. 21 | if (move.GetAbsDeltaX() <= 1 && move.GetAbsDeltaY() <= 1) 22 | { 23 | return true; 24 | } 25 | // Not castle move. 26 | if (absDeltaX != 2 || absDeltaY != 0 || move.Source.File != File.E || 27 | (move.Player == Player.White && move.Source.Rank != Rank.First) || 28 | (move.Player == Player.Black && move.Source.Rank != Rank.Eighth) || 29 | (board.GameState == GameState.BlackInCheck || board.GameState == GameState.WhiteInCheck)) 30 | { 31 | return false; 32 | } 33 | 34 | // White king-side castle move. 35 | if (move.Player == Player.White && move.Destination.File == File.G && board.CanWhiteCastleKingSide && 36 | !board.IsTherePieceInBetween(move.Source, new Square(File.H, Rank.First)) && 37 | new Rook(Player.White).Equals(board[File.H, Rank.First])) 38 | { 39 | return !board.PlayerWillBeInCheck( 40 | new Move(move.Source, new Square(File.F, Rank.First), move.Player)); 41 | } 42 | 43 | // Black king-side castle move. 44 | if (move.Player == Player.Black && move.Destination.File == File.G && board.CanBlackCastleKingSide && 45 | !board.IsTherePieceInBetween(move.Source, new Square(File.H, Rank.Eighth)) && 46 | new Rook(Player.Black).Equals(board[File.H, Rank.Eighth])) 47 | { 48 | return !board.PlayerWillBeInCheck( 49 | new Move(move.Source, new Square(File.F, Rank.Eighth), move.Player)); 50 | } 51 | 52 | // White queen-side castle move. 53 | if (move.Player == Player.White && move.Destination.File == File.C && board.CanWhiteCastleQueenSide && 54 | !board.IsTherePieceInBetween(move.Source, new Square(File.A, Rank.First)) && 55 | new Rook(Player.White).Equals(board[File.A, Rank.First])) 56 | { 57 | return !board.PlayerWillBeInCheck( 58 | new Move(move.Source, new Square(File.D, Rank.First), move.Player)); 59 | } 60 | 61 | // Black queen-side castle move. 62 | if (move.Player == Player.Black && move.Destination.File == File.C && board.CanBlackCastleQueenSide && 63 | !board.IsTherePieceInBetween(move.Source, new Square(File.A, Rank.Eighth)) && 64 | new Rook(Player.Black).Equals(board[File.A, Rank.Eighth])) 65 | { 66 | return !board.PlayerWillBeInCheck( 67 | new Move(move.Source, new Square(File.D, Rank.Eighth), move.Player)); 68 | } 69 | 70 | return false; 71 | 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/Chess.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.10.34607.79 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChessSharp", "ChessSharp\ChessSharp.csproj", "{14AF9C40-B183-41EB-A2FB-40D97EC71125}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChessUI", "ChessUI\ChessUI.csproj", "{1A14EB92-18BF-4CEB-AAB2-1E5E357EC84D}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChessSharpWeb", "ChessSharpWeb\ChessSharpWeb.csproj", "{6C3157EA-B624-4347-88D9-AF60EC7BFB06}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChessSharp.UnitTests", "ChessSharp.UnitTests\ChessSharp.UnitTests.csproj", "{67815E3D-5E38-4796-928E-05F4A389879B}" 13 | EndProject 14 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ChessSharpUno", "ChessSharpUno", "{50047599-DE12-4DA4-9AF7-39E179DAA392}" 15 | EndProject 16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChessSharpUno", "ChessSharpUno\ChessSharpUno\ChessSharpUno.csproj", "{7B83D419-6291-40C3-9881-CF14D14E1E0B}" 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 20 | Debug|Any CPU = Debug|Any CPU 21 | Release|Any CPU = Release|Any CPU 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {14AF9C40-B183-41EB-A2FB-40D97EC71125}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {14AF9C40-B183-41EB-A2FB-40D97EC71125}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {14AF9C40-B183-41EB-A2FB-40D97EC71125}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {14AF9C40-B183-41EB-A2FB-40D97EC71125}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {1A14EB92-18BF-4CEB-AAB2-1E5E357EC84D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {1A14EB92-18BF-4CEB-AAB2-1E5E357EC84D}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {1A14EB92-18BF-4CEB-AAB2-1E5E357EC84D}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {1A14EB92-18BF-4CEB-AAB2-1E5E357EC84D}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {6C3157EA-B624-4347-88D9-AF60EC7BFB06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {6C3157EA-B624-4347-88D9-AF60EC7BFB06}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {6C3157EA-B624-4347-88D9-AF60EC7BFB06}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {6C3157EA-B624-4347-88D9-AF60EC7BFB06}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {67815E3D-5E38-4796-928E-05F4A389879B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 37 | {67815E3D-5E38-4796-928E-05F4A389879B}.Debug|Any CPU.Build.0 = Debug|Any CPU 38 | {67815E3D-5E38-4796-928E-05F4A389879B}.Release|Any CPU.ActiveCfg = Release|Any CPU 39 | {67815E3D-5E38-4796-928E-05F4A389879B}.Release|Any CPU.Build.0 = Release|Any CPU 40 | {7B83D419-6291-40C3-9881-CF14D14E1E0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 | {7B83D419-6291-40C3-9881-CF14D14E1E0B}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 | {7B83D419-6291-40C3-9881-CF14D14E1E0B}.Debug|Any CPU.Deploy.0 = Debug|Any CPU 43 | {7B83D419-6291-40C3-9881-CF14D14E1E0B}.Release|Any CPU.ActiveCfg = Release|Any CPU 44 | {7B83D419-6291-40C3-9881-CF14D14E1E0B}.Release|Any CPU.Build.0 = Release|Any CPU 45 | EndGlobalSection 46 | GlobalSection(SolutionProperties) = preSolution 47 | HideSolutionNode = FALSE 48 | EndGlobalSection 49 | GlobalSection(NestedProjects) = preSolution 50 | {7B83D419-6291-40C3-9881-CF14D14E1E0B} = {50047599-DE12-4DA4-9AF7-39E179DAA392} 51 | EndGlobalSection 52 | GlobalSection(ExtensibilityGlobals) = postSolution 53 | SolutionGuid = {510EDAEF-7FB9-48B2-9BED-389416606E34} 54 | EndGlobalSection 55 | EndGlobal 56 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Platforms/WebAssembly/wwwroot/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/ChessBoardGrid.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using ChessSharp; 4 | using ChessSharp.SquareData; 5 | using Microsoft.UI.Xaml; 6 | using Microsoft.UI.Xaml.Controls; 7 | 8 | namespace ChessSharpUno; 9 | 10 | public sealed partial class ChessBoardGrid : Grid 11 | { 12 | private readonly ChessGame _game = new(); 13 | private Dictionary _boardSquareMap = new(); 14 | 15 | private Square? _selectedSquare; 16 | private List _validMoves = new(); 17 | 18 | public string WhoseTurn { get; private set; } 19 | 20 | public ChessBoardGrid() 21 | { 22 | for (int i = 0; i < 8; i++) 23 | { 24 | ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); 25 | RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); 26 | } 27 | 28 | for (File file = File.A; file <= File.H; file++) 29 | { 30 | for (Rank rank = Rank.First; rank <= Rank.Eighth; rank++) 31 | { 32 | var boardSquare = new BoardSquare(file, rank, this); 33 | boardSquare.Piece = _game[file, rank]; 34 | Grid.SetRow(boardSquare, 7 - (int)rank); 35 | Grid.SetColumn(boardSquare, (int)file); 36 | Children.Add(boardSquare); 37 | _boardSquareMap[new Square(file, rank)] = boardSquare; 38 | } 39 | } 40 | 41 | WhoseTurn = _game.WhoseTurn.ToString(); 42 | } 43 | 44 | private void UpdateBoard() 45 | { 46 | for (File file = File.A; file <= File.H; file++) 47 | { 48 | for (Rank rank = Rank.First; rank <= Rank.Eighth; rank++) 49 | { 50 | _boardSquareMap[new Square(file, rank)].Piece = _game[file, rank]; 51 | } 52 | } 53 | } 54 | 55 | public event Action? MoveMade; 56 | 57 | public void ClickSquare(File file, Rank rank) 58 | { 59 | if (_selectedSquare.HasValue) 60 | { 61 | _boardSquareMap[_selectedSquare.Value].Status = BoardSquareStatus.Unselected; 62 | } 63 | 64 | foreach (var oldValidMove in _validMoves) 65 | { 66 | _boardSquareMap[oldValidMove].Status = BoardSquareStatus.Unselected; 67 | } 68 | 69 | var clickedSquare = new Square(file, rank); 70 | if (_selectedSquare.HasValue && _validMoves.Contains(clickedSquare)) 71 | { 72 | _game.MakeMove(new Move(_selectedSquare.Value, clickedSquare, _game.WhoseTurn), isMoveValidated: true); 73 | 74 | try 75 | { 76 | WhoseTurn = _game.WhoseTurn.ToString(); 77 | MoveMade?.Invoke(); 78 | } 79 | catch { } 80 | 81 | _selectedSquare = null; 82 | _validMoves.Clear(); 83 | 84 | UpdateBoard(); 85 | } 86 | else 87 | { 88 | _validMoves.Clear(); 89 | var moves = ChessUtilities.GetValidMovesOfSourceSquare(clickedSquare, _game); 90 | if (moves.Count > 0) 91 | { 92 | _selectedSquare = clickedSquare; 93 | _boardSquareMap[clickedSquare].Status = BoardSquareStatus.Selected; 94 | foreach (var move in moves) 95 | { 96 | _validMoves.Add(move.Destination); 97 | var possibleDestination = _boardSquareMap[move.Destination]; 98 | possibleDestination.Status = BoardSquareStatus.ValidMove; 99 | } 100 | } 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/ChessSharp/SquareData/Square.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | using System.Globalization; 4 | 5 | namespace ChessSharp.SquareData; 6 | 7 | internal class Parser 8 | { 9 | private static File ParseFile(char file) 10 | { 11 | // Culture doesn't really matter here, but to silence CA1304 12 | file = char.ToUpper(file, CultureInfo.InvariantCulture); 13 | if (file < 'A' || file > 'H') 14 | { 15 | throw new ArgumentOutOfRangeException(nameof(file)); 16 | } 17 | 18 | return (File)(file - 'A'); 19 | } 20 | 21 | private static Rank ParseRank(char rank) 22 | { 23 | if (rank < '1' || rank > '8') 24 | { 25 | throw new ArgumentOutOfRangeException(nameof(rank)); 26 | } 27 | return (Rank)(rank - '1'); 28 | } 29 | 30 | public static Square Parse(string square) 31 | { 32 | _ = square ?? throw new ArgumentNullException(nameof(square)); 33 | 34 | if (square.Length != 2) 35 | { 36 | throw new ArgumentException("Argument length must be 2", nameof(square)); 37 | } 38 | 39 | File file = ParseFile(square[0]); 40 | Rank rank = ParseRank(square[1]); 41 | 42 | return new Square(file, rank); 43 | } 44 | 45 | public static Square Parse(ReadOnlySpan square) 46 | { 47 | if (square.Length != 2) 48 | { 49 | throw new ArgumentException("Argument length must be 2", nameof(square)); 50 | } 51 | 52 | File file = ParseFile(square[0]); 53 | Rank rank = ParseRank(square[1]); 54 | 55 | return new Square(file, rank); 56 | } 57 | } 58 | 59 | /// Represents a chess square. 60 | public struct Square : IEquatable 61 | { 62 | 63 | /// 64 | /// Initializes a new instance of the Squareclass. 65 | /// 66 | /// A enum representing the file of the square. 67 | /// A enum representing the rank of the square. 68 | public Square(File file, Rank rank) 69 | { 70 | File = file; 71 | Rank = rank; 72 | } 73 | 74 | #pragma warning disable CA2225 // Operator overloads have named alternates - Investigate this later. 75 | public static implicit operator Square(string s) => Parser.Parse(s); 76 | public static implicit operator Square(ReadOnlySpan s) => Parser.Parse(s); 77 | #pragma warning restore CA2225 // Operator overloads have named alternates - Investigate this later. 78 | 79 | /// Gets the of the square. 80 | public File File { get; } 81 | 82 | /// Gets the of the square. 83 | public Rank Rank { get; } 84 | 85 | public override bool Equals([NotNullWhen(true)] object? obj) => 86 | obj is Square sq && sq.File == File && sq.Rank == Rank; 87 | 88 | public override int GetHashCode() => HashCode.Combine(File, Rank); 89 | 90 | /// Converts the given square to a string. 91 | /// Returns string representation of the square. For example, it returns "G2" for a square with G file and second rank. 92 | public override string ToString() => $"{File}{(int)Rank + 1}"; 93 | 94 | public bool Equals(Square other) => other.File == File && other.Rank == Rank; // TODO: What if `other` is null? 95 | 96 | public static bool operator ==(Square left, Square right) => left.Equals(right); 97 | 98 | public static bool operator !=(Square left, Square right) => !(left == right); 99 | } 100 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/BoardSquare.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using ChessSharp.Pieces; 3 | using ChessSharp.SquareData; 4 | using Microsoft.UI; 5 | using Microsoft.UI.Xaml; 6 | using Microsoft.UI.Xaml.Controls; 7 | using Microsoft.UI.Xaml.Input; 8 | using Microsoft.UI.Xaml.Media; 9 | using Microsoft.UI.Xaml.Media.Imaging; 10 | using Windows.UI; 11 | 12 | namespace ChessSharpUno; 13 | 14 | public sealed partial class BoardSquare : Grid 15 | { 16 | private readonly Image _image; 17 | private readonly ChessBoardGrid _boardGrid; 18 | private readonly File _file; 19 | private readonly Rank _rank; 20 | 21 | public BoardSquare(File file, Rank rank, ChessBoardGrid boardGrid) 22 | { 23 | Width = 60; 24 | Height = 60; 25 | _file = file; 26 | _rank = rank; 27 | _image = new Image(); 28 | _boardGrid = boardGrid; 29 | Children.Add(_image); 30 | OnStatusChanged(BoardSquareStatus.Unselected); 31 | PointerReleased += OnSquareClick; 32 | } 33 | 34 | private void OnSquareClick(object sender, PointerRoutedEventArgs e) 35 | => _boardGrid.ClickSquare(_file, _rank); 36 | 37 | public Piece? Piece 38 | { 39 | get => (Piece?)GetValue(PieceProperty); 40 | set => SetValue(PieceProperty, value); 41 | } 42 | 43 | public static DependencyProperty PieceProperty { get; } = DependencyProperty.Register( 44 | nameof(Piece), 45 | typeof(Piece), 46 | typeof(BoardSquare), new PropertyMetadata(null, propertyChangedCallback: (sender, args) => ((BoardSquare)sender).OnPieceChanged(args))); 47 | 48 | 49 | 50 | public BoardSquareStatus Status 51 | { 52 | get => (BoardSquareStatus)GetValue(StatusProperty); 53 | set => SetValue(StatusProperty, value); 54 | } 55 | 56 | public static DependencyProperty StatusProperty { get; } = DependencyProperty.Register( 57 | nameof(Status), 58 | typeof(BoardSquareStatus), 59 | typeof(BoardSquare), 60 | new PropertyMetadata( 61 | BoardSquareStatus.Unselected, 62 | propertyChangedCallback: (sender, args) => ((BoardSquare)sender).OnStatusChanged((BoardSquareStatus)args.NewValue))); 63 | 64 | private void OnStatusChanged(BoardSquareStatus status) 65 | { 66 | switch (status) 67 | { 68 | case BoardSquareStatus.Unselected: 69 | var i = (int)_file; 70 | var j = (int)_rank; 71 | var backgroundColor = ((i + j) % 2 == 0) ? Color.FromArgb(255, 181, 136, 99) : Color.FromArgb(255, 240, 217, 181); 72 | Background = new SolidColorBrush(backgroundColor); 73 | break; 74 | 75 | case BoardSquareStatus.Selected: 76 | Background = new SolidColorBrush(Colors.Cyan); 77 | break; 78 | 79 | case BoardSquareStatus.ValidMove: 80 | Background = new SolidColorBrush(Colors.DarkCyan); 81 | break; 82 | 83 | case BoardSquareStatus.InCheck: 84 | Background = new SolidColorBrush(Colors.Red); 85 | break; 86 | 87 | default: 88 | throw new ArgumentOutOfRangeException(nameof(status)); 89 | } 90 | } 91 | 92 | private void OnPieceChanged(DependencyPropertyChangedEventArgs args) 93 | { 94 | var piece = (Piece)args.NewValue; 95 | if (piece is not null) 96 | { 97 | var color = piece.Owner.ToString(); 98 | var pieceName = piece.GetType().Name; 99 | _image.Source = new BitmapImage(new Uri($"ms-appx:///Assets/Images/{color}{pieceName}.png")); 100 | } 101 | else 102 | { 103 | _image.Source = null; 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Reboot v4.3.1 (https://getbootstrap.com/) 3 | * Copyright 2011-2019 The Bootstrap Authors 4 | * Copyright 2011-2019 Twitter, Inc. 5 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 6 | * Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md) 7 | */*,::after,::before{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}article,aside,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;text-align:left;background-color:#fff}[tabindex="-1"]:focus{outline:0!important}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem}p{margin-top:0;margin-bottom:1rem}abbr[data-original-title],abbr[title]{text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;border-bottom:0;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#007bff;text-decoration:none;background-color:transparent}a:hover{color:#0056b3;text-decoration:underline}a:not([href]):not([tabindex]){color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus,a:not([href]):not([tabindex]):hover{color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus{outline:0}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em}pre{margin-top:0;margin-bottom:1rem;overflow:auto}figure{margin:0 0 1rem}img{vertical-align:middle;border-style:none}svg{overflow:hidden;vertical-align:middle}table{border-collapse:collapse}caption{padding-top:.75rem;padding-bottom:.75rem;color:#6c757d;text-align:left;caption-side:bottom}th{text-align:inherit}label{display:inline-block;margin-bottom:.5rem}button{border-radius:0}button:focus{outline:1px dotted;outline:5px auto -webkit-focus-ring-color}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}select{word-wrap:normal}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{padding:0;border-style:none}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=date],input[type=datetime-local],input[type=month],input[type=time]{-webkit-appearance:listbox}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{display:block;width:100%;max-width:100%;padding:0;margin-bottom:.5rem;font-size:1.5rem;line-height:inherit;color:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item;cursor:pointer}template{display:none}[hidden]{display:none!important} 8 | /*# sourceMappingURL=bootstrap-reboot.min.css.map */ -------------------------------------------------------------------------------- /src/ChessSharp/LibraryDiagram.cd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | AAAhAAAAAAAAAAQEgAABAAAAAAAEAIAAAAAAAAAAAAA= 7 | SquareData\Square.cs 8 | 9 | 10 | 11 | 12 | 13 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgA= 14 | Pieces\Bishop.cs 15 | 16 | 17 | 18 | 19 | 20 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgA= 21 | Pieces\King.cs 22 | 23 | 24 | 25 | 26 | 27 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgA= 28 | Pieces\Knight.cs 29 | 30 | 31 | 32 | 33 | 34 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAgA= 35 | Pieces\Pawn.cs 36 | 37 | 38 | 39 | 40 | 41 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgA= 42 | Pieces\Queen.cs 43 | 44 | 45 | 46 | 47 | 48 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgA= 49 | Pieces\Rook.cs 50 | 51 | 52 | 53 | 54 | 55 | AQAAAAAAAAIAAAAAAAAAAAIAAACAAAIAAAAAAAQBAAg= 56 | ChessUtilities.cs 57 | 58 | 59 | 60 | 61 | 62 | AAAACAAAQAIACAAACAAAAAAAAACIAkJAAACAACAAIAA= 63 | ChessGame.cs 64 | 65 | 66 | 67 | 68 | 69 | AAAAAAAAAgAAAAAAgAACBAAAAAAAAIAEAAAAAwAAAAA= 70 | Move.cs 71 | 72 | 73 | 74 | 75 | 76 | AAAAAACAAAAAAAAAgAAAAAAAAAAAAIAAAAAAAAAAAgA= 77 | Piece.cs 78 | 79 | 80 | 81 | 82 | 83 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAvkEAAAA= 84 | SquareData\File.cs 85 | 86 | 87 | 88 | 89 | 90 | AAQAgAAAAAAAAQAAAAAAAAIAIAABAAAAAAAAAAAAAYA= 91 | SquareData\Rank.cs 92 | 93 | 94 | 95 | 96 | 97 | AAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAA= 98 | Player.cs 99 | 100 | 101 | 102 | 103 | 104 | AAgAAAABAAAAAgAAAAAAAgAAAEAgAAQAAAAAAAAAAAA= 105 | GameState.cs 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/Hubs/ChessHub.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Security.Claims; 5 | using System.Text.RegularExpressions; 6 | using System.Threading.Tasks; 7 | 8 | using ChessSharp; 9 | using ChessSharp.Pieces; 10 | using ChessSharp.SquareData; 11 | using ChessSharpWeb.Data; 12 | using ChessSharpWeb.Models; 13 | using Microsoft.AspNetCore.Authorization; 14 | using Microsoft.AspNetCore.Http; 15 | using Microsoft.AspNetCore.SignalR; 16 | using Microsoft.EntityFrameworkCore; 17 | using Newtonsoft.Json; 18 | 19 | namespace ChessWebsite; 20 | 21 | public class ChessHub : Hub 22 | { 23 | private readonly ApplicationDbContext _context; 24 | private readonly string _loggedUserId; 25 | 26 | public ChessHub(ApplicationDbContext context, IHttpContextAccessor httpContextAccessor) 27 | { 28 | _context = context; 29 | _loggedUserId = httpContextAccessor.HttpContext!.User.FindFirst(ClaimTypes.NameIdentifier)!.Value; 30 | } 31 | 32 | private Game GetGameFromId(int gameId) 33 | { 34 | return _context.Games.Include(g => g.WhitePlayer).Include(g => g.BlackPlayer).First(g => g.Id == gameId); // TODO: Can it be null ? 35 | } 36 | 37 | private static GameBoard GetGameBoardFromJson(string json) 38 | { 39 | var settings = new JsonSerializerSettings 40 | { 41 | TypeNameHandling = TypeNameHandling.All 42 | }; 43 | return JsonConvert.DeserializeObject(json, settings); 44 | } 45 | 46 | [Authorize] 47 | public override async Task OnConnectedAsync() 48 | { 49 | 50 | int gameId = Convert.ToInt32(Context.GetHttpContext()!.Request.Query["gameId"]); 51 | Game game = GetGameFromId(gameId); 52 | if (_loggedUserId == game.WhitePlayer.Id) 53 | { 54 | await Groups.AddToGroupAsync(Context.ConnectionId, gameId.ToString()); 55 | } 56 | else if (game.BlackPlayer != null && game.BlackPlayer.Id == _loggedUserId) 57 | { 58 | await Clients.Group(gameId.ToString()).SendAsync("BlackJoined", game.BlackPlayer.UserName); 59 | } 60 | await base.OnConnectedAsync(); 61 | } 62 | 63 | public List GetValidMovesOfSquare(string square) 64 | { 65 | int gameId = Convert.ToInt32(Context.GetHttpContext()!.Request.Query["gameId"]); 66 | var game = GetGameFromId(gameId); 67 | var gameBoard = GetGameBoardFromJson(game.GameBoardJson); 68 | return ChessUtilities.GetValidMovesOfSourceSquare(Square.Parse(square), gameBoard); 69 | } 70 | 71 | public async Task MakeMove(int gameId, string source, string destination, int? promoteTo = null) 72 | { 73 | var settings = new JsonSerializerSettings 74 | { 75 | TypeNameHandling = TypeNameHandling.All 76 | }; 77 | var game = _context.Games.Include(m => m.WhitePlayer) 78 | .Include(m => m.WhitePlayer) 79 | .FirstOrDefault(g => g.Id == gameId); 80 | if (game == null) 81 | { 82 | // No game exists. 83 | // Not sure what to do here, temporarily, I'll return. 84 | return; 85 | } 86 | 87 | 88 | 89 | if (!Regex.IsMatch(source, "[A-H][1-8]", RegexOptions.IgnoreCase) || 90 | !Regex.IsMatch(destination, "[A-H][1-8]", RegexOptions.IgnoreCase)) 91 | { 92 | // Invalid squares. 93 | return; 94 | } 95 | 96 | 97 | /* 98 | * promoteTo: 0 ==> Knight, 99 | * promoteTo: 1 ==> Bishop, 100 | * promoteTo: 2 ==> Rook, 101 | * promoteTo: 3 ==> Queen 102 | */ 103 | if (promoteTo != null && (promoteTo < 0 || promoteTo > 3)) 104 | { 105 | // Invalid promoteTo value 106 | return; 107 | } 108 | 109 | 110 | var gameBoard = JsonConvert.DeserializeObject(game.GameBoardJson, settings); 111 | var move = new Move(Square.Parse(source), Square.Parse(destination), gameBoard.WhoseTurn(), 112 | (PawnPromotion?)promoteTo); 113 | 114 | if (gameBoard.IsValidMove(move)) 115 | { 116 | gameBoard.MakeMove(move, true); 117 | game.GameBoardJson = JsonConvert.SerializeObject(gameBoard, settings); 118 | await _context.SaveChangesAsync(); 119 | await Clients.Users(new List() { game.WhitePlayer.Id, game.BlackPlayer!.Id }).SendAsync("ShowGame", gameBoard.Board); 120 | } 121 | } 122 | 123 | } 124 | -------------------------------------------------------------------------------- /src/ChessSharp/ChessUtilities.cs: -------------------------------------------------------------------------------- 1 | using ChessSharp.Pieces; 2 | using ChessSharp.SquareData; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace ChessSharp; 8 | 9 | /// A static class containing helper methods. 10 | public static class ChessUtilities 11 | { 12 | private static readonly IEnumerable s_allSquares = 13 | from file in Enum.GetValues(typeof(File)).Cast() 14 | from rank in Enum.GetValues(typeof(Rank)).Cast() 15 | select new Square(file, rank); 16 | 17 | internal static Player RevertPlayer(Player player) => player == Player.White ? Player.Black : Player.White; 18 | 19 | /* TODO: Still not sure where to implement it, but I may need methods: 20 | TODO: bool CanClaimDraw + bool ClaimDraw + OfferDraw 21 | */ 22 | 23 | /// Gets the valid moves of the given . 24 | /// The that you want to get its valid moves. 25 | /// Returns a list of the valid moves. 26 | public static List GetValidMoves(ChessGame board) 27 | { 28 | // Although nullable is enabled and board is non-nullable ref type, this check is needed 29 | // because this is a public method that can be used by an application that doesn't have 30 | // nullable enabled. 31 | _ = board ?? throw new ArgumentNullException(nameof(board)); 32 | 33 | 34 | Player player = board.WhoseTurn; 35 | var validMoves = new List(); 36 | 37 | IEnumerable playerOwnedSquares = s_allSquares.Where(sq => board[sq.File, sq.Rank]?.Owner == player); 38 | Square[] nonPlayerOwnedSquares = s_allSquares.Where(sq => board[sq.File, sq.Rank]?.Owner != player).ToArray(); // Converting to array to avoid "Possible multiple enumeration" as suggested by ReSharper. 39 | 40 | foreach (Square playerOwnedSquare in playerOwnedSquares) 41 | { 42 | validMoves.AddRange(nonPlayerOwnedSquares 43 | .Select(nonPlayerOwnedSquare => new Move(playerOwnedSquare, nonPlayerOwnedSquare, player)) 44 | .Where(move => ChessGame.IsValidMove(move, board))); 45 | } 46 | 47 | return validMoves; 48 | } 49 | 50 | /// Gets the valid moves of the given that has a specific given source . 51 | /// The source that you're looking for its valid moves. 52 | /// The that you want to get its valid moves from the specified square. 53 | /// Returns a list of the valid moves that has the given source square. 54 | /// 55 | public static List GetValidMovesOfSourceSquare(Square source, ChessGame board) 56 | { 57 | if (board == null) 58 | { 59 | throw new ArgumentNullException(nameof(board)); 60 | } 61 | 62 | var validMoves = new List(); 63 | Piece? piece = board[source.File, source.Rank]; 64 | if (piece == null || piece.Owner != board.WhoseTurn) 65 | { 66 | return validMoves; 67 | } 68 | 69 | Player player = piece.Owner; 70 | Square[] nonPlayerOwnedSquares = s_allSquares.Where(sq => board[sq.File, sq.Rank]?.Owner != player).ToArray(); 71 | 72 | validMoves.AddRange(nonPlayerOwnedSquares 73 | .Select(nonPlayerOwnedSquare => new Move(source, nonPlayerOwnedSquare, player, PawnPromotion.Queen)) // If promoteTo is null, valid pawn promotion will cause exception. Need to implement this better and cleaner in the future. 74 | .Where(move => ChessGame.IsValidMove(move, board))); 75 | return validMoves; 76 | } 77 | 78 | internal static bool IsPlayerInCheck(Player player, ChessGame board) 79 | { 80 | Player opponent = RevertPlayer(player); 81 | IEnumerable opponentOwnedSquares = s_allSquares.Where(sq => board[sq.File, sq.Rank]?.Owner == opponent); 82 | Square playerKingSquare = s_allSquares.First(sq => new King(player).Equals(board[sq.File, sq.Rank])); 83 | 84 | return (from opponentOwnedSquare in opponentOwnedSquares 85 | let piece = board[opponentOwnedSquare.File, opponentOwnedSquare.Rank] 86 | let move = new Move(opponentOwnedSquare, playerKingSquare, opponent, PawnPromotion.Queen) // Added PawnPromotion in the Move because omitting it causes a bug when King in its rank is in a check by a pawn. 87 | where piece.IsValidGameMove(move, board) 88 | select piece).Any(); 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Welcome to ChessSharp documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 |
26 | 27 | 58 | 59 | 66 |
67 | 93 | 94 |
95 |
96 | 105 |
106 |
107 | 108 | 109 | 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | [Xx]64/ 19 | [Xx]86/ 20 | [Bb]uild/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | 85 | # Visual Studio profiler 86 | *.psess 87 | *.vsp 88 | *.vspx 89 | *.sap 90 | 91 | # TFS 2012 Local Workspace 92 | $tf/ 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | *.DotSettings.user 101 | 102 | # JustCode is a .NET coding add-in 103 | .JustCode 104 | 105 | # TeamCity is a build add-in 106 | _TeamCity* 107 | 108 | # DotCover is a Code Coverage Tool 109 | *.dotCover 110 | 111 | # NCrunch 112 | _NCrunch_* 113 | .*crunch*.local.xml 114 | nCrunchTemp_* 115 | 116 | # MightyMoose 117 | *.mm.* 118 | AutoTest.Net/ 119 | 120 | # Web workbench (sass) 121 | .sass-cache/ 122 | 123 | # Installshield output folder 124 | [Ee]xpress/ 125 | 126 | # DocProject is a documentation generator add-in 127 | DocProject/buildhelp/ 128 | DocProject/Help/*.HxT 129 | DocProject/Help/*.HxC 130 | DocProject/Help/*.hhc 131 | DocProject/Help/*.hhk 132 | DocProject/Help/*.hhp 133 | DocProject/Help/Html2 134 | DocProject/Help/html 135 | 136 | # Click-Once directory 137 | publish/ 138 | 139 | # Publish Web Output 140 | *.[Pp]ublish.xml 141 | *.azurePubxml 142 | 143 | # TODO: Un-comment the next line if you do not want to checkin 144 | # your web deploy settings because they may include unencrypted 145 | # passwords 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # NuGet Packages 150 | *.nupkg 151 | # The packages folder can be ignored because of Package Restore 152 | **/packages/* 153 | # except build/, which is used as an MSBuild target. 154 | !**/packages/build/ 155 | # Uncomment if necessary however generally it will be regenerated when needed 156 | #!**/packages/repositories.config 157 | # NuGet v3's project.json files produces more ignoreable files 158 | *.nuget.props 159 | *.nuget.targets 160 | 161 | # Microsoft Azure Build Output 162 | csx/ 163 | *.build.csdef 164 | 165 | # Microsoft Azure Emulator 166 | ecf/ 167 | rcf/ 168 | 169 | # Windows Store app package directory 170 | AppPackages/ 171 | BundleArtifacts/ 172 | 173 | # Visual Studio cache files 174 | # files ending in .cache can be ignored 175 | *.[Cc]ache 176 | # but keep track of directories ending in .cache 177 | !*.[Cc]ache/ 178 | 179 | # Others 180 | ClientBin/ 181 | [Ss]tyle[Cc]op.* 182 | ~$* 183 | *~ 184 | *.dbmdl 185 | *.dbproj.schemaview 186 | *.pfx 187 | *.publishsettings 188 | node_modules/ 189 | orleans.codegen.cs 190 | 191 | # RIA/Silverlight projects 192 | Generated_Code/ 193 | 194 | # Backup & report files from converting an old project file 195 | # to a newer Visual Studio version. Backup files are not needed, 196 | # because we have git ;-) 197 | _UpgradeReport_Files/ 198 | Backup*/ 199 | UpgradeLog*.XML 200 | UpgradeLog*.htm 201 | 202 | # SQL Server files 203 | *.mdf 204 | *.ldf 205 | 206 | # Business Intelligence projects 207 | *.rdl.data 208 | *.bim.layout 209 | *.bim_*.settings 210 | 211 | # Microsoft Fakes 212 | FakesAssemblies/ 213 | 214 | # GhostDoc plugin setting file 215 | *.GhostDoc.xml 216 | 217 | # Node.js Tools for Visual Studio 218 | .ntvs_analysis.dat 219 | 220 | # Visual Studio 6 build log 221 | *.plg 222 | 223 | # Visual Studio 6 workspace options file 224 | *.opt 225 | 226 | # Visual Studio LightSwitch build output 227 | **/*.HTMLClient/GeneratedArtifacts 228 | **/*.DesktopClient/GeneratedArtifacts 229 | **/*.DesktopClient/ModelManifest.xml 230 | **/*.Server/GeneratedArtifacts 231 | **/*.Server/ModelManifest.xml 232 | _Pvt_Extensions 233 | 234 | # LightSwitch generated files 235 | GeneratedArtifacts/ 236 | ModelManifest.xml 237 | 238 | # Paket dependency manager 239 | .paket/paket.exe 240 | 241 | # FAKE - F# Make 242 | .fake/ 243 | -------------------------------------------------------------------------------- /src/ChessSharp/Pieces/Pawn.cs: -------------------------------------------------------------------------------- 1 | using ChessSharp.SquareData; 2 | using System; 3 | using System.Linq; 4 | 5 | namespace ChessSharp.Pieces; 6 | 7 | /// Represents a pawn . 8 | public class Pawn : Piece 9 | { 10 | internal Pawn(Player player) : base(player) { } 11 | 12 | 13 | internal static PawnMoveType GetPawnMoveType(Move move) 14 | { 15 | // No need to do null check here, this method isn't public and isn't annotated with nullable. 16 | // If the caller try to pass a possible null reference, the compiler should issue a warning. 17 | // TODO: Should I add [NotNull] attribute to the argument? What's the benefit? 18 | // The argument is already non-nullable. 19 | 20 | int deltaY = move.GetDeltaY(); 21 | int absDeltaX = move.GetAbsDeltaX(); 22 | 23 | // Check normal one step pawn move. 24 | if ((move.Player == Player.White && deltaY == 1 && absDeltaX == 0) || 25 | move.Player == Player.Black && deltaY == -1 && absDeltaX == 0) 26 | { 27 | if ((move.Player == Player.White && move.Destination.Rank == Rank.Eighth) || 28 | (move.Player == Player.Black && move.Destination.Rank == Rank.First)) 29 | { 30 | return PawnMoveType.OneStep | PawnMoveType.Promotion; 31 | } 32 | return PawnMoveType.OneStep; 33 | } 34 | 35 | // Check two step move from starting position. 36 | if ((move.Player == Player.White && deltaY == 2 && absDeltaX == 0 && move.Source.Rank == Rank.Second) || 37 | (move.Player == Player.Black && deltaY == -2 && absDeltaX == 0 && move.Source.Rank == Rank.Seventh)) 38 | { 39 | return PawnMoveType.TwoSteps; 40 | } 41 | 42 | // Check capture (Enpassant is special case from capture). 43 | if ((move.Player == Player.White && deltaY == 1 && absDeltaX == 1) || 44 | (move.Player == Player.Black && deltaY == -1 && absDeltaX == 1)) 45 | { 46 | if ((move.Player == Player.White && move.Destination.Rank == Rank.Eighth) || 47 | (move.Player == Player.Black && move.Destination.Rank == Rank.First)) 48 | { 49 | return PawnMoveType.Capture | PawnMoveType.Promotion; 50 | } 51 | return PawnMoveType.Capture; 52 | } 53 | 54 | return PawnMoveType.Invalid; 55 | } 56 | 57 | internal override bool IsValidGameMove(Move move, ChessGame board) 58 | { 59 | // No need to do null checks here, this method isn't public and isn't annotated with nullable. 60 | // If the caller try to pass a possible null reference, the compiler should issue a warning. 61 | // TODO: Should I add [NotNull] attribute to the arguments? What's the benefit? 62 | // The arguments are already non-nullable. 63 | 64 | var moveType = GetPawnMoveType(move); 65 | 66 | if (moveType == PawnMoveType.Invalid) 67 | { 68 | return false; 69 | } 70 | 71 | if (moveType.Contains(PawnMoveType.Promotion) && move.PromoteTo == null) 72 | { 73 | return false; 74 | } 75 | 76 | if (moveType.Contains(PawnMoveType.TwoSteps)) 77 | { 78 | return !board.IsTherePieceInBetween(move.Source, move.Destination) && board[move.Destination.File, move.Destination.Rank] == null; 79 | } 80 | 81 | if (moveType.Contains(PawnMoveType.OneStep)) 82 | { 83 | return board[move.Destination.File, move.Destination.Rank] == null; 84 | } 85 | 86 | if (moveType.Contains(PawnMoveType.Capture)) 87 | { 88 | // Capture isn't possible as first move. 89 | // This prevents exception when getting board.Moves.Last() later. 90 | if (board.Moves.Count == 0) 91 | { 92 | return false; 93 | } 94 | // Check regular capture. 95 | if (board[move.Destination.File, move.Destination.Rank] != null) 96 | { 97 | return true; 98 | } 99 | 100 | // Check enpassant. 101 | Move lastMove = board.Moves.Last(); 102 | Piece? lastMovedPiece = board[lastMove.Destination.File, lastMove.Destination.Rank]; 103 | 104 | if (lastMovedPiece is Pawn || 105 | !GetPawnMoveType(lastMove).Contains(PawnMoveType.TwoSteps) || lastMove.Destination.File != move.Destination.File || 106 | lastMove.Destination.Rank != move.Source.Rank) 107 | { 108 | return false; 109 | } 110 | // Two Step pawn move ( white from rank 2 to 4 ) ( black from rank 7 to 5 ) 111 | // SHOULDN'T REMOVE CAPTURED PAWN FROM THE BOARD HERE!! THIS IS ONLY FOR CHECKING IF MOVE IS LEGAL OR NOT!! 112 | // PAWN REMOVAL SHOULD BE DONE IN MAKEMOVE METHOD!!! 113 | ChessGame clone = board.DeepClone(); 114 | clone.Board[(int) move.Destination.Rank][(int) move.Destination.File] = null; 115 | clone.Board[((int) move.Destination.Rank + (int) move.Source.Rank) / 2][(int) move.Destination.File] = lastMovedPiece; 116 | return !clone.PlayerWillBeInCheck(move); 117 | } 118 | 119 | throw new Exception("Unexpected PawnMoveType."); // Should never happen. If it happened, this it's a bug. 120 | 121 | 122 | } 123 | } -------------------------------------------------------------------------------- /Documentation/api/ChessSharp.Pieces.PawnPromotion.yml: -------------------------------------------------------------------------------- 1 | ### YamlMime:ManagedReference 2 | items: 3 | - uid: ChessSharp.Pieces.PawnPromotion 4 | commentId: T:ChessSharp.Pieces.PawnPromotion 5 | id: PawnPromotion 6 | parent: ChessSharp.Pieces 7 | children: 8 | - ChessSharp.Pieces.PawnPromotion.Bishop 9 | - ChessSharp.Pieces.PawnPromotion.Knight 10 | - ChessSharp.Pieces.PawnPromotion.Queen 11 | - ChessSharp.Pieces.PawnPromotion.Rook 12 | langs: 13 | - csharp 14 | - vb 15 | name: PawnPromotion 16 | nameWithType: PawnPromotion 17 | fullName: ChessSharp.Pieces.PawnPromotion 18 | type: Enum 19 | source: 20 | remote: 21 | path: src/ChessSharp/Pieces/PawnPromotion.cs 22 | branch: master 23 | repo: https://github.com/Youssef1313/ChessSharp.git 24 | id: PawnPromotion 25 | path: ../src/ChessSharp/Pieces/PawnPromotion.cs 26 | startLine: 3 27 | assemblies: 28 | - ChessSharp 29 | namespace: ChessSharp.Pieces 30 | summary: Represents the promotion of the pawn. 31 | example: [] 32 | syntax: 33 | content: public enum PawnPromotion 34 | content.vb: Public Enum PawnPromotion 35 | modifiers.csharp: 36 | - public 37 | - enum 38 | modifiers.vb: 39 | - Public 40 | - Enum 41 | - uid: ChessSharp.Pieces.PawnPromotion.Knight 42 | commentId: F:ChessSharp.Pieces.PawnPromotion.Knight 43 | id: Knight 44 | parent: ChessSharp.Pieces.PawnPromotion 45 | langs: 46 | - csharp 47 | - vb 48 | name: Knight 49 | nameWithType: PawnPromotion.Knight 50 | fullName: ChessSharp.Pieces.PawnPromotion.Knight 51 | type: Field 52 | source: 53 | remote: 54 | path: src/ChessSharp/Pieces/PawnPromotion.cs 55 | branch: master 56 | repo: https://github.com/Youssef1313/ChessSharp.git 57 | id: Knight 58 | path: ../src/ChessSharp/Pieces/PawnPromotion.cs 59 | startLine: 6 60 | assemblies: 61 | - ChessSharp 62 | namespace: ChessSharp.Pieces 63 | summary: Promote the pawn to a knight. 64 | example: [] 65 | syntax: 66 | content: Knight = 0 67 | return: 68 | type: ChessSharp.Pieces.PawnPromotion 69 | modifiers.csharp: 70 | - public 71 | - const 72 | modifiers.vb: 73 | - Public 74 | - Const 75 | - uid: ChessSharp.Pieces.PawnPromotion.Bishop 76 | commentId: F:ChessSharp.Pieces.PawnPromotion.Bishop 77 | id: Bishop 78 | parent: ChessSharp.Pieces.PawnPromotion 79 | langs: 80 | - csharp 81 | - vb 82 | name: Bishop 83 | nameWithType: PawnPromotion.Bishop 84 | fullName: ChessSharp.Pieces.PawnPromotion.Bishop 85 | type: Field 86 | source: 87 | remote: 88 | path: src/ChessSharp/Pieces/PawnPromotion.cs 89 | branch: master 90 | repo: https://github.com/Youssef1313/ChessSharp.git 91 | id: Bishop 92 | path: ../src/ChessSharp/Pieces/PawnPromotion.cs 93 | startLine: 8 94 | assemblies: 95 | - ChessSharp 96 | namespace: ChessSharp.Pieces 97 | summary: Promote the pawn to a bishop. 98 | example: [] 99 | syntax: 100 | content: Bishop = 1 101 | return: 102 | type: ChessSharp.Pieces.PawnPromotion 103 | modifiers.csharp: 104 | - public 105 | - const 106 | modifiers.vb: 107 | - Public 108 | - Const 109 | - uid: ChessSharp.Pieces.PawnPromotion.Rook 110 | commentId: F:ChessSharp.Pieces.PawnPromotion.Rook 111 | id: Rook 112 | parent: ChessSharp.Pieces.PawnPromotion 113 | langs: 114 | - csharp 115 | - vb 116 | name: Rook 117 | nameWithType: PawnPromotion.Rook 118 | fullName: ChessSharp.Pieces.PawnPromotion.Rook 119 | type: Field 120 | source: 121 | remote: 122 | path: src/ChessSharp/Pieces/PawnPromotion.cs 123 | branch: master 124 | repo: https://github.com/Youssef1313/ChessSharp.git 125 | id: Rook 126 | path: ../src/ChessSharp/Pieces/PawnPromotion.cs 127 | startLine: 10 128 | assemblies: 129 | - ChessSharp 130 | namespace: ChessSharp.Pieces 131 | summary: Promote the pawn to a rook. 132 | example: [] 133 | syntax: 134 | content: Rook = 2 135 | return: 136 | type: ChessSharp.Pieces.PawnPromotion 137 | modifiers.csharp: 138 | - public 139 | - const 140 | modifiers.vb: 141 | - Public 142 | - Const 143 | - uid: ChessSharp.Pieces.PawnPromotion.Queen 144 | commentId: F:ChessSharp.Pieces.PawnPromotion.Queen 145 | id: Queen 146 | parent: ChessSharp.Pieces.PawnPromotion 147 | langs: 148 | - csharp 149 | - vb 150 | name: Queen 151 | nameWithType: PawnPromotion.Queen 152 | fullName: ChessSharp.Pieces.PawnPromotion.Queen 153 | type: Field 154 | source: 155 | remote: 156 | path: src/ChessSharp/Pieces/PawnPromotion.cs 157 | branch: master 158 | repo: https://github.com/Youssef1313/ChessSharp.git 159 | id: Queen 160 | path: ../src/ChessSharp/Pieces/PawnPromotion.cs 161 | startLine: 12 162 | assemblies: 163 | - ChessSharp 164 | namespace: ChessSharp.Pieces 165 | summary: Promote the pawn to a queen. 166 | example: [] 167 | syntax: 168 | content: Queen = 3 169 | return: 170 | type: ChessSharp.Pieces.PawnPromotion 171 | modifiers.csharp: 172 | - public 173 | - const 174 | modifiers.vb: 175 | - Public 176 | - Const 177 | references: 178 | - uid: ChessSharp.Pieces 179 | commentId: N:ChessSharp.Pieces 180 | name: ChessSharp.Pieces 181 | nameWithType: ChessSharp.Pieces 182 | fullName: ChessSharp.Pieces 183 | - uid: ChessSharp.Pieces.PawnPromotion 184 | commentId: T:ChessSharp.Pieces.PawnPromotion 185 | parent: ChessSharp.Pieces 186 | name: PawnPromotion 187 | nameWithType: PawnPromotion 188 | fullName: ChessSharp.Pieces.PawnPromotion 189 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.UI.Xaml; 3 | using Microsoft.UI.Xaml.Controls; 4 | using Microsoft.UI.Xaml.Navigation; 5 | using Uno.Resizetizer; 6 | using Uno.UI; 7 | 8 | namespace ChessSharpUno; 9 | public partial class App : Application 10 | { 11 | /// 12 | /// Initializes the singleton application object. This is the first line of authored code 13 | /// executed, and as such is the logical equivalent of main() or WinMain(). 14 | /// 15 | public App() 16 | { 17 | this.InitializeComponent(); 18 | } 19 | 20 | protected Window? MainWindow { get; private set; } 21 | 22 | protected override void OnLaunched(LaunchActivatedEventArgs args) 23 | { 24 | MainWindow = new Window(); 25 | #if DEBUG 26 | MainWindow.EnableHotReload(); 27 | #endif 28 | 29 | 30 | // Do not repeat app initialization when the Window already has content, 31 | // just ensure that the window is active 32 | if (MainWindow.Content is not Frame rootFrame) 33 | { 34 | // Create a Frame to act as the navigation context and navigate to the first page 35 | rootFrame = new Frame(); 36 | 37 | // Place the frame in the current Window 38 | MainWindow.Content = rootFrame; 39 | 40 | rootFrame.NavigationFailed += OnNavigationFailed; 41 | } 42 | 43 | if (rootFrame.Content == null) 44 | { 45 | // When the navigation stack isn't restored navigate to the first page, 46 | // configuring the new page by passing required information as a navigation 47 | // parameter 48 | rootFrame.Navigate(typeof(MainPage), args.Arguments); 49 | } 50 | 51 | MainWindow.SetWindowIcon(); 52 | // Ensure the current window is active 53 | MainWindow.Activate(); 54 | } 55 | 56 | /// 57 | /// Invoked when Navigation to a certain page fails 58 | /// 59 | /// The Frame which failed navigation 60 | /// Details about the navigation failure 61 | void OnNavigationFailed(object sender, NavigationFailedEventArgs e) 62 | { 63 | throw new InvalidOperationException($"Failed to load {e.SourcePageType.FullName}: {e.Exception}"); 64 | } 65 | 66 | /// 67 | /// Configures global Uno Platform logging 68 | /// 69 | public static void InitializeLogging() 70 | { 71 | #if DEBUG 72 | // Logging is disabled by default for release builds, as it incurs a significant 73 | // initialization cost from Microsoft.Extensions.Logging setup. If startup performance 74 | // is a concern for your application, keep this disabled. If you're running on the web or 75 | // desktop targets, you can use URL or command line parameters to enable it. 76 | // 77 | // For more performance documentation: https://platform.uno/docs/articles/Uno-UI-Performance.html 78 | 79 | var factory = LoggerFactory.Create(builder => 80 | { 81 | #if __WASM__ 82 | builder.AddProvider(new global::Uno.Extensions.Logging.WebAssembly.WebAssemblyConsoleLoggerProvider()); 83 | #elif __IOS__ || __MACCATALYST__ 84 | builder.AddProvider(new global::Uno.Extensions.Logging.OSLogLoggerProvider()); 85 | #else 86 | builder.AddConsole(); 87 | #endif 88 | 89 | // Exclude logs below this level 90 | builder.SetMinimumLevel(LogLevel.Information); 91 | 92 | // Default filters for Uno Platform namespaces 93 | builder.AddFilter("Uno", LogLevel.Warning); 94 | builder.AddFilter("Windows", LogLevel.Warning); 95 | builder.AddFilter("Microsoft", LogLevel.Warning); 96 | 97 | // Generic Xaml events 98 | // builder.AddFilter("Microsoft.UI.Xaml", LogLevel.Debug ); 99 | // builder.AddFilter("Microsoft.UI.Xaml.VisualStateGroup", LogLevel.Debug ); 100 | // builder.AddFilter("Microsoft.UI.Xaml.StateTriggerBase", LogLevel.Debug ); 101 | // builder.AddFilter("Microsoft.UI.Xaml.UIElement", LogLevel.Debug ); 102 | // builder.AddFilter("Microsoft.UI.Xaml.FrameworkElement", LogLevel.Trace ); 103 | 104 | // Layouter specific messages 105 | // builder.AddFilter("Microsoft.UI.Xaml.Controls", LogLevel.Debug ); 106 | // builder.AddFilter("Microsoft.UI.Xaml.Controls.Layouter", LogLevel.Debug ); 107 | // builder.AddFilter("Microsoft.UI.Xaml.Controls.Panel", LogLevel.Debug ); 108 | 109 | // builder.AddFilter("Windows.Storage", LogLevel.Debug ); 110 | 111 | // Binding related messages 112 | // builder.AddFilter("Microsoft.UI.Xaml.Data", LogLevel.Debug ); 113 | // builder.AddFilter("Microsoft.UI.Xaml.Data", LogLevel.Debug ); 114 | 115 | // Binder memory references tracking 116 | // builder.AddFilter("Uno.UI.DataBinding.BinderReferenceHolder", LogLevel.Debug ); 117 | 118 | // DevServer and HotReload related 119 | // builder.AddFilter("Uno.UI.RemoteControl", LogLevel.Information); 120 | 121 | // Debug JS interop 122 | // builder.AddFilter("Uno.Foundation.WebAssemblyRuntime", LogLevel.Debug ); 123 | }); 124 | 125 | global::Uno.Extensions.LogExtensionPoint.AmbientLoggerFactory = factory; 126 | 127 | #if HAS_UNO 128 | global::Uno.UI.Adapter.Microsoft.Extensions.Logging.LoggingAdapter.Initialize(); 129 | #endif 130 | #endif 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /src/ChessSharpWeb/wwwroot/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js: -------------------------------------------------------------------------------- 1 | // Unobtrusive validation support library for jQuery and jQuery Validate 2 | // Copyright (c) .NET Foundation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 4 | // @version v3.2.11 5 | !function(a){"function"==typeof define&&define.amd?define("jquery.validate.unobtrusive",["jquery-validation"],a):"object"==typeof module&&module.exports?module.exports=a(require("jquery-validation")):jQuery.validator.unobtrusive=a(jQuery)}(function(a){function e(a,e,n){a.rules[e]=n,a.message&&(a.messages[e]=a.message)}function n(a){return a.replace(/^\s+|\s+$/g,"").split(/\s*,\s*/g)}function t(a){return a.replace(/([!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~])/g,"\\$1")}function r(a){return a.substr(0,a.lastIndexOf(".")+1)}function i(a,e){return 0===a.indexOf("*.")&&(a=a.replace("*.",e)),a}function o(e,n){var r=a(this).find("[data-valmsg-for='"+t(n[0].name)+"']"),i=r.attr("data-valmsg-replace"),o=i?a.parseJSON(i)!==!1:null;r.removeClass("field-validation-valid").addClass("field-validation-error"),e.data("unobtrusiveContainer",r),o?(r.empty(),e.removeClass("input-validation-error").appendTo(r)):e.hide()}function d(e,n){var t=a(this).find("[data-valmsg-summary=true]"),r=t.find("ul");r&&r.length&&n.errorList.length&&(r.empty(),t.addClass("validation-summary-errors").removeClass("validation-summary-valid"),a.each(n.errorList,function(){a("
  • ").html(this.message).appendTo(r)}))}function s(e){var n=e.data("unobtrusiveContainer");if(n){var t=n.attr("data-valmsg-replace"),r=t?a.parseJSON(t):null;n.addClass("field-validation-valid").removeClass("field-validation-error"),e.removeData("unobtrusiveContainer"),r&&n.empty()}}function l(e){var n=a(this),t="__jquery_unobtrusive_validation_form_reset";if(!n.data(t)){n.data(t,!0);try{n.data("validator").resetForm()}finally{n.removeData(t)}n.find(".validation-summary-errors").addClass("validation-summary-valid").removeClass("validation-summary-errors"),n.find(".field-validation-error").addClass("field-validation-valid").removeClass("field-validation-error").removeData("unobtrusiveContainer").find(">*").removeData("unobtrusiveContainer")}}function u(e){var n=a(e),t=n.data(v),r=a.proxy(l,e),i=f.unobtrusive.options||{},u=function(n,t){var r=i[n];r&&a.isFunction(r)&&r.apply(e,t)};return t||(t={options:{errorClass:i.errorClass||"input-validation-error",errorElement:i.errorElement||"span",errorPlacement:function(){o.apply(e,arguments),u("errorPlacement",arguments)},invalidHandler:function(){d.apply(e,arguments),u("invalidHandler",arguments)},messages:{},rules:{},success:function(){s.apply(e,arguments),u("success",arguments)}},attachValidation:function(){n.off("reset."+v,r).on("reset."+v,r).validate(this.options)},validate:function(){return n.validate(),n.valid()}},n.data(v,t)),t}var m,f=a.validator,v="unobtrusiveValidation";return f.unobtrusive={adapters:[],parseElement:function(e,n){var t,r,i,o=a(e),d=o.parents("form")[0];d&&(t=u(d),t.options.rules[e.name]=r={},t.options.messages[e.name]=i={},a.each(this.adapters,function(){var n="data-val-"+this.name,t=o.attr(n),s={};void 0!==t&&(n+="-",a.each(this.params,function(){s[this]=o.attr(n+this)}),this.adapt({element:e,form:d,message:t,params:s,rules:r,messages:i}))}),a.extend(r,{__dummy__:!0}),n||t.attachValidation())},parse:function(e){var n=a(e),t=n.parents().addBack().filter("form").add(n.find("form")).has("[data-val=true]");n.find("[data-val=true]").each(function(){f.unobtrusive.parseElement(this,!0)}),t.each(function(){var a=u(this);a&&a.attachValidation()})}},m=f.unobtrusive.adapters,m.add=function(a,e,n){return n||(n=e,e=[]),this.push({name:a,params:e,adapt:n}),this},m.addBool=function(a,n){return this.add(a,function(t){e(t,n||a,!0)})},m.addMinMax=function(a,n,t,r,i,o){return this.add(a,[i||"min",o||"max"],function(a){var i=a.params.min,o=a.params.max;i&&o?e(a,r,[i,o]):i?e(a,n,i):o&&e(a,t,o)})},m.addSingleVal=function(a,n,t){return this.add(a,[n||"val"],function(r){e(r,t||a,r.params[n])})},f.addMethod("__dummy__",function(a,e,n){return!0}),f.addMethod("regex",function(a,e,n){var t;return!!this.optional(e)||(t=new RegExp(n).exec(a),t&&0===t.index&&t[0].length===a.length)}),f.addMethod("nonalphamin",function(a,e,n){var t;return n&&(t=a.match(/\W/g),t=t&&t.length>=n),t}),f.methods.extension?(m.addSingleVal("accept","mimtype"),m.addSingleVal("extension","extension")):m.addSingleVal("extension","extension","accept"),m.addSingleVal("regex","pattern"),m.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url"),m.addMinMax("length","minlength","maxlength","rangelength").addMinMax("range","min","max","range"),m.addMinMax("minlength","minlength").addMinMax("maxlength","minlength","maxlength"),m.add("equalto",["other"],function(n){var o=r(n.element.name),d=n.params.other,s=i(d,o),l=a(n.form).find(":input").filter("[name='"+t(s)+"']")[0];e(n,"equalTo",l)}),m.add("required",function(a){"INPUT"===a.element.tagName.toUpperCase()&&"CHECKBOX"===a.element.type.toUpperCase()||e(a,"required",!0)}),m.add("remote",["url","type","additionalfields"],function(o){var d={url:o.params.url,type:o.params.type||"GET",data:{}},s=r(o.element.name);a.each(n(o.params.additionalfields||o.element.name),function(e,n){var r=i(n,s);d.data[r]=function(){var e=a(o.form).find(":input").filter("[name='"+t(r)+"']");return e.is(":checkbox")?e.filter(":checked").val()||e.filter(":hidden").val()||"":e.is(":radio")?e.filter(":checked").val()||"":e.val()}}),e(o,"remote",d)}),m.add("password",["min","nonalphamin","regex"],function(a){a.params.min&&e(a,"minlength",a.params.min),a.params.nonalphamin&&e(a,"nonalphamin",a.params.nonalphamin),a.params.regex&&e(a,"regex",a.params.regex)}),m.add("fileextensions",["extensions"],function(a){e(a,"extension",a.params.extensions)}),a(function(){f.unobtrusive.parse(document)}),f.unobtrusive}); -------------------------------------------------------------------------------- /Documentation/api/.manifest: -------------------------------------------------------------------------------- 1 | { 2 | "ChessSharp": "ChessSharp.yml", 3 | "ChessSharp.ChessUtilities": "ChessSharp.ChessUtilities.yml", 4 | "ChessSharp.ChessUtilities.GetValidMoves(ChessSharp.GameBoard)": "ChessSharp.ChessUtilities.yml", 5 | "ChessSharp.ChessUtilities.GetValidMovesOfSourceSquare(ChessSharp.SquareData.Square,ChessSharp.GameBoard)": "ChessSharp.ChessUtilities.yml", 6 | "ChessSharp.GameBoard": "ChessSharp.GameBoard.yml", 7 | "ChessSharp.GameBoard.#ctor": "ChessSharp.GameBoard.yml", 8 | "ChessSharp.GameBoard.Board": "ChessSharp.GameBoard.yml", 9 | "ChessSharp.GameBoard.GameState": "ChessSharp.GameBoard.yml", 10 | "ChessSharp.GameBoard.IsValidMove(ChessSharp.Move)": "ChessSharp.GameBoard.yml", 11 | "ChessSharp.GameBoard.Item(ChessSharp.SquareData.File,ChessSharp.SquareData.Rank)": "ChessSharp.GameBoard.yml", 12 | "ChessSharp.GameBoard.Item(ChessSharp.SquareData.Square)": "ChessSharp.GameBoard.yml", 13 | "ChessSharp.GameBoard.MakeMove(ChessSharp.Move,System.Boolean)": "ChessSharp.GameBoard.yml", 14 | "ChessSharp.GameBoard.Moves": "ChessSharp.GameBoard.yml", 15 | "ChessSharp.GameBoard.WhoseTurn": "ChessSharp.GameBoard.yml", 16 | "ChessSharp.GameState": "ChessSharp.GameState.yml", 17 | "ChessSharp.GameState.BlackInCheck": "ChessSharp.GameState.yml", 18 | "ChessSharp.GameState.BlackWinner": "ChessSharp.GameState.yml", 19 | "ChessSharp.GameState.Draw": "ChessSharp.GameState.yml", 20 | "ChessSharp.GameState.NotCompleted": "ChessSharp.GameState.yml", 21 | "ChessSharp.GameState.Stalemate": "ChessSharp.GameState.yml", 22 | "ChessSharp.GameState.WhiteInCheck": "ChessSharp.GameState.yml", 23 | "ChessSharp.GameState.WhiteWinner": "ChessSharp.GameState.yml", 24 | "ChessSharp.Move": "ChessSharp.Move.yml", 25 | "ChessSharp.Move.#ctor(ChessSharp.SquareData.Square,ChessSharp.SquareData.Square,ChessSharp.Player,System.Nullable{ChessSharp.Pieces.PawnPromotion})": "ChessSharp.Move.yml", 26 | "ChessSharp.Move.Destination": "ChessSharp.Move.yml", 27 | "ChessSharp.Move.Equals(System.Object)": "ChessSharp.Move.yml", 28 | "ChessSharp.Move.GetAbsDeltaX": "ChessSharp.Move.yml", 29 | "ChessSharp.Move.GetAbsDeltaY": "ChessSharp.Move.yml", 30 | "ChessSharp.Move.GetDeltaX": "ChessSharp.Move.yml", 31 | "ChessSharp.Move.GetDeltaY": "ChessSharp.Move.yml", 32 | "ChessSharp.Move.GetHashCode": "ChessSharp.Move.yml", 33 | "ChessSharp.Move.Player": "ChessSharp.Move.yml", 34 | "ChessSharp.Move.PromoteTo": "ChessSharp.Move.yml", 35 | "ChessSharp.Move.Source": "ChessSharp.Move.yml", 36 | "ChessSharp.Piece": "ChessSharp.Piece.yml", 37 | "ChessSharp.Piece.#ctor(ChessSharp.Player)": "ChessSharp.Piece.yml", 38 | "ChessSharp.Piece.Equals(System.Object)": "ChessSharp.Piece.yml", 39 | "ChessSharp.Piece.GetHashCode": "ChessSharp.Piece.yml", 40 | "ChessSharp.Piece.Owner": "ChessSharp.Piece.yml", 41 | "ChessSharp.Pieces": "ChessSharp.Pieces.yml", 42 | "ChessSharp.Pieces.Bishop": "ChessSharp.Pieces.Bishop.yml", 43 | "ChessSharp.Pieces.King": "ChessSharp.Pieces.King.yml", 44 | "ChessSharp.Pieces.Knight": "ChessSharp.Pieces.Knight.yml", 45 | "ChessSharp.Pieces.Pawn": "ChessSharp.Pieces.Pawn.yml", 46 | "ChessSharp.Pieces.PawnPromotion": "ChessSharp.Pieces.PawnPromotion.yml", 47 | "ChessSharp.Pieces.PawnPromotion.Bishop": "ChessSharp.Pieces.PawnPromotion.yml", 48 | "ChessSharp.Pieces.PawnPromotion.Knight": "ChessSharp.Pieces.PawnPromotion.yml", 49 | "ChessSharp.Pieces.PawnPromotion.Queen": "ChessSharp.Pieces.PawnPromotion.yml", 50 | "ChessSharp.Pieces.PawnPromotion.Rook": "ChessSharp.Pieces.PawnPromotion.yml", 51 | "ChessSharp.Pieces.Queen": "ChessSharp.Pieces.Queen.yml", 52 | "ChessSharp.Pieces.Rook": "ChessSharp.Pieces.Rook.yml", 53 | "ChessSharp.Player": "ChessSharp.Player.yml", 54 | "ChessSharp.Player.Black": "ChessSharp.Player.yml", 55 | "ChessSharp.Player.White": "ChessSharp.Player.yml", 56 | "ChessSharp.SquareData": "ChessSharp.SquareData.yml", 57 | "ChessSharp.SquareData.File": "ChessSharp.SquareData.File.yml", 58 | "ChessSharp.SquareData.File.A": "ChessSharp.SquareData.File.yml", 59 | "ChessSharp.SquareData.File.B": "ChessSharp.SquareData.File.yml", 60 | "ChessSharp.SquareData.File.C": "ChessSharp.SquareData.File.yml", 61 | "ChessSharp.SquareData.File.D": "ChessSharp.SquareData.File.yml", 62 | "ChessSharp.SquareData.File.E": "ChessSharp.SquareData.File.yml", 63 | "ChessSharp.SquareData.File.F": "ChessSharp.SquareData.File.yml", 64 | "ChessSharp.SquareData.File.G": "ChessSharp.SquareData.File.yml", 65 | "ChessSharp.SquareData.File.H": "ChessSharp.SquareData.File.yml", 66 | "ChessSharp.SquareData.Rank": "ChessSharp.SquareData.Rank.yml", 67 | "ChessSharp.SquareData.Rank.Eighth": "ChessSharp.SquareData.Rank.yml", 68 | "ChessSharp.SquareData.Rank.Fifth": "ChessSharp.SquareData.Rank.yml", 69 | "ChessSharp.SquareData.Rank.First": "ChessSharp.SquareData.Rank.yml", 70 | "ChessSharp.SquareData.Rank.Forth": "ChessSharp.SquareData.Rank.yml", 71 | "ChessSharp.SquareData.Rank.Second": "ChessSharp.SquareData.Rank.yml", 72 | "ChessSharp.SquareData.Rank.Seventh": "ChessSharp.SquareData.Rank.yml", 73 | "ChessSharp.SquareData.Rank.Sixth": "ChessSharp.SquareData.Rank.yml", 74 | "ChessSharp.SquareData.Rank.Third": "ChessSharp.SquareData.Rank.yml", 75 | "ChessSharp.SquareData.Square": "ChessSharp.SquareData.Square.yml", 76 | "ChessSharp.SquareData.Square.#ctor(ChessSharp.SquareData.File,ChessSharp.SquareData.Rank)": "ChessSharp.SquareData.Square.yml", 77 | "ChessSharp.SquareData.Square.#ctor(System.Char,System.Int32)": "ChessSharp.SquareData.Square.yml", 78 | "ChessSharp.SquareData.Square.Equals(System.Object)": "ChessSharp.SquareData.Square.yml", 79 | "ChessSharp.SquareData.Square.File": "ChessSharp.SquareData.Square.yml", 80 | "ChessSharp.SquareData.Square.GetHashCode": "ChessSharp.SquareData.Square.yml", 81 | "ChessSharp.SquareData.Square.op_Implicit(System.String)~ChessSharp.SquareData.Square": "ChessSharp.SquareData.Square.yml", 82 | "ChessSharp.SquareData.Square.Parse(System.String)": "ChessSharp.SquareData.Square.yml", 83 | "ChessSharp.SquareData.Square.Rank": "ChessSharp.SquareData.Square.yml", 84 | "ChessSharp.SquareData.Square.ToString": "ChessSharp.SquareData.Square.yml" 85 | } -------------------------------------------------------------------------------- /src/ChessUI/Form1.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /src/ChessSharpUno/ChessSharpUno/Strings/en/Resources.resw: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | ChessSharpUno-en 122 | 123 | 124 | --------------------------------------------------------------------------------