initial commit
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
|
@ -0,0 +1,163 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{D2367663-B1D6-4C08-B870-0C5B4A056E9A}</ProjectGuid>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<RootNamespace>Chess</RootNamespace>
|
||||||
|
<AssemblyName>Chess</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Deployment" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Szachownica.cs" />
|
||||||
|
<Compile Include="Figura.cs" />
|
||||||
|
<Compile Include="ChessWindow.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="ChessWindow.Designer.cs">
|
||||||
|
<DependentUpon>ChessWindow.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Posuniecie.cs" />
|
||||||
|
<Compile Include="PieceSelection.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="PieceSelection.Designer.cs">
|
||||||
|
<DependentUpon>PieceSelection.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Tile.cs">
|
||||||
|
<SubType>UserControl</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Tile.Designer.cs">
|
||||||
|
<DependentUpon>Tile.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<EmbeddedResource Include="ChessWindow.resx">
|
||||||
|
<DependentUpon>ChessWindow.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="PieceSelection.resx">
|
||||||
|
<DependentUpon>PieceSelection.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="Tile.resx">
|
||||||
|
<DependentUpon>Tile.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<None Include=".editorconfig" />
|
||||||
|
<None Include="Properties\Settings.settings">
|
||||||
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
|
</None>
|
||||||
|
<Compile Include="Properties\Settings.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\WKing.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\WKnight.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\WPawn.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\WBishop.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\WQueen.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\WRook.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\BPawn.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\BQueen.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\BRook.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\BBishop.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\BKing.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\BKnight.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\PossibleMove.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\OLDPaper2.jpg" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\ChessFrames.jpg" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\undoArrrow.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\redoArrow.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\CantRedo.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\undoArrrowClicked.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
|
@ -0,0 +1,30 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 16
|
||||||
|
VisualStudioVersion = 16.0.29806.167
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Chess", "Chess.csproj", "{D2367663-B1D6-4C08-B870-0C5B4A056E9A}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{34887B0F-D3F9-4271-B4B9-CAA1FD4DF2FB}"
|
||||||
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
.editorconfig = .editorconfig
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{D2367663-B1D6-4C08-B870-0C5B4A056E9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{D2367663-B1D6-4C08-B870-0C5B4A056E9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{D2367663-B1D6-4C08-B870-0C5B4A056E9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{D2367663-B1D6-4C08-B870-0C5B4A056E9A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {ED2453F2-3EF4-4D2E-80F6-AE7E51336B86}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -0,0 +1,232 @@
|
||||||
|
namespace Chess
|
||||||
|
{
|
||||||
|
partial class Szachy
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Szachy));
|
||||||
|
this.RestartButton = new System.Windows.Forms.Button();
|
||||||
|
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||||
|
this.GameState = new System.Windows.Forms.Label();
|
||||||
|
this.Timer = new System.Windows.Forms.GroupBox();
|
||||||
|
this.label5 = new System.Windows.Forms.Label();
|
||||||
|
this.label4 = new System.Windows.Forms.Label();
|
||||||
|
this.WhiteTimer = new System.Windows.Forms.Label();
|
||||||
|
this.TimeButton = new System.Windows.Forms.Button();
|
||||||
|
this.BlackTimer = new System.Windows.Forms.Label();
|
||||||
|
this.State = new System.Windows.Forms.GroupBox();
|
||||||
|
this.Undo = new System.Windows.Forms.PictureBox();
|
||||||
|
this.groupBox1.SuspendLayout();
|
||||||
|
this.Timer.SuspendLayout();
|
||||||
|
this.State.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.Undo)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// RestartButton
|
||||||
|
//
|
||||||
|
this.RestartButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
||||||
|
this.RestartButton.Location = new System.Drawing.Point(24, 62);
|
||||||
|
this.RestartButton.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.RestartButton.Name = "RestartButton";
|
||||||
|
this.RestartButton.Size = new System.Drawing.Size(49, 19);
|
||||||
|
this.RestartButton.TabIndex = 1;
|
||||||
|
this.RestartButton.Text = "Od nowa";
|
||||||
|
this.RestartButton.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
this.groupBox1.BackColor = System.Drawing.SystemColors.Control;
|
||||||
|
this.groupBox1.Controls.Add(this.Undo);
|
||||||
|
this.groupBox1.Controls.Add(this.RestartButton);
|
||||||
|
this.groupBox1.Location = new System.Drawing.Point(400, 11);
|
||||||
|
this.groupBox1.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.groupBox1.Name = "groupBox1";
|
||||||
|
this.groupBox1.Padding = new System.Windows.Forms.Padding(2);
|
||||||
|
this.groupBox1.Size = new System.Drawing.Size(95, 97);
|
||||||
|
this.groupBox1.TabIndex = 1;
|
||||||
|
this.groupBox1.TabStop = false;
|
||||||
|
this.groupBox1.Text = "Kontrola gry";
|
||||||
|
//
|
||||||
|
// GameState
|
||||||
|
//
|
||||||
|
this.GameState.Anchor = System.Windows.Forms.AnchorStyles.None;
|
||||||
|
this.GameState.AutoSize = true;
|
||||||
|
this.GameState.BackColor = System.Drawing.Color.Transparent;
|
||||||
|
this.GameState.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.GameState.ForeColor = System.Drawing.Color.OliveDrab;
|
||||||
|
this.GameState.Location = new System.Drawing.Point(20, 60);
|
||||||
|
this.GameState.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||||
|
this.GameState.Name = "GameState";
|
||||||
|
this.GameState.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
|
||||||
|
this.GameState.Size = new System.Drawing.Size(0, 18);
|
||||||
|
this.GameState.TabIndex = 2;
|
||||||
|
this.GameState.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
|
//
|
||||||
|
// Timer
|
||||||
|
//
|
||||||
|
this.Timer.BackColor = System.Drawing.SystemColors.Control;
|
||||||
|
this.Timer.Controls.Add(this.label5);
|
||||||
|
this.Timer.Controls.Add(this.label4);
|
||||||
|
this.Timer.Controls.Add(this.WhiteTimer);
|
||||||
|
this.Timer.Controls.Add(this.TimeButton);
|
||||||
|
this.Timer.Controls.Add(this.BlackTimer);
|
||||||
|
this.Timer.Location = new System.Drawing.Point(400, 112);
|
||||||
|
this.Timer.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.Timer.Name = "Timer";
|
||||||
|
this.Timer.Padding = new System.Windows.Forms.Padding(2);
|
||||||
|
this.Timer.Size = new System.Drawing.Size(96, 138);
|
||||||
|
this.Timer.TabIndex = 3;
|
||||||
|
this.Timer.TabStop = false;
|
||||||
|
this.Timer.Text = "Zegar";
|
||||||
|
//
|
||||||
|
// label5
|
||||||
|
//
|
||||||
|
this.label5.AutoSize = true;
|
||||||
|
this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.label5.Location = new System.Drawing.Point(7, 65);
|
||||||
|
this.label5.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||||
|
this.label5.Name = "label5";
|
||||||
|
this.label5.Size = new System.Drawing.Size(35, 13);
|
||||||
|
this.label5.TabIndex = 4;
|
||||||
|
this.label5.Text = "Biale";
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
this.label4.AutoSize = true;
|
||||||
|
this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.label4.Location = new System.Drawing.Point(4, 31);
|
||||||
|
this.label4.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||||
|
this.label4.Name = "label4";
|
||||||
|
this.label4.Size = new System.Drawing.Size(46, 13);
|
||||||
|
this.label4.TabIndex = 3;
|
||||||
|
this.label4.Text = "Czarne";
|
||||||
|
//
|
||||||
|
// WhiteTimer
|
||||||
|
//
|
||||||
|
this.WhiteTimer.AutoSize = true;
|
||||||
|
this.WhiteTimer.BackColor = System.Drawing.Color.Transparent;
|
||||||
|
this.WhiteTimer.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.WhiteTimer.Location = new System.Drawing.Point(51, 62);
|
||||||
|
this.WhiteTimer.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||||
|
this.WhiteTimer.Name = "WhiteTimer";
|
||||||
|
this.WhiteTimer.Size = new System.Drawing.Size(44, 18);
|
||||||
|
this.WhiteTimer.TabIndex = 2;
|
||||||
|
this.WhiteTimer.Text = "00:00";
|
||||||
|
//
|
||||||
|
// TimeButton
|
||||||
|
//
|
||||||
|
this.TimeButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
||||||
|
this.TimeButton.Location = new System.Drawing.Point(28, 102);
|
||||||
|
this.TimeButton.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.TimeButton.Name = "TimeButton";
|
||||||
|
this.TimeButton.Size = new System.Drawing.Size(42, 19);
|
||||||
|
this.TimeButton.TabIndex = 0;
|
||||||
|
this.TimeButton.Text = "Start";
|
||||||
|
this.TimeButton.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// BlackTimer
|
||||||
|
//
|
||||||
|
this.BlackTimer.AutoSize = true;
|
||||||
|
this.BlackTimer.BackColor = System.Drawing.Color.Transparent;
|
||||||
|
this.BlackTimer.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.BlackTimer.Location = new System.Drawing.Point(50, 31);
|
||||||
|
this.BlackTimer.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||||
|
this.BlackTimer.Name = "BlackTimer";
|
||||||
|
this.BlackTimer.Size = new System.Drawing.Size(44, 18);
|
||||||
|
this.BlackTimer.TabIndex = 0;
|
||||||
|
this.BlackTimer.Text = "00:00";
|
||||||
|
//
|
||||||
|
// State
|
||||||
|
//
|
||||||
|
this.State.BackColor = System.Drawing.SystemColors.Control;
|
||||||
|
this.State.Controls.Add(this.GameState);
|
||||||
|
this.State.Location = new System.Drawing.Point(400, 254);
|
||||||
|
this.State.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.State.Name = "State";
|
||||||
|
this.State.Padding = new System.Windows.Forms.Padding(2);
|
||||||
|
this.State.Size = new System.Drawing.Size(96, 146);
|
||||||
|
this.State.TabIndex = 4;
|
||||||
|
this.State.TabStop = false;
|
||||||
|
//
|
||||||
|
// Undo
|
||||||
|
//
|
||||||
|
this.Undo.Image = global::Chess.Properties.Resources.undoArrrow;
|
||||||
|
this.Undo.Location = new System.Drawing.Point(37, 26);
|
||||||
|
this.Undo.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.Undo.Name = "Undo";
|
||||||
|
this.Undo.Size = new System.Drawing.Size(24, 21);
|
||||||
|
this.Undo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||||
|
this.Undo.TabIndex = 3;
|
||||||
|
this.Undo.TabStop = false;
|
||||||
|
//
|
||||||
|
// Szachy
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(513, 413);
|
||||||
|
this.Controls.Add(this.State);
|
||||||
|
this.Controls.Add(this.Timer);
|
||||||
|
this.Controls.Add(this.groupBox1);
|
||||||
|
this.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
|
this.DoubleBuffered = true;
|
||||||
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||||
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.MaximizeBox = false;
|
||||||
|
this.MaximumSize = new System.Drawing.Size(529, 460);
|
||||||
|
this.MinimizeBox = false;
|
||||||
|
this.MinimumSize = new System.Drawing.Size(488, 450);
|
||||||
|
this.Name = "Szachy";
|
||||||
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
|
this.Text = "Szachy";
|
||||||
|
this.Load += new System.EventHandler(this.Chess_Load);
|
||||||
|
this.groupBox1.ResumeLayout(false);
|
||||||
|
this.Timer.ResumeLayout(false);
|
||||||
|
this.Timer.PerformLayout();
|
||||||
|
this.State.ResumeLayout(false);
|
||||||
|
this.State.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.Undo)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Button RestartButton;
|
||||||
|
private System.Windows.Forms.GroupBox groupBox1;
|
||||||
|
public System.Windows.Forms.Label GameState;
|
||||||
|
private System.Windows.Forms.GroupBox Timer;
|
||||||
|
private System.Windows.Forms.Label BlackTimer;
|
||||||
|
private System.Windows.Forms.Button TimeButton;
|
||||||
|
private System.Windows.Forms.Label label5;
|
||||||
|
private System.Windows.Forms.Label label4;
|
||||||
|
private System.Windows.Forms.Label WhiteTimer;
|
||||||
|
private System.Windows.Forms.PictureBox Undo;
|
||||||
|
private System.Windows.Forms.GroupBox State;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,216 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Chess
|
||||||
|
{
|
||||||
|
public partial class Szachy : Form
|
||||||
|
{
|
||||||
|
public Szachy() { InitializeComponent(); }
|
||||||
|
|
||||||
|
private Szachownica board;
|
||||||
|
private void Chess_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
board = new Szachownica(this);
|
||||||
|
Szachownica.KogoTerazTura = Kolor.NONE;
|
||||||
|
TimeButton.MouseDown += click;
|
||||||
|
Undo.MouseDown += click;
|
||||||
|
Undo.MouseUp += ReleasedButton;
|
||||||
|
RestartButton.MouseUp += click;
|
||||||
|
}
|
||||||
|
public Kolor poprzedniGracz = Kolor.WHITE;
|
||||||
|
|
||||||
|
private void click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (sender.GetType() == typeof(Button))
|
||||||
|
{
|
||||||
|
switch (((Button)sender).Name)
|
||||||
|
{
|
||||||
|
case "TimeButton":
|
||||||
|
if (Szachownica.KogoTerazTura == Kolor.NONE && poprzedniGracz == Kolor.NONE) { TimeButton.Enabled = false; return; }
|
||||||
|
TimeButton.Text = TimeButton.Text == "Start" ? "Stop" : "Start";
|
||||||
|
if (Szachownica.KogoTerazTura == Kolor.NONE)
|
||||||
|
{
|
||||||
|
WystartujZegar();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ZatrzymajZegar();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case "RestartButton":
|
||||||
|
int moves = Szachownica.poprzednieRuchy.Count;
|
||||||
|
for (int i = 0; i < moves; i++)
|
||||||
|
{
|
||||||
|
PokazPoprzednieRuchy();
|
||||||
|
}
|
||||||
|
|
||||||
|
Szachownica.poprzednieRuchy = new List<PoprzedniStanSzachownicy>();
|
||||||
|
Black = new CzasGraczy(0, 0);
|
||||||
|
White = new CzasGraczy(0, 0);
|
||||||
|
if (timer != null)
|
||||||
|
{
|
||||||
|
ZatrzymajZegar();
|
||||||
|
}
|
||||||
|
|
||||||
|
TimeButton.Text = "Start";
|
||||||
|
Szachownica.Window.GameState.Text = "";
|
||||||
|
Szachownica.KogoTerazTura = Kolor.NONE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sender.GetType() == typeof(PictureBox))
|
||||||
|
{
|
||||||
|
switch (((PictureBox)sender).Name)
|
||||||
|
{
|
||||||
|
case "Undo":
|
||||||
|
Undo.Image = Properties.Resources.undoArrrowClicked;
|
||||||
|
PokazPoprzednieRuchy();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PokazPoprzednieRuchy()
|
||||||
|
{
|
||||||
|
if (Szachownica.poprzednieRuchy.Count == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int dir = Szachownica.KogoTerazTura == Kolor.BLACK ? 1 : -1;
|
||||||
|
Kolor poprzedniGracz = Szachownica.KogoTerazTura == Kolor.BLACK ? Kolor.WHITE : Kolor.BLACK;
|
||||||
|
if (poprzedniRuch.figura.rodzajfigury == RodzajFigury.King)
|
||||||
|
{
|
||||||
|
int ydir = poprzedniGracz == Kolor.WHITE ? 7 : 0;
|
||||||
|
if (poprzedniRuch.indexRuchu == 8)
|
||||||
|
{
|
||||||
|
Szachownica.pola[ydir, 5].PrzydzialFigur(new Figura(RodzajFigury.EMPTY));
|
||||||
|
Szachownica.pola[ydir, 7].PrzydzialFigur(new Figura(RodzajFigury.Rook, poprzedniGracz));
|
||||||
|
}
|
||||||
|
if (poprzedniRuch.indexRuchu == 9)
|
||||||
|
{
|
||||||
|
Szachownica.pola[ydir, 3].PrzydzialFigur(new Figura(RodzajFigury.EMPTY));
|
||||||
|
Szachownica.pola[ydir, 0].PrzydzialFigur(new Figura(RodzajFigury.Rook, poprzedniGracz));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (poprzedniRuch.figura.rodzajfigury == RodzajFigury.Pawn)
|
||||||
|
{
|
||||||
|
if (poprzedniRuch.indexRuchu == 4)
|
||||||
|
{
|
||||||
|
Szachownica.pola[poprzedniRuch.ruch.y + dir, poprzedniRuch.ruch.x].PrzydzialFigur(new Figura(RodzajFigury.Pawn, Szachownica.KogoTerazTura, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (poprzedniRuch.indexRuchu == 5)
|
||||||
|
{
|
||||||
|
Szachownica.pola[poprzedniRuch.ruch.y + dir, poprzedniRuch.ruch.x].PrzydzialFigur(new Figura(RodzajFigury.Pawn, Szachownica.KogoTerazTura, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Szachownica.pola[poprzedniRuch.ruch.y, poprzedniRuch.ruch.x].PrzydzialFigur(poprzedniRuch.usunieteFigury);
|
||||||
|
Szachownica.pola[poprzedniRuch.poprzedniaLokalizacja.y, poprzedniRuch.poprzedniaLokalizacja.x].PrzydzialFigur(poprzedniRuch.figura);
|
||||||
|
Szachownica.poprzednieRuchy.RemoveAt(Szachownica.poprzednieRuchy.Count - 1);
|
||||||
|
Szachownica.KogoTerazTura = poprzedniGracz;
|
||||||
|
Figura.ZaaktualizujWszystkieAtaki();
|
||||||
|
Posuniecie movement = new Posuniecie();
|
||||||
|
if (movement.SyndromOblezonejTwierdzy())
|
||||||
|
{
|
||||||
|
Szachownica.Window.GameState.Text = "Szach";
|
||||||
|
Szachownica.Window.GameState.ForeColor = System.Drawing.Color.Firebrick;
|
||||||
|
_ = movement.Mat();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReleasedButton(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
Undo.Image = Properties.Resources.undoArrrow;
|
||||||
|
}
|
||||||
|
|
||||||
|
private PoprzedniStanSzachownicy poprzedniRuch => Szachownica.poprzednieRuchy.Last();
|
||||||
|
|
||||||
|
private CzasGraczy Black = new CzasGraczy(0, 0);
|
||||||
|
private CzasGraczy White = new CzasGraczy(0, 0);
|
||||||
|
public Timer timer;
|
||||||
|
private void WystartujZegar()
|
||||||
|
{
|
||||||
|
Szachownica.KogoTerazTura = poprzedniGracz;
|
||||||
|
void ShowLabel(Label label, ref CzasGraczy time)
|
||||||
|
{
|
||||||
|
time.sekundy += 1;
|
||||||
|
label.Text = time.FormatCzasu();
|
||||||
|
if (time.sekundy >= 59) { time.minuty += 1; }
|
||||||
|
}
|
||||||
|
timer = new Timer
|
||||||
|
{
|
||||||
|
Interval = 1000
|
||||||
|
};
|
||||||
|
timer.Tick += (object sender, EventArgs e) =>
|
||||||
|
{
|
||||||
|
string gracz = Szachownica.KogoTerazTura.ToString();
|
||||||
|
if (gracz == "BLACK")
|
||||||
|
{
|
||||||
|
ShowLabel(BlackTimer, ref Black);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ShowLabel(WhiteTimer, ref White);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
timer.Start();
|
||||||
|
|
||||||
|
}
|
||||||
|
public void ZatrzymajZegar()
|
||||||
|
{
|
||||||
|
timer.Stop();
|
||||||
|
poprzedniGracz = Szachownica.KogoTerazTura;
|
||||||
|
Szachownica.KogoTerazTura = Kolor.NONE;
|
||||||
|
BlackTimer.Text = Black.FormatCzasu();
|
||||||
|
WhiteTimer.Text = White.FormatCzasu();
|
||||||
|
}
|
||||||
|
|
||||||
|
private struct CzasGraczy
|
||||||
|
{
|
||||||
|
public int sekundy;
|
||||||
|
public int minuty;
|
||||||
|
public CzasGraczy(int sekundy, int minuty) { this.sekundy = sekundy; this.minuty = minuty; }
|
||||||
|
public string FormatCzasu()
|
||||||
|
{
|
||||||
|
string Format(string czas)
|
||||||
|
{
|
||||||
|
if (czas.Length == 1)
|
||||||
|
{
|
||||||
|
czas = "0" + czas;
|
||||||
|
}
|
||||||
|
|
||||||
|
return czas;
|
||||||
|
}
|
||||||
|
if (sekundy >= 60)
|
||||||
|
{
|
||||||
|
sekundy = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (minuty >= 5)
|
||||||
|
{
|
||||||
|
minuty = 0;
|
||||||
|
sekundy = 0;
|
||||||
|
if (Szachownica.KogoTerazTura == Kolor.BLACK)
|
||||||
|
{
|
||||||
|
Szachownica.Window.GameState.Text = "Gracz bialy przegral na czas!";
|
||||||
|
Szachownica.Window.GameState.ForeColor = System.Drawing.Color.Firebrick;
|
||||||
|
Szachownica.Window.ZatrzymajZegar();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Szachownica.Window.GameState.Text = "Gracz czarny przegral na czas!";
|
||||||
|
Szachownica.Window.GameState.ForeColor = System.Drawing.Color.Firebrick;
|
||||||
|
Szachownica.Window.ZatrzymajZegar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Format(minuty.ToString()) + ":" + Format(sekundy.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,98 @@
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Chess
|
||||||
|
{
|
||||||
|
public enum RodzajFigury { King, Queen, Pawn, Bishop, Knight, Rook, EMPTY }
|
||||||
|
public struct Figura
|
||||||
|
{
|
||||||
|
public bool pierwszyRuch { get; set; }
|
||||||
|
public bool ruchODwaPola;
|
||||||
|
public RodzajFigury rodzajfigury { get; private set; }
|
||||||
|
public Kolor kolor;
|
||||||
|
private Pole[] polaAtakujace;
|
||||||
|
|
||||||
|
private void atak(Pole figuraPole)
|
||||||
|
{
|
||||||
|
Posuniecie posuniecie = new Posuniecie(figuraPole);
|
||||||
|
polaAtakujace = new Pole[posuniecie.mozliweRuchy.Length];
|
||||||
|
for (int ruch = 0; ruch < posuniecie.mozliweRuchy.Length; ruch++)
|
||||||
|
{
|
||||||
|
if (posuniecie.mozliweRuchy[ruch] == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (figuraPole.figura.rodzajfigury == RodzajFigury.Pawn)
|
||||||
|
{
|
||||||
|
if (ruch == 0 || ruch == 1)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Szachownica.pola[(int)posuniecie.mozliweRuchy[ruch]?.y, (int)posuniecie.mozliweRuchy[ruch]?.x].UstawAtak(figuraPole.figura);
|
||||||
|
polaAtakujace[ruch] = Szachownica.pola[(int)posuniecie.mozliweRuchy[ruch]?.y, (int)posuniecie.mozliweRuchy[ruch]?.x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void WyszyscPoprzednieAtaki()
|
||||||
|
{
|
||||||
|
for (int x = 0; x < 8; x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < 8; y++)
|
||||||
|
{
|
||||||
|
Szachownica.pola[y, x].UsunAtak();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void ZaaktualizujWszystkieAtaki()
|
||||||
|
{
|
||||||
|
WyszyscPoprzednieAtaki();
|
||||||
|
for (int x = 0; x < 8; x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < 8; y++)
|
||||||
|
{
|
||||||
|
if (Szachownica.pola[y, x].jestZajete() && Szachownica.pola[y, x].figura.kolor != Szachownica.KogoTerazTura)
|
||||||
|
{
|
||||||
|
Szachownica.pola[y, x].figura.atak(Szachownica.pola[y, x]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string NazwaObrazu()
|
||||||
|
{
|
||||||
|
string name = "";
|
||||||
|
if (kolor != Kolor.NONE)
|
||||||
|
{
|
||||||
|
name = kolor == Kolor.BLACK ? "B" : "W";
|
||||||
|
}
|
||||||
|
|
||||||
|
return name + rodzajfigury.ToString();
|
||||||
|
}
|
||||||
|
public Figura(RodzajFigury rodzajfigury = RodzajFigury.EMPTY, Kolor kolor = Kolor.NONE, bool ruchODwaPola = false, bool pierwszyRuch = false)
|
||||||
|
{
|
||||||
|
polaAtakujace = new Pole[32];
|
||||||
|
this.pierwszyRuch = true;
|
||||||
|
this.ruchODwaPola = ruchODwaPola;
|
||||||
|
this.rodzajfigury = rodzajfigury;
|
||||||
|
this.kolor = kolor;
|
||||||
|
if (rodzajfigury == RodzajFigury.EMPTY)
|
||||||
|
{
|
||||||
|
this.pierwszyRuch = pierwszyRuch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public Figura(string key, Pole pole) : this(RodzajFigury.Queen)
|
||||||
|
{
|
||||||
|
kolor = key.First() == 'B' ? Kolor.BLACK : Kolor.WHITE;
|
||||||
|
key = key.Remove(0, 1);
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case "Bishop": rodzajfigury = RodzajFigury.Bishop; break;
|
||||||
|
case "Rook": rodzajfigury = RodzajFigury.Rook; break;
|
||||||
|
case "Queen": rodzajfigury = RodzajFigury.Queen; break;
|
||||||
|
case "Knight": rodzajfigury = RodzajFigury.Knight; break;
|
||||||
|
}
|
||||||
|
pole.FiguraObraz.BackgroundImage = Pole.FiguryObrazy[NazwaObrazu()];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,119 @@
|
||||||
|
namespace Chess
|
||||||
|
{
|
||||||
|
partial class WybranieFigury
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.RightArrow = new System.Windows.Forms.Button();
|
||||||
|
this.ApplyButton = new System.Windows.Forms.Button();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.LeftArrow = new System.Windows.Forms.Button();
|
||||||
|
this.Preview = new System.Windows.Forms.PictureBox();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.Preview)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// RightArrow
|
||||||
|
//
|
||||||
|
this.RightArrow.Location = new System.Drawing.Point(92, 55);
|
||||||
|
this.RightArrow.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||||
|
this.RightArrow.Name = "RightArrow";
|
||||||
|
this.RightArrow.Size = new System.Drawing.Size(25, 19);
|
||||||
|
this.RightArrow.TabIndex = 1;
|
||||||
|
this.RightArrow.Text = ">";
|
||||||
|
this.RightArrow.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// ApplyButton
|
||||||
|
//
|
||||||
|
this.ApplyButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||||
|
this.ApplyButton.Location = new System.Drawing.Point(11, 110);
|
||||||
|
this.ApplyButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||||
|
this.ApplyButton.Name = "ApplyButton";
|
||||||
|
this.ApplyButton.Size = new System.Drawing.Size(106, 21);
|
||||||
|
this.ApplyButton.TabIndex = 3;
|
||||||
|
this.ApplyButton.Text = "Wybierz!";
|
||||||
|
this.ApplyButton.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.label1.Location = new System.Drawing.Point(24, 7);
|
||||||
|
this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(91, 13);
|
||||||
|
this.label1.TabIndex = 4;
|
||||||
|
this.label1.Text = "Wybierz Figure";
|
||||||
|
//
|
||||||
|
// LeftArrow
|
||||||
|
//
|
||||||
|
this.LeftArrow.Location = new System.Drawing.Point(14, 55);
|
||||||
|
this.LeftArrow.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||||
|
this.LeftArrow.Name = "LeftArrow";
|
||||||
|
this.LeftArrow.Size = new System.Drawing.Size(25, 19);
|
||||||
|
this.LeftArrow.TabIndex = 5;
|
||||||
|
this.LeftArrow.Text = "<";
|
||||||
|
this.LeftArrow.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// Preview
|
||||||
|
//
|
||||||
|
this.Preview.Location = new System.Drawing.Point(43, 42);
|
||||||
|
this.Preview.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||||
|
this.Preview.Name = "Preview";
|
||||||
|
this.Preview.Size = new System.Drawing.Size(45, 49);
|
||||||
|
this.Preview.TabIndex = 2;
|
||||||
|
this.Preview.TabStop = false;
|
||||||
|
//
|
||||||
|
// WybranieFigury
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(131, 144);
|
||||||
|
this.Controls.Add(this.LeftArrow);
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.Controls.Add(this.ApplyButton);
|
||||||
|
this.Controls.Add(this.Preview);
|
||||||
|
this.Controls.Add(this.RightArrow);
|
||||||
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||||
|
this.MaximumSize = new System.Drawing.Size(147, 183);
|
||||||
|
this.MinimumSize = new System.Drawing.Size(147, 183);
|
||||||
|
this.Name = "WybranieFigury";
|
||||||
|
this.ShowIcon = false;
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.Preview)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
private System.Windows.Forms.Button RightArrow;
|
||||||
|
private System.Windows.Forms.PictureBox Preview;
|
||||||
|
private System.Windows.Forms.Button ApplyButton;
|
||||||
|
private System.Windows.Forms.Label label1;
|
||||||
|
private System.Windows.Forms.Button LeftArrow;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
using System;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Chess
|
||||||
|
{
|
||||||
|
public partial class WybranieFigury : Form
|
||||||
|
{
|
||||||
|
private WybranieFigury()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
LeftArrow.Click += ButtonClick;
|
||||||
|
RightArrow.Click += ButtonClick;
|
||||||
|
ApplyButton.Click += ButtonClick;
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly Pole clickedTile;
|
||||||
|
private int position = 0;
|
||||||
|
private readonly string[] keys = { "BQueen", "BBishop", "BRook", "BKnight" };
|
||||||
|
private readonly Kolor waitingPlayer;
|
||||||
|
public static bool waiting { get; private set; } = false;
|
||||||
|
public WybranieFigury(Pole clickedTile) : this()
|
||||||
|
{
|
||||||
|
waiting = true;
|
||||||
|
waitingPlayer = Szachownica.KogoTerazTura == Kolor.WHITE ? Kolor.BLACK : Kolor.WHITE;
|
||||||
|
Szachownica.KogoTerazTura = Kolor.NONE;
|
||||||
|
this.clickedTile = clickedTile;
|
||||||
|
if (clickedTile.GetY == 0)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < keys.Length; i++)
|
||||||
|
{
|
||||||
|
keys[i] = keys[i].Remove(0, 1);
|
||||||
|
keys[i] = 'W' + keys[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Preview.Image = Pole.FiguryObrazy[keys[position]];
|
||||||
|
}
|
||||||
|
public void ButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
switch (((Button)sender).Name)
|
||||||
|
{
|
||||||
|
case "RightArrow": position++; break;
|
||||||
|
case "LeftArrow": position--; break;
|
||||||
|
default: Close(); break;
|
||||||
|
}
|
||||||
|
if (position < 0)
|
||||||
|
{
|
||||||
|
position = keys.Length - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (position > keys.Length - 1)
|
||||||
|
{
|
||||||
|
position = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Preview.Image = Pole.FiguryObrazy[keys[position]];
|
||||||
|
}
|
||||||
|
protected override void OnClosed(EventArgs e)
|
||||||
|
{
|
||||||
|
waiting = false;
|
||||||
|
clickedTile.figura = new Figura(keys[position], clickedTile);
|
||||||
|
Szachownica.KogoTerazTura = waitingPlayer;
|
||||||
|
Figura.ZaaktualizujWszystkieAtaki();
|
||||||
|
Posuniecie Search = new Posuniecie();
|
||||||
|
if (Search.SyndromOblezonejTwierdzy())
|
||||||
|
{
|
||||||
|
Szachownica.Window.GameState.Text = "CHECK";
|
||||||
|
Szachownica.Window.GameState.ForeColor = System.Drawing.Color.Firebrick;
|
||||||
|
Szachownica.Window.GameState.Visible = true;
|
||||||
|
}
|
||||||
|
_ = Search.Mat();
|
||||||
|
base.OnClosed(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,120 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
|
@ -0,0 +1,358 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Chess
|
||||||
|
{
|
||||||
|
public class Posuniecie
|
||||||
|
{
|
||||||
|
private Pole figuraPole;
|
||||||
|
public RuchFigury?[] mozliweRuchy;
|
||||||
|
public Posuniecie() { poprzedniRuchy = new RuchFigury(1, 1); }
|
||||||
|
public Posuniecie(Pole figuraPole) : this()
|
||||||
|
{
|
||||||
|
this.figuraPole = figuraPole;
|
||||||
|
mozliweRuchy = Ruchy();
|
||||||
|
}
|
||||||
|
public bool jestRuchMozliwy(Pole wybranePole)
|
||||||
|
{
|
||||||
|
InterfejsObslugiPoprzednichRuchow(false);
|
||||||
|
for (int ruch = 0; ruch < mozliweRuchy.Length; ruch++)
|
||||||
|
{
|
||||||
|
if (mozliweRuchy[ruch] == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mozliweRuchy[ruch]?.x == wybranePole.lokalizacja.x && mozliweRuchy[ruch]?.y == wybranePole.lokalizacja.y)
|
||||||
|
{
|
||||||
|
if (!ACzyMoznaSieRuszyc(ruch, wybranePole))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Szachownica.poprzednieRuchy.Add(new PoprzedniStanSzachownicy(figuraPole.figura, figuraPole.lokalizacja, (RuchFigury)mozliweRuchy[ruch], wybranePole.figura, ruch));
|
||||||
|
figuraPole.figura.pierwszyRuch = false;
|
||||||
|
wybranePole.PrzydzialFigur(figuraPole.figura);
|
||||||
|
figuraPole.PrzydzialFigur(new Figura(RodzajFigury.EMPTY));
|
||||||
|
if (!WybranieFigury.waiting)
|
||||||
|
{
|
||||||
|
Szachownica.KogoTerazTura = Szachownica.KogoTerazTura == Kolor.WHITE ? Kolor.BLACK : Kolor.WHITE;
|
||||||
|
Figura.ZaaktualizujWszystkieAtaki();
|
||||||
|
if (SyndromOblezonejTwierdzy())
|
||||||
|
{
|
||||||
|
Szachownica.Window.GameState.Text = "Szach";
|
||||||
|
Szachownica.Window.GameState.ForeColor = System.Drawing.Color.Firebrick;
|
||||||
|
_ = Mat();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Szachownica.Window.GameState.Text = "";
|
||||||
|
Szachownica.Window.GameState.ForeColor = System.Drawing.Color.OliveDrab;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public void InterfejsObslugiPoprzednichRuchow(bool show)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < mozliweRuchy.Length; i++)
|
||||||
|
{
|
||||||
|
if (mozliweRuchy[i] == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (figuraPole.figura.rodzajfigury == RodzajFigury.Pawn && ((i == 2 && nieJestZajetePole(figuraPole.lokalizacja.y + dir, figuraPole.lokalizacja.x + 1))
|
||||||
|
|| (i == 3 && nieJestZajetePole(figuraPole.lokalizacja.y + dir, figuraPole.lokalizacja.x - 1))))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Szachownica.pola[(int)mozliweRuchy[i]?.y, (int)mozliweRuchy[i]?.x].PossibleMove(show);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public bool SyndromOblezonejTwierdzy()
|
||||||
|
{
|
||||||
|
return Szachownica.JakieToPole(RodzajFigury.King, Szachownica.KogoTerazTura).atakNaPole != Kolor.NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Mat()
|
||||||
|
{
|
||||||
|
List<Pole> figuraPola = Szachownica.ZbierzWszystkieFiguryPola(Szachownica.KogoTerazTura);
|
||||||
|
for (int j = 0; j < figuraPola.Count; j++)
|
||||||
|
{
|
||||||
|
figuraPole = figuraPola[j];
|
||||||
|
mozliweRuchy = Ruchy();
|
||||||
|
if (CzyKrolJestBezpieczny())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Szachownica.Window.GameState.Text = "Mat!";
|
||||||
|
Szachownica.Window.GameState.ForeColor = System.Drawing.Color.Firebrick;
|
||||||
|
Szachownica.Window.ZatrzymajZegar();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool CzyKrolJestBezpieczny()
|
||||||
|
{
|
||||||
|
for (int ruch = 0; ruch < mozliweRuchy.Length; ruch++)
|
||||||
|
{
|
||||||
|
if (mozliweRuchy[ruch] == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!MoznaSieRuszac((int)mozliweRuchy[ruch]?.y, (int)mozliweRuchy[ruch]?.x))
|
||||||
|
{
|
||||||
|
mozliweRuchy[ruch] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < mozliweRuchy.Length; i++)
|
||||||
|
{
|
||||||
|
if (mozliweRuchy[i].HasValue)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool MoznaSieRuszac(int y, int x)
|
||||||
|
{
|
||||||
|
Figura poprzedniePoleFigury = Szachownica.pola[y, x].figura;
|
||||||
|
Szachownica.pola[y, x].figura = figuraPole.figura;
|
||||||
|
figuraPole.figura = new Figura(RodzajFigury.EMPTY);
|
||||||
|
Figura.ZaaktualizujWszystkieAtaki();
|
||||||
|
if (!SyndromOblezonejTwierdzy())
|
||||||
|
{
|
||||||
|
figuraPole.figura = Szachownica.pola[y, x].figura;
|
||||||
|
Szachownica.pola[y, x].figura = poprzedniePoleFigury;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
figuraPole.figura = Szachownica.pola[y, x].figura;
|
||||||
|
Szachownica.pola[y, x].figura = poprzedniePoleFigury;
|
||||||
|
Figura.ZaaktualizujWszystkieAtaki();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool ACzyMoznaSieRuszyc(int move, Pole kliknietePole)
|
||||||
|
{
|
||||||
|
switch (figuraPole.figura.rodzajfigury)
|
||||||
|
{
|
||||||
|
case RodzajFigury.Pawn:
|
||||||
|
figuraPole.figura.ruchODwaPola = move == 1;
|
||||||
|
if (move == 2 && nieJestZajetePole(figuraPole.lokalizacja.y + dir, figuraPole.lokalizacja.x + 1))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (move == 3 && nieJestZajetePole(figuraPole.lokalizacja.y + dir, figuraPole.lokalizacja.x - 1))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (move == 4 || move == 5)
|
||||||
|
{
|
||||||
|
int xdir = move == 4 ? 1 : -1;
|
||||||
|
Szachownica.pola[figuraPole.GetY, figuraPole.GetX + xdir].PrzydzialFigur(new Figura(RodzajFigury.EMPTY)); return true;
|
||||||
|
}
|
||||||
|
if ((figuraPole.GetY == 1 && figuraPole.figura.kolor == Kolor.WHITE) || (figuraPole.GetY == 6 && figuraPole.figura.kolor == Kolor.BLACK))
|
||||||
|
{
|
||||||
|
WybranieFigury pieceSelection = new WybranieFigury(kliknietePole);
|
||||||
|
pieceSelection.Show();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case RodzajFigury.King:
|
||||||
|
int ydir = Szachownica.KogoTerazTura == Kolor.WHITE ? 7 : 0;
|
||||||
|
void castle(int tilex, int piecex)
|
||||||
|
{
|
||||||
|
Szachownica.pola[ydir, tilex].PrzydzialFigur(Szachownica.JakaToFigura(ydir, piecex));
|
||||||
|
Szachownica.pola[ydir, piecex].PrzydzialFigur(new Figura(RodzajFigury.EMPTY));
|
||||||
|
}
|
||||||
|
if (move == 8)
|
||||||
|
{
|
||||||
|
castle(5, 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (move == 9)
|
||||||
|
{
|
||||||
|
castle(3, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private RuchFigury? poprzedniRuchy;
|
||||||
|
private int move;
|
||||||
|
|
||||||
|
private RuchFigury?[] Ruchy()
|
||||||
|
{
|
||||||
|
RuchFigury?[] ruchy = new RuchFigury?[8];
|
||||||
|
move = 0;
|
||||||
|
switch (figuraPole.figura.rodzajfigury)
|
||||||
|
{
|
||||||
|
case RodzajFigury.Bishop: ruchy = new RuchFigury?[32]; RuchLiniowy(ruchy, false); break;
|
||||||
|
case RodzajFigury.Knight:
|
||||||
|
ruchy[0] = destynacja(2, -1);
|
||||||
|
ruchy[1] = destynacja(2, 1);
|
||||||
|
ruchy[2] = destynacja(-2, 1);
|
||||||
|
ruchy[3] = destynacja(-2, -1);
|
||||||
|
ruchy[4] = destynacja(1, -2);
|
||||||
|
ruchy[5] = destynacja(1, 2);
|
||||||
|
ruchy[6] = destynacja(-1, -2);
|
||||||
|
ruchy[7] = destynacja(-1, 2);
|
||||||
|
break;
|
||||||
|
case RodzajFigury.Queen:
|
||||||
|
ruchy = new RuchFigury?[64];
|
||||||
|
RuchLiniowy(ruchy, false);
|
||||||
|
poprzedniRuchy = new RuchFigury(1, 1);
|
||||||
|
RuchLiniowy(ruchy, true);
|
||||||
|
break;
|
||||||
|
case RodzajFigury.Rook: ruchy = new RuchFigury?[32]; RuchLiniowy(ruchy, true); break;
|
||||||
|
case RodzajFigury.King:
|
||||||
|
ruchy = new RuchFigury?[10];
|
||||||
|
ruchy[0] = destynacja(1, -1);
|
||||||
|
ruchy[1] = destynacja(1, 1);
|
||||||
|
ruchy[2] = destynacja(-1, 1);
|
||||||
|
ruchy[3] = destynacja(-1, -1);
|
||||||
|
ruchy[4] = destynacja(1, 0);
|
||||||
|
ruchy[5] = destynacja(-1, 0);
|
||||||
|
ruchy[6] = destynacja(0, -1);
|
||||||
|
ruchy[7] = destynacja(0, 1);
|
||||||
|
bool CanCastle(int dir)
|
||||||
|
{
|
||||||
|
int range = dir == 1 ? 3 : 4;
|
||||||
|
for (int i = 1; i < range; i++)
|
||||||
|
{
|
||||||
|
if (jestZajete(figuraPole.GetY, figuraPole.GetX + (i * dir)) ||
|
||||||
|
(Szachownica.pola[figuraPole.GetY, figuraPole.GetX + (i * dir)].atakNaPole != Kolor.NONE))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (figuraPole.figura.pierwszyRuch && Szachownica.JakaToFigura(figuraPole.GetY, figuraPole.GetX + 3).pierwszyRuch) //right castling
|
||||||
|
{
|
||||||
|
ruchy[8] = CanCastle(1) ? destynacja(0, 2) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (figuraPole.figura.pierwszyRuch && Szachownica.JakaToFigura(figuraPole.GetY, figuraPole.GetX - 4).pierwszyRuch) //left castling
|
||||||
|
{
|
||||||
|
ruchy[9] = CanCastle(-1) ? destynacja(0, -2) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case RodzajFigury.Pawn:
|
||||||
|
ruchy = new RuchFigury?[6];
|
||||||
|
ruchy[0] = nieJestZajetePole(figuraPole.lokalizacja.y + (1 * dir), figuraPole.lokalizacja.x) ? destynacja(1 * dir, 0) : poprzedniRuchy = null;
|
||||||
|
if (poprzedniRuchy != null)
|
||||||
|
{
|
||||||
|
ruchy[1] = nieJestZajetePole(figuraPole.GetY + (2 * dir), figuraPole.GetX) && figuraPole.figura.pierwszyRuch ? destynacja(2 * dir, 0) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ruchy[2] = destynacja(dir, 1);
|
||||||
|
ruchy[3] = destynacja(dir, -1);
|
||||||
|
ruchy[4] = czyJestPionemPrzeciwnika(figuraPole.GetY, figuraPole.GetX + 1) && !jestZajete(figuraPole.GetY + dir, figuraPole.GetX + 1) ? destynacja(dir, 1) : null;
|
||||||
|
ruchy[5] = czyJestPionemPrzeciwnika(figuraPole.GetY, figuraPole.GetX - 1) && !jestZajete(figuraPole.GetY + dir, figuraPole.GetX - 1) ? destynacja(dir, -1) : null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return ruchy;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int dir => figuraPole.figura.kolor == Kolor.BLACK ? 1 : -1;
|
||||||
|
|
||||||
|
private void RuchLiniowy(RuchFigury?[] ruchy, bool liniaProsta)
|
||||||
|
{
|
||||||
|
int rookDir = liniaProsta ? 0 : 1; int bishopDir = liniaProsta ? 1 : -1;
|
||||||
|
for (int i = 1; i < 9; i++)
|
||||||
|
{
|
||||||
|
ruchy[move] = destynacjaLiniowa(-i, i * bishopDir * rookDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
poprzedniRuchy = new RuchFigury(1, 1); for (int i = 1; i < 9; i++)
|
||||||
|
{
|
||||||
|
ruchy[move] = destynacjaLiniowa(i, i * rookDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
poprzedniRuchy = new RuchFigury(1, 1); for (int i = 1; i < 9; i++)
|
||||||
|
{
|
||||||
|
ruchy[move] = destynacjaLiniowa(i * rookDir, -i);
|
||||||
|
}
|
||||||
|
|
||||||
|
poprzedniRuchy = new RuchFigury(1, 1); for (int i = 1; i < 9; i++)
|
||||||
|
{
|
||||||
|
ruchy[move] = destynacjaLiniowa(i * bishopDir * rookDir, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private RuchFigury? destynacjaLiniowa(int y, int x)
|
||||||
|
{
|
||||||
|
return poprzedniRuchy == null ? null : destynacja(y, x);
|
||||||
|
}
|
||||||
|
|
||||||
|
private RuchFigury? destynacja(int y, int x)
|
||||||
|
{
|
||||||
|
int LokacjaY = figuraPole.lokalizacja.y + y;
|
||||||
|
int LokacjaX = figuraPole.lokalizacja.x + x;
|
||||||
|
move++;
|
||||||
|
if (czyDostepUdzielony(LokacjaY, LokacjaX))
|
||||||
|
{
|
||||||
|
if (jestZajete(LokacjaY, LokacjaX) && figuraPole.figura.kolor != KolorPrzeciwnika(LokacjaY, LokacjaX))
|
||||||
|
{
|
||||||
|
poprzedniRuchy = null;
|
||||||
|
return new RuchFigury(LokacjaY, LokacjaX);
|
||||||
|
}
|
||||||
|
return jestZajete(LokacjaY, LokacjaX) ? (poprzedniRuchy = null) : (poprzedniRuchy = new RuchFigury(LokacjaY, LokacjaX));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return poprzedniRuchy = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool czyDostepUdzielony(int y, int x)
|
||||||
|
{
|
||||||
|
return Szachownica.czyMoznaWbic(y, x);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool jestZajete(int y, int x)
|
||||||
|
{
|
||||||
|
return Szachownica.pola[y, x].jestZajete();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool czyJestPionemPrzeciwnika(int y, int x)
|
||||||
|
{
|
||||||
|
return czyDostepUdzielony(y, x)
|
||||||
|
&& jestZajete(y, x) && Szachownica.JakaToFigura(y, x).ruchODwaPola && jestPrzeciwnegoKoloru(y, x);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool nieJestZajetePole(int y, int x)
|
||||||
|
{
|
||||||
|
return czyDostepUdzielony(y, x) && !jestZajete(y, x);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool jestPrzeciwnegoKoloru(int y, int x)
|
||||||
|
{
|
||||||
|
return figuraPole.figura.kolor != KolorPrzeciwnika(y, x) && KolorPrzeciwnika(y, x) != Kolor.NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Kolor KolorPrzeciwnika(int y, int x)
|
||||||
|
{
|
||||||
|
return Szachownica.pola[y, x].figura.kolor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public struct RuchFigury
|
||||||
|
{
|
||||||
|
public int y, x;
|
||||||
|
public RuchFigury(int y, int x) { this.y = y; this.x = x; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
using System;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Chess
|
||||||
|
{
|
||||||
|
internal static class Program
|
||||||
|
{
|
||||||
|
[STAThread]
|
||||||
|
private static void Main()
|
||||||
|
{
|
||||||
|
Application.EnableVisualStyles();
|
||||||
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
Application.Run(new Szachy());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("Chess")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Chess")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("d2367663-b1d6-4c08-b870-0c5b4a056e9a")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,253 @@
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Ten kod został wygenerowany przez narzędzie.
|
||||||
|
// Wersja wykonawcza:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Zmiany w tym pliku mogą spowodować nieprawidłowe zachowanie i zostaną utracone, jeśli
|
||||||
|
// kod zostanie ponownie wygenerowany.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace Chess.Properties {
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Klasa zasobu wymagająca zdefiniowania typu do wyszukiwania zlokalizowanych ciągów itd.
|
||||||
|
/// </summary>
|
||||||
|
// Ta klasa została automatycznie wygenerowana za pomocą klasy StronglyTypedResourceBuilder
|
||||||
|
// przez narzędzie, takie jak ResGen lub Visual Studio.
|
||||||
|
// Aby dodać lub usunąć składową, edytuj plik ResX, a następnie ponownie uruchom narzędzie ResGen
|
||||||
|
// z opcją /str lub ponownie utwórz projekt VS.
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.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() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Zwraca buforowane wystąpienie ResourceManager używane przez tę klasę.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
|
get {
|
||||||
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Chess.Properties.Resources", typeof(Resources).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Przesłania właściwość CurrentUICulture bieżącego wątku dla wszystkich
|
||||||
|
/// przypadków przeszukiwania zasobów za pomocą tej klasy zasobów wymagającej zdefiniowania typu.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
|
get {
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wyszukuje zlokalizowany zasób typu System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap Black_Bishop {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("Black_Bishop", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wyszukuje zlokalizowany zasób typu System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap Black_King {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("Black_King", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wyszukuje zlokalizowany zasób typu System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap Black_Knight {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("Black_Knight", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wyszukuje zlokalizowany zasób typu System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap Black_Pawn {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("Black_Pawn", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wyszukuje zlokalizowany zasób typu System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap Black_Queen {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("Black_Queen", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wyszukuje zlokalizowany zasób typu System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap Black_Rook {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("Black_Rook", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wyszukuje zlokalizowany zasób typu System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap CantRedo {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("CantRedo", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wyszukuje zlokalizowany zasób typu System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap ChessFrames {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("ChessFrames", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wyszukuje zlokalizowany zasób typu System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap OLDPaper2 {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("OLDPaper2", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wyszukuje zlokalizowany zasób typu System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap PossibleMove {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("PossibleMove", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wyszukuje zlokalizowany zasób typu System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap redoArrow {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("redoArrow", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wyszukuje zlokalizowany zasób typu System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap undoArrrow {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("undoArrrow", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wyszukuje zlokalizowany zasób typu System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap undoArrrowClicked {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("undoArrrowClicked", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wyszukuje zlokalizowany zasób typu System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap White_Bishop {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("White_Bishop", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wyszukuje zlokalizowany zasób typu System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap White_Pawn {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("White_Pawn", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wyszukuje zlokalizowany zasób typu System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap White_Queen {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("White_Queen", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wyszukuje zlokalizowany zasób typu System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap White_Rook {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("White_Rook", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wyszukuje zlokalizowany zasób typu System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap WKing {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("WKing", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wyszukuje zlokalizowany zasób typu System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap WKnight {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("WKnight", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,178 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||||
|
<data name="Black_Rook" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\BRook.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="White_Queen" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\WQueen.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="Black_King" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\BKing.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="WKnight" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\WKnight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="White_Rook" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\WRook.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="PossibleMove" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\PossibleMove.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="Black_Queen" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\BQueen.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="WKing" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\WKing.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="OLDPaper2" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\OLDPaper2.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="Black_Bishop" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\BBishop.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="White_Bishop" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\WBishop.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="Black_Pawn" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\BPawn.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="ChessFrames" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\ChessFrames.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="undoArrrow" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\undoArrrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="White_Pawn" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\WPawn.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="redoArrow" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\redoArrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="Black_Knight" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\BKnight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="CantRedo" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\CantRedo.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="undoArrrowClicked" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\undoArrrowClicked.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
</root>
|
|
@ -0,0 +1,30 @@
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// 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.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace Chess.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||||
|
<Profiles>
|
||||||
|
<Profile Name="(Default)" />
|
||||||
|
</Profiles>
|
||||||
|
<Settings />
|
||||||
|
</SettingsFile>
|
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 6.2 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 1.5 MiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 5.7 KiB |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 5.6 KiB |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 6.3 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 5.4 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 6.3 KiB |
After Width: | Height: | Size: 6.9 KiB |
|
@ -0,0 +1,120 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Chess
|
||||||
|
{
|
||||||
|
internal class Szachownica
|
||||||
|
{
|
||||||
|
public static Pole[,] pola = new Pole[8, 8];
|
||||||
|
public static Kolor KogoTerazTura = Kolor.WHITE;
|
||||||
|
public static Szachy Window;
|
||||||
|
public static List<PoprzedniStanSzachownicy> poprzednieRuchy = new List<PoprzedniStanSzachownicy>();
|
||||||
|
public static Figura JakaToFigura(int y, int x)
|
||||||
|
{
|
||||||
|
return pola[y, x].figura;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Pole> ZbierzWszystkieFiguryPola(Kolor kolor)
|
||||||
|
{
|
||||||
|
List<Pole> wszystkieFigury = new List<Pole>();
|
||||||
|
for (int x = 0; x < 8; x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < 8; y++)
|
||||||
|
{
|
||||||
|
if (JakaToFigura(y, x).kolor == kolor)
|
||||||
|
{
|
||||||
|
wszystkieFigury.Add(pola[y, x]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return wszystkieFigury;
|
||||||
|
}
|
||||||
|
public static Pole JakieToPole(RodzajFigury rodzajfigury, Kolor kolor)
|
||||||
|
{
|
||||||
|
for (byte x = 0; x < 8; x++)
|
||||||
|
{
|
||||||
|
for (byte y = 0; y < 8; y++)
|
||||||
|
{
|
||||||
|
if (JakaToFigura(y, x).rodzajfigury == rodzajfigury && JakaToFigura(y, x).kolor == kolor)
|
||||||
|
{
|
||||||
|
return pola[y, x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public Szachownica(Szachy glowneOkno)
|
||||||
|
{
|
||||||
|
Window = glowneOkno;
|
||||||
|
byte rzedy = 0;
|
||||||
|
for (byte x = 0; x < 8; x++, rzedy++)
|
||||||
|
{
|
||||||
|
for (byte y = 0; y < 8; y++, rzedy++)
|
||||||
|
{
|
||||||
|
Pole PoprawnePole()
|
||||||
|
{
|
||||||
|
return rzedy % 2 == 0 ? new Pole(y, x, Kolor.WHITE) : new Pole(y, x, Kolor.BLACK);
|
||||||
|
}
|
||||||
|
|
||||||
|
pola[y, x] = PoprawnePole();
|
||||||
|
glowneOkno.Controls.Add(pola[y, x]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UstawSzachownice(0, Kolor.BLACK);
|
||||||
|
UstawSzachownice(7, Kolor.WHITE);
|
||||||
|
for (int x = 0; x < 8; x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < 8; y++)
|
||||||
|
{
|
||||||
|
if (pola[y, x].figura.rodzajfigury != RodzajFigury.EMPTY)
|
||||||
|
{
|
||||||
|
pola[y, x].FiguraObraz.BackgroundImage = Pole.FiguryObrazy[pola[y, x].figura.NazwaObrazu()];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static bool czyMoznaWbic(int y, int x)
|
||||||
|
{
|
||||||
|
return y < 8 && y >= 0 && x < 8 && x >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UstawSzachownice(int y, Kolor kolor)
|
||||||
|
{
|
||||||
|
pola[y, 0].figura = new Figura(RodzajFigury.Rook, kolor);
|
||||||
|
pola[y, 1].figura = new Figura(RodzajFigury.Knight, kolor);
|
||||||
|
pola[y, 2].figura = new Figura(RodzajFigury.Bishop, kolor);
|
||||||
|
pola[y, 3].figura = new Figura(RodzajFigury.Queen, kolor);
|
||||||
|
pola[y, 4].figura = new Figura(RodzajFigury.King, kolor);
|
||||||
|
pola[y, 5].figura = new Figura(RodzajFigury.Bishop, kolor);
|
||||||
|
pola[y, 6].figura = new Figura(RodzajFigury.Knight, kolor);
|
||||||
|
pola[y, 7].figura = new Figura(RodzajFigury.Rook, kolor);
|
||||||
|
y += y == 0 ? 1 : -1;
|
||||||
|
for (int x = 0; x < 8; x++)
|
||||||
|
{
|
||||||
|
pola[y, x].figura = new Figura(RodzajFigury.Pawn, kolor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal struct PoprzedniStanSzachownicy
|
||||||
|
{
|
||||||
|
public Figura usunieteFigury { get; private set; }
|
||||||
|
public RuchFigury ruch { get; private set; }
|
||||||
|
public Figura figura { get; private set; }
|
||||||
|
public Lokalizacja poprzedniaLokalizacja { get; private set; }
|
||||||
|
public int indexRuchu;
|
||||||
|
public PoprzedniStanSzachownicy(Figura figura, int indexRuchu, Lokalizacja poprzedniaLokalizacja, RuchFigury ruch)
|
||||||
|
{
|
||||||
|
this.figura = figura;
|
||||||
|
this.indexRuchu = indexRuchu;
|
||||||
|
this.poprzedniaLokalizacja = poprzedniaLokalizacja;
|
||||||
|
usunieteFigury = new Figura(RodzajFigury.EMPTY);
|
||||||
|
this.ruch = ruch;
|
||||||
|
}
|
||||||
|
public PoprzedniStanSzachownicy(Figura figura, Lokalizacja lokalizacja, RuchFigury ruch, Figura usunietaFigura, int indexRuchu) : this(figura, indexRuchu, lokalizacja, ruch)
|
||||||
|
{
|
||||||
|
usunieteFigury = usunietaFigura;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
namespace Chess
|
||||||
|
{
|
||||||
|
partial class Pole
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Component Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.FiguraObraz = new System.Windows.Forms.PictureBox();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.FiguraObraz)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// FiguraObraz
|
||||||
|
//
|
||||||
|
this.FiguraObraz.BackColor = System.Drawing.Color.White;
|
||||||
|
this.FiguraObraz.ErrorImage = null;
|
||||||
|
this.FiguraObraz.InitialImage = null;
|
||||||
|
this.FiguraObraz.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.FiguraObraz.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||||
|
this.FiguraObraz.MaximumSize = new System.Drawing.Size(100, 100);
|
||||||
|
this.FiguraObraz.MinimumSize = new System.Drawing.Size(48, 52);
|
||||||
|
this.FiguraObraz.Name = "FiguraObraz";
|
||||||
|
this.FiguraObraz.Size = new System.Drawing.Size(48, 52);
|
||||||
|
this.FiguraObraz.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
|
||||||
|
this.FiguraObraz.TabIndex = 0;
|
||||||
|
this.FiguraObraz.TabStop = false;
|
||||||
|
//
|
||||||
|
// Pole
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.Controls.Add(this.FiguraObraz);
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||||
|
this.Name = "Pole";
|
||||||
|
this.Size = new System.Drawing.Size(48, 52);
|
||||||
|
this.Load += new System.EventHandler(this.Tile_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.FiguraObraz)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public System.Windows.Forms.PictureBox FiguraObraz;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Chess
|
||||||
|
{
|
||||||
|
public enum Kolor { WHITE, BLACK, NONE }
|
||||||
|
public partial class Pole : UserControl
|
||||||
|
{
|
||||||
|
public Figura figura = new Figura(RodzajFigury.EMPTY);
|
||||||
|
public Kolor kolor = Kolor.WHITE;
|
||||||
|
public Lokalizacja lokalizacja = new Lokalizacja();
|
||||||
|
public Kolor atakNaPole = Kolor.NONE;
|
||||||
|
public void UstawAtak(Figura figuraAtak) { atakNaPole = figuraAtak.kolor; }
|
||||||
|
public void UsunAtak() { atakNaPole = Kolor.NONE; }
|
||||||
|
|
||||||
|
public byte GetY => lokalizacja.y;
|
||||||
|
public byte GetX => lokalizacja.x;
|
||||||
|
public bool jestZajete()
|
||||||
|
{
|
||||||
|
return figura.rodzajfigury != RodzajFigury.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pole(byte y, byte x) { InitializeComponent(); lokalizacja.y = y; lokalizacja.x = x; Location = new Point(x * Size.Width, y * Size.Height); }
|
||||||
|
public Pole(byte y, byte x, Kolor kolor) : this(y, x) { this.kolor = kolor; }
|
||||||
|
public Color KolorPola()
|
||||||
|
{
|
||||||
|
return kolor != Kolor.WHITE ? Color.DarkOliveGreen : Color.WhiteSmoke;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PrzydzialFigur(Figura figura)
|
||||||
|
{
|
||||||
|
this.figura = figura;
|
||||||
|
FiguraObraz.BackgroundImageLayout = ImageLayout.Center;
|
||||||
|
FiguraObraz.BackgroundImage = FiguryObrazy[figura.NazwaObrazu()];
|
||||||
|
FiguraObraz.Size = new Size(Size.Width / 2, Size.Height / 2);
|
||||||
|
}
|
||||||
|
private void Tile_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
FiguraObraz.BackColor = KolorPola();
|
||||||
|
BackColor = KolorPola();
|
||||||
|
Click += KliknietoNaPole;
|
||||||
|
FiguraObraz.Click += KliknietoNaPole;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int click = 0;
|
||||||
|
private static Posuniecie ruchyfigur;
|
||||||
|
public void PossibleMove(bool show)
|
||||||
|
{
|
||||||
|
FiguraObraz.Image = !show ? null : (Image)Properties.Resources.PossibleMove;
|
||||||
|
}
|
||||||
|
private void KliknietoNaPole(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (click == 0 && figura.kolor != Szachownica.KogoTerazTura)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
click++;
|
||||||
|
if (click == 1)
|
||||||
|
{
|
||||||
|
ruchyfigur = new Posuniecie(this);
|
||||||
|
_ = ruchyfigur.CzyKrolJestBezpieczny();
|
||||||
|
ruchyfigur.InterfejsObslugiPoprzednichRuchow(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_ = ruchyfigur.jestRuchMozliwy(this);
|
||||||
|
click = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static Dictionary<string, Image> FiguryObrazy = new Dictionary<string, Image> {
|
||||||
|
{ "BBishop",Properties.Resources.Black_Bishop},
|
||||||
|
{ "BKnight",Properties.Resources.Black_Knight },
|
||||||
|
{ "BRook",Properties.Resources.Black_Rook },
|
||||||
|
{ "BKing",Properties.Resources.Black_King },
|
||||||
|
{ "BQueen",Properties.Resources.Black_Queen },
|
||||||
|
{ "BPawn",Properties.Resources.Black_Pawn },
|
||||||
|
{ "WBishop",Properties.Resources.White_Bishop },
|
||||||
|
{ "WKnight",Properties.Resources.WKnight },
|
||||||
|
{ "WRook",Properties.Resources.White_Rook },
|
||||||
|
{ "WKing",Properties.Resources.WKing},
|
||||||
|
{ "WQueen",Properties.Resources.White_Queen },
|
||||||
|
{ "WPawn",Properties.Resources.White_Pawn },
|
||||||
|
{ "EMPTY",null }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public struct Lokalizacja
|
||||||
|
{
|
||||||
|
public byte y, x;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,120 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
|
@ -0,0 +1,4 @@
|
||||||
|
// <autogenerated />
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
|
|
@ -0,0 +1 @@
|
||||||
|
5ac251e34c977d563d3acd8a2fc9d7ca427030b31217e071aa76031ea95d884b
|
|
@ -0,0 +1,35 @@
|
||||||
|
C:\Users\Slava\source\repos\Chess\bin\Debug\Chess.exe.config
|
||||||
|
C:\Users\Slava\source\repos\Chess\bin\Debug\Chess.exe
|
||||||
|
C:\Users\Slava\source\repos\Chess\bin\Debug\Chess.pdb
|
||||||
|
C:\Users\Slava\source\repos\Chess\obj\Debug\Chess.csprojAssemblyReference.cache
|
||||||
|
C:\Users\Slava\source\repos\Chess\obj\Debug\Chess.Properties.Resources.resources
|
||||||
|
C:\Users\Slava\source\repos\Chess\obj\Debug\Chess.Tile.resources
|
||||||
|
C:\Users\Slava\source\repos\Chess\obj\Debug\Chess.csproj.GenerateResource.cache
|
||||||
|
C:\Users\Slava\source\repos\Chess\obj\Debug\Chess.exe
|
||||||
|
C:\Users\Slava\source\repos\Chess\obj\Debug\Chess.pdb
|
||||||
|
C:\Users\Slava\source\repos\Chess\obj\Debug\Chess.Chess.resources
|
||||||
|
C:\Users\Slava\source\repos\Chess\obj\Debug\Chess.PieceSelection.resources
|
||||||
|
C:\Users\kvj\Source\Repos\szachydla\bin\Debug\Chess.exe.config
|
||||||
|
C:\Users\kvj\Source\Repos\szachydla\bin\Debug\Chess.exe
|
||||||
|
C:\Users\kvj\Source\Repos\szachydla\bin\Debug\Chess.pdb
|
||||||
|
C:\Users\kvj\Source\Repos\szachydla\obj\Debug\Chess.csproj.AssemblyReference.cache
|
||||||
|
C:\Users\kvj\Source\Repos\szachydla\obj\Debug\Chess.Properties.Resources.resources
|
||||||
|
C:\Users\kvj\Source\Repos\szachydla\obj\Debug\Chess.csproj.GenerateResource.cache
|
||||||
|
C:\Users\kvj\Source\Repos\szachydla\obj\Debug\Chess.csproj.CoreCompileInputs.cache
|
||||||
|
C:\Users\kvj\Source\Repos\szachydla\obj\Debug\Chess.exe
|
||||||
|
C:\Users\kvj\Source\Repos\szachydla\obj\Debug\Chess.pdb
|
||||||
|
C:\Users\kvj\Source\Repos\szachydla\obj\Debug\Chess.Szachy.resources
|
||||||
|
C:\Users\kvj\Source\Repos\szachydla\obj\Debug\Chess.WybranieFigury.resources
|
||||||
|
C:\Users\kvj\Source\Repos\szachydla\obj\Debug\Chess.Pole.resources
|
||||||
|
C:\Users\kvj\source\repos\SzachySzachaPersji\bin\Debug\Chess.exe.config
|
||||||
|
C:\Users\kvj\source\repos\SzachySzachaPersji\bin\Debug\Chess.exe
|
||||||
|
C:\Users\kvj\source\repos\SzachySzachaPersji\bin\Debug\Chess.pdb
|
||||||
|
C:\Users\kvj\source\repos\SzachySzachaPersji\obj\Debug\Chess.csproj.AssemblyReference.cache
|
||||||
|
C:\Users\kvj\source\repos\SzachySzachaPersji\obj\Debug\Chess.Szachy.resources
|
||||||
|
C:\Users\kvj\source\repos\SzachySzachaPersji\obj\Debug\Chess.WybranieFigury.resources
|
||||||
|
C:\Users\kvj\source\repos\SzachySzachaPersji\obj\Debug\Chess.Properties.Resources.resources
|
||||||
|
C:\Users\kvj\source\repos\SzachySzachaPersji\obj\Debug\Chess.Pole.resources
|
||||||
|
C:\Users\kvj\source\repos\SzachySzachaPersji\obj\Debug\Chess.csproj.GenerateResource.cache
|
||||||
|
C:\Users\kvj\source\repos\SzachySzachaPersji\obj\Debug\Chess.csproj.CoreCompileInputs.cache
|
||||||
|
C:\Users\kvj\source\repos\SzachySzachaPersji\obj\Debug\Chess.exe
|
||||||
|
C:\Users\kvj\source\repos\SzachySzachaPersji\obj\Debug\Chess.pdb
|
|
@ -0,0 +1,4 @@
|
||||||
|
// <autogenerated />
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
|