diff --git a/ChineseChess.Core/Chess.cs b/ChineseChess.Core/Chess.cs new file mode 100644 index 0000000..8b0e9dc --- /dev/null +++ b/ChineseChess.Core/Chess.cs @@ -0,0 +1,9 @@ +namespace ChineseChess.Core +{ + public class Chess + { + public ChessType Type { get; set; } + public ChessCamp Camp { get; set; } + public ChessboardPosition Position { get; set; } + } +} \ No newline at end of file diff --git a/ChineseChess.Core/ChessCamp.cs b/ChineseChess.Core/ChessCamp.cs new file mode 100644 index 0000000..7faa01b --- /dev/null +++ b/ChineseChess.Core/ChessCamp.cs @@ -0,0 +1,18 @@ +namespace ChineseChess.Core +{ + /// + /// 棋子阵营 + /// + public enum ChessCamp + { + /// + /// 红方 + /// + Red, + + /// + /// 黑方 + /// + Black, + } +} \ No newline at end of file diff --git a/ChineseChess.Core/ChessMove.cs b/ChineseChess.Core/ChessMove.cs new file mode 100644 index 0000000..fd7dd76 --- /dev/null +++ b/ChineseChess.Core/ChessMove.cs @@ -0,0 +1,55 @@ +using System; + +namespace ChineseChess.Core +{ + /// + /// 棋子移动步骤 + /// + public class ChessMove + { + private ChessMove() + { + + } + + public static ChessMove GenMove(Chessboard chessboard, string move) + { + throw new NotImplementedException(); + } + + public static ChessMove GenMove(Chessboard chessboard, ChessCamp camp, ChessboardPosition start, ChessboardPosition end) + { + throw new NotImplementedException(); + } + + /// + /// 阵营 + /// + public ChessCamp Camp { get; } + + /// + /// 移动的棋子 + /// + public ChessType Chess { get; } + + /// + /// 击杀的棋子 可为空 + /// + public ChessType? Killed { get; } + + /// + /// 起点位置 + /// + public ChessboardPosition Start { get; } + + /// + /// 终点位置 + /// + public ChessboardPosition End { get; } + + /// + /// 文本格式 + /// + public string Text { get; } + } +} \ No newline at end of file diff --git a/ChineseChess.Core/ChessType.cs b/ChineseChess.Core/ChessType.cs new file mode 100644 index 0000000..f8a030d --- /dev/null +++ b/ChineseChess.Core/ChessType.cs @@ -0,0 +1,43 @@ +namespace ChineseChess.Core +{ + /// + /// 象棋棋子 + /// + public enum ChessType + { + /// + /// 将、帅 + /// + King, + + /// + /// 士、仕 + /// + Mandarins, + + /// + /// 象、相 + /// + Elephants, + + /// + /// 马 + /// + Knights, + + /// + /// 车 + /// + Rooks, + + /// + /// 炮 + /// + Cannons, + + /// + /// 兵、卒 + /// + Pawns, + } +} diff --git a/ChineseChess.Core/ChessTypeExtensions.cs b/ChineseChess.Core/ChessTypeExtensions.cs new file mode 100644 index 0000000..26b6ad0 --- /dev/null +++ b/ChineseChess.Core/ChessTypeExtensions.cs @@ -0,0 +1,82 @@ +using System.Collections.Generic; + +namespace ChineseChess.Core +{ + public static class ChessTypeExtensions + { + private readonly static Dictionary RedChess; + private readonly static Dictionary BlackChess; + private readonly static Dictionary ChessNames; + + static ChessTypeExtensions() + { + RedChess = new Dictionary + { + [ChessType.King ] = '帅', + [ChessType.Mandarins] = '仕', + [ChessType.Elephants] = '相', + [ChessType.Knights ] = '马', + [ChessType.Rooks ] = '车', + [ChessType.Cannons ] = '炮', + [ChessType.Pawns ] = '兵', + }; + BlackChess = new Dictionary + { + [ChessType.King ] = '将', + [ChessType.Mandarins] = '士', + [ChessType.Elephants] = '象', + [ChessType.Knights ] = '马', + [ChessType.Rooks ] = '车', + [ChessType.Cannons ] = '炮', + [ChessType.Pawns ] = '卒', + }; + + ChessNames = new Dictionary + { + ['帅'] = ChessType.King, + ['将'] = ChessType.King, + ['仕'] = ChessType.Mandarins, + ['士'] = ChessType.Mandarins, + ['相'] = ChessType.Elephants, + ['象'] = ChessType.Elephants, + ['马'] = ChessType.Knights, + ['车'] = ChessType.Rooks, + ['炮'] = ChessType.Cannons, + ['兵'] = ChessType.Pawns, + ['卒'] = ChessType.Pawns, + }; + } + + /// + /// 获取棋子名称 + /// + /// 棋子类型 + /// 棋子阵营 + /// + public static char GetName(this ChessType type, ChessCamp camp) + { + return camp == ChessCamp.Red ? RedChess[type] : BlackChess[type]; + } + + /// + /// Parses the specified name. + /// + /// The name. + /// + public static ChessType Parse(char name) + { + return ChessNames[name]; + } + + /// + /// Tries the parse. + /// + /// The name. + /// The type. + /// + public static bool TryParse(char name, out ChessType type) + { + return ChessNames.TryGetValue(name, out type); + } + } +} \ No newline at end of file diff --git a/ChineseChess.Core/Chessboard.cs b/ChineseChess.Core/Chessboard.cs new file mode 100644 index 0000000..90a7b4e --- /dev/null +++ b/ChineseChess.Core/Chessboard.cs @@ -0,0 +1,6 @@ +namespace ChineseChess.Core +{ + public class Chessboard + { + } +} \ No newline at end of file diff --git a/ChineseChess.Core/ChessboardPosition.cs b/ChineseChess.Core/ChessboardPosition.cs new file mode 100644 index 0000000..616b848 --- /dev/null +++ b/ChineseChess.Core/ChessboardPosition.cs @@ -0,0 +1,8 @@ +namespace ChineseChess.Core +{ + public struct ChessboardPosition + { + public byte Col; + public byte Row; + } +} \ No newline at end of file diff --git a/ChineseChess.Core/ChineseChess.Core.csproj b/ChineseChess.Core/ChineseChess.Core.csproj new file mode 100644 index 0000000..dbdcea4 --- /dev/null +++ b/ChineseChess.Core/ChineseChess.Core.csproj @@ -0,0 +1,7 @@ + + + + netstandard2.0 + + + diff --git a/ChineseChess.Core/Game.cs b/ChineseChess.Core/Game.cs new file mode 100644 index 0000000..c4c5229 --- /dev/null +++ b/ChineseChess.Core/Game.cs @@ -0,0 +1,9 @@ +using System; + +namespace ChineseChess.Core +{ + public class Game + { + // TODO + } +} diff --git a/ChineseChess.UI/App.config b/ChineseChess.UI/App.config new file mode 100644 index 0000000..88fa402 --- /dev/null +++ b/ChineseChess.UI/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ChineseChess.UI/App.xaml b/ChineseChess.UI/App.xaml new file mode 100644 index 0000000..ea2515f --- /dev/null +++ b/ChineseChess.UI/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/ChineseChess.UI/App.xaml.cs b/ChineseChess.UI/App.xaml.cs new file mode 100644 index 0000000..94815ff --- /dev/null +++ b/ChineseChess.UI/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace ChineseChess.UI +{ + /// + /// App.xaml 的交互逻辑 + /// + public partial class App : Application + { + } +} diff --git a/ChineseChess.UI/ChineseChess.UI.csproj b/ChineseChess.UI/ChineseChess.UI.csproj new file mode 100644 index 0000000..d6d3259 --- /dev/null +++ b/ChineseChess.UI/ChineseChess.UI.csproj @@ -0,0 +1,104 @@ + + + + + Debug + AnyCPU + {92AB0092-581C-4518-916D-FFC5084282FB} + WinExe + ChineseChess.UI + ChineseChess.UI + v4.5.2 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + {6e2fa057-9341-496b-bd68-ec3e4ce3e18a} + ChineseChess.Core + + + + \ No newline at end of file diff --git a/ChineseChess.UI/MainWindow.xaml b/ChineseChess.UI/MainWindow.xaml new file mode 100644 index 0000000..7818bbf --- /dev/null +++ b/ChineseChess.UI/MainWindow.xaml @@ -0,0 +1,14 @@ + + + diff --git a/ChineseChess.UI/MainWindow.xaml.cs b/ChineseChess.UI/MainWindow.xaml.cs new file mode 100644 index 0000000..d3be992 --- /dev/null +++ b/ChineseChess.UI/MainWindow.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace ChineseChess.UI +{ + /// + /// MainWindow.xaml 的交互逻辑 + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + } + } +} diff --git a/ChineseChess.UI/Properties/AssemblyInfo.cs b/ChineseChess.UI/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..8d121d6 --- /dev/null +++ b/ChineseChess.UI/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("ChineseChess.UI")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ChineseChess.UI")] +[assembly: AssemblyCopyright("Copyright © 2021")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +//若要开始生成可本地化的应用程序,请设置 +//.csproj 文件中的 CultureYouAreCodingWith +//例如,如果您在源文件中使用的是美国英语, +//使用的是美国英语,请将 设置为 en-US。 然后取消 +//对以下 NeutralResourceLanguage 特性的注释。 更新 +//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。 + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //主题特定资源词典所处位置 + //(未在页面中找到资源时使用, + //或应用程序资源字典中找到时使用) + ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置 + //(未在页面中找到资源时使用, + //、应用程序或任何主题专用资源字典中找到时使用) +)] + + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ChineseChess.UI/Properties/Resources.Designer.cs b/ChineseChess.UI/Properties/Resources.Designer.cs new file mode 100644 index 0000000..b6638a9 --- /dev/null +++ b/ChineseChess.UI/Properties/Resources.Designer.cs @@ -0,0 +1,70 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本: 4.0.30319.42000 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + + +namespace ChineseChess.UI.Properties +{ + /// + /// 强类型资源类,用于查找本地化字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// 返回此类使用的缓存 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ChineseChess.UI.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 重写当前线程的 CurrentUICulture 属性,对 + /// 使用此强类型资源类的所有资源查找执行重写。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/ChineseChess.UI/Properties/Resources.resx b/ChineseChess.UI/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/ChineseChess.UI/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ChineseChess.UI/Properties/Settings.Designer.cs b/ChineseChess.UI/Properties/Settings.Designer.cs new file mode 100644 index 0000000..51bff2c --- /dev/null +++ b/ChineseChess.UI/Properties/Settings.Designer.cs @@ -0,0 +1,29 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +namespace ChineseChess.UI.Properties +{ + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/ChineseChess.UI/Properties/Settings.settings b/ChineseChess.UI/Properties/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/ChineseChess.UI/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ChineseChess.sln b/ChineseChess.sln new file mode 100644 index 0000000..08ff48a --- /dev/null +++ b/ChineseChess.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31129.286 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChineseChess.UI", "ChineseChess.UI\ChineseChess.UI.csproj", "{92AB0092-581C-4518-916D-FFC5084282FB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChineseChess.Core", "ChineseChess.Core\ChineseChess.Core.csproj", "{6E2FA057-9341-496B-BD68-EC3E4CE3E18A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {92AB0092-581C-4518-916D-FFC5084282FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {92AB0092-581C-4518-916D-FFC5084282FB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {92AB0092-581C-4518-916D-FFC5084282FB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {92AB0092-581C-4518-916D-FFC5084282FB}.Release|Any CPU.Build.0 = Release|Any CPU + {6E2FA057-9341-496B-BD68-EC3E4CE3E18A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6E2FA057-9341-496B-BD68-EC3E4CE3E18A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6E2FA057-9341-496B-BD68-EC3E4CE3E18A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6E2FA057-9341-496B-BD68-EC3E4CE3E18A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A499202F-4B5A-4F4B-88F4-C153ABC4E049} + EndGlobalSection +EndGlobal