Skip to content

Commit

Permalink
Merge pull request #38 from AleksanderNekr/Alex
Browse files Browse the repository at this point in the history
Added settings functionality
  • Loading branch information
AleksanderNekr authored Jun 6, 2022
2 parents fb5be8f + 2de8701 commit 51815b6
Show file tree
Hide file tree
Showing 38 changed files with 259 additions and 935 deletions.
Binary file modified ChessLearnProgram/.vs/ChessLearnProgram/v17/.suo
Binary file not shown.
7 changes: 4 additions & 3 deletions ChessLearnProgram/Chess/Chess.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@
<Compile Include="Pieces\Rook.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Pieces\ValidMove.cs" />
<Compile Include="Pieces\ValidMove.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
Expand Down Expand Up @@ -102,7 +104,7 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="Resources\Knight %281%29.ico" />
<Content Include="Resources\move_sound.wav" />
<None Include="Resources\Фон для текста.png" />
<None Include="Resources\Фон для кнопки.jpg" />
<None Include="Resources\Фон для кнопки.png" />
Expand Down Expand Up @@ -133,7 +135,6 @@
<Content Include="Properties\Images\White\Queen.png" />
<Content Include="Properties\Images\White\Rook.png" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
61 changes: 41 additions & 20 deletions ChessLearnProgram/Chess/ClassDiagram2.cd
Original file line number Diff line number Diff line change
@@ -1,75 +1,96 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="Chess.ChessBoard">
<Position X="2.25" Y="2" Width="1.5" />
<Position X="6" Y="2.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAgAAAAAAA=</HashCode>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAgAABAAAA=</HashCode>
<FileName>ChessBoard.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="Chess.Coordinate" BaseTypeListCollapsed="true">
<Position X="0.5" Y="0.5" Width="1.5" />
<Position X="1" Y="0.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAEAAAAAAIAAAABAAAAAAAACAgAAAAAAAAAAAAA=</HashCode>
<HashCode>AAAAAAEAAAAAAIAEgABAAAAAAAACAoAAAAAAAAAAAAA=</HashCode>
<FileName>Coordinate.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="Chess.ResourceBlack">
<Position X="11.75" Y="0.5" Width="1.5" />
<Position X="14.75" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>gAAAAAAAAAEggAAAAEABEAQAAQAAAAAAAAAAAAAAAIA=</HashCode>
</TypeIdentifier>
</Class>
<Class Name="Chess.ResourceWhite">
<Position X="10" Y="0.5" Width="1.5" />
<Position X="12.75" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>gAAAAAAAAAEggAAAAEABEAQAAQAAAAAAAAAAAAAAAIA=</HashCode>
</TypeIdentifier>
</Class>
<Class Name="Chess.Pieces.Bishop">
<Position X="2.5" Y="4.5" Width="1.5" />
<Position X="2.5" Y="4.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<HashCode>AQAAAAAAAAAAAAAAAgAgAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Pieces\Bishop.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="Chess.Pieces.ChessPiece">
<Position X="4.25" Y="0.5" Width="1.5" />
<Position X="3.5" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAIEAAAAAAAAAAAAABIAAAAAAAAgAAAgAA=</HashCode>
<HashCode>AQAAAAAAAAAIAAAAAAAAAAAAAABIAAQAAAAAgAAAggA=</HashCode>
<FileName>Pieces\ChessPiece.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="Chess.Pieces.ValidMove">
<Position X="6.5" Y="4.5" Width="1.5" />
<Position X="4.5" Y="4.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Pieces\ChessPiece.cs</FileName>
<HashCode>AQAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Pieces\ValidMove.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="Chess.Pieces.King">
<Position X="0.5" Y="4.5" Width="1.5" />
<Position X="0.5" Y="4.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgA=</HashCode>
<HashCode>AQAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Pieces\King.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="Chess.Pieces.Pawn">
<Position X="4.5" Y="4.5" Width="1.5" />
<Position X="2.5" Y="6.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AQAAEAAAAAAAEAAAAAAACAAACBAAAAAAAAAAAAAAAgA=</HashCode>
<HashCode>AQAAEAAAAAAAAAAAAAAACAAACBAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Pieces\Pawn.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="Chess.Properties.Resources">
<Position X="10.75" Y="4.25" Width="1.5" />
<Position X="16.75" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAEAAAAAAAAAAAAAABEAAAARAAABAAAAAAAAAAAIA=</HashCode>
</TypeIdentifier>
</Class>
<Class Name="Chess.Pieces.Knight">
<Position X="4.5" Y="6.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AQAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Pieces\Knight.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="Chess.Pieces.Queen">
<Position X="6.5" Y="4.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AQAAAAAAAAAAAAAAAgAgAAAAAAAAEAAAAgAAAAAAAAA=</HashCode>
<FileName>Pieces\Queen.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="Chess.Pieces.Rook">
<Position X="0.5" Y="6.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAABEAAAAQAAABAAAAAAAAAAAIA=</HashCode>
<HashCode>AQAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAgAAAAAAAAA=</HashCode>
<FileName>Pieces\Rook.cs</FileName>
</TypeIdentifier>
</Class>
<Interface Name="Chess.ICoordinate">
<Position X="2.25" Y="0.5" Width="1.5" />
<Position X="6" Y="0.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAABAAAAAAAAAAgAAAAAAAAAAAAA=</HashCode>
<FileName>ICoordinate.cs</FileName>
Expand Down
24 changes: 19 additions & 5 deletions ChessLearnProgram/Chess/Pieces/ChessPiece.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System;
#nullable enable
using System;
using System.Collections.Generic;
using System.Media;
using System.Threading;
using System.Windows.Forms;

namespace Chess.Pieces
Expand All @@ -10,8 +13,9 @@ namespace Chess.Pieces
/// </summary>
public abstract class ChessPiece : Button
{
private string _color;
private Coordinate _currentCoordinate;
private string _color;
private Coordinate _currentCoordinate;
public static SoundPlayer? MoveSound;

public ChessPiece(Coordinate coordinate, string color)
{
Expand Down Expand Up @@ -89,6 +93,8 @@ public void MoveTo(Coordinate newCoordinate)

this.CurrentCoordinate = new Coordinate(newCoordinate.Row, newCoordinate.Column);
this.Clicks = 0;
this.BackColor = System.Drawing.Color.Transparent;
MoveSound?.Play();
}

public abstract List<Coordinate> GetValidMoves();
Expand All @@ -111,7 +117,7 @@ public void ToggleShowValidMoves()
if (enemy.BackColor == System.Drawing.Color.Transparent)
{
enemy.Enabled = true;
enemy.BackColor = System.Drawing.Color.Red;
enemy.BackColor = ValidMove.ValidMoveColor;
}
else
{
Expand All @@ -138,8 +144,16 @@ public void ToggleShowValidMoves()
{
chessPiece.Enabled = true;
}
}

this.Enabled = true;
this.Enabled = true;
if (this.Clicks % 2 == 1)
{
this.BackColor = System.Drawing.Color.Bisque;
}
else
{
this.BackColor = System.Drawing.Color.Transparent;
}
}

Expand Down
2 changes: 1 addition & 1 deletion ChessLearnProgram/Chess/Pieces/King.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public King(Coordinate coordinate, string color) : base(coordinate, color)
this.UseVisualStyleBackColor = true;
}

public List<Coordinate> ValidMoves { get; } = new List<Coordinate>();
public List<Coordinate> ValidMoves { get; set; } = new List<Coordinate>();

public override List<Coordinate> GetValidMoves()
{
Expand Down
4 changes: 3 additions & 1 deletion ChessLearnProgram/Chess/Pieces/ValidMove.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ namespace Chess.Pieces
{
public sealed class ValidMove : ChessPiece
{
public static System.Drawing.Color ValidMoveColor { get; set; }

public ValidMove(Coordinate coordinate, string color) : base(coordinate, color)
{
this.AllowDrop = true;
this.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
this.AutoSize = true;
this.BackColor = System.Drawing.Color.Chartreuse;
this.BackColor = ValidMoveColor;
this.FlatAppearance.BorderColor = System.Drawing.Color.White;
this.FlatAppearance.BorderSize = 0;
this.FlatStyle = FlatStyle.Flat;
Expand Down
45 changes: 27 additions & 18 deletions ChessLearnProgram/Chess/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions ChessLearnProgram/Chess/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,9 @@
<data name="Фон_для_кнопки" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Фон для кнопки.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="move_sound" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\move_sound.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
</data>
</root>
Binary file added ChessLearnProgram/Chess/Resources/move_sound.wav
Binary file not shown.
Binary file modified ChessLearnProgram/Chess/bin/Debug/Chess.dll
Binary file not shown.
Binary file modified ChessLearnProgram/Chess/bin/Debug/Chess.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified ChessLearnProgram/Chess/obj/Debug/Chess.dll
Binary file not shown.
Binary file modified ChessLearnProgram/Chess/obj/Debug/Chess.pdb
Binary file not shown.
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 51815b6

Please sign in to comment.