-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chess #43
Chess #43
Conversation
Thanks for your interest in contributing! :) I'll update the New Games issue to show that there is an open pull request for Chess. Don't hesitate to ask for assistance. I'll wait on performing a code review until you mark it as a non-draft. |
I may take ya up on that offer! The biggest thing right now is finding time to build out the logic but I think I got an idea of where I want to go with certain elements. Just a matter of figuring out the details ^^ |
Projects/Chess/Board.cs
Outdated
}; | ||
|
||
// position status for a piece on the board currently | ||
public object[,] Cases { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it object
?
Projects/Chess/Board.cs
Outdated
|
||
public T SetWhite<T>( char column, int row ) where T : Piece | ||
{ | ||
var piece = Activator.CreateInstance(typeof(T), PieceColor.White) as T; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend either passing a delegate, e. g. Func<T> creator
, or using static abstracts from C# 11.
Projects/Chess/Board.cs
Outdated
|
||
public T SetBlack<T>(char column, int row) where T : Piece | ||
{ | ||
var piece = Activator.CreateInstance(typeof(T), PieceColor.Black) as T; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
Projects/Chess/Pieces/MoveOutcome.cs
Outdated
public class MoveOutcome | ||
{ | ||
public MoveOutcome() | ||
{ | ||
IsSuccess = true; | ||
} | ||
|
||
public bool IsSuccess { get; set; } | ||
|
||
public bool Attack { get; set; } | ||
|
||
public Piece CapturedPiece { get; set; } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one I told above. So I'd make it nullable where needed, removed IsSuccess
, and the rest to be made into record
@@ -0,0 +1,23 @@ | |||
namespace Chess; | |||
|
|||
public class MovementRule |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, make it a record
Projects/Chess/Pieces/Piece.cs
Outdated
{ | ||
Rules = new Collection<MovementRule>(); | ||
|
||
Color = (color == PieceColor.White ? PieceColor.White : PieceColor.Black); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you do ... Color = color
?
Currently working on adding Chess #17 to the list of games. Due to the addition of checkers I have been reusing some aspects of that for my base but by the completion of this it will be functionally different. I’m not yet done with this but I wanted to reserve Chess so I’m putting this PR up as a draft.
Any input, opinions, or help is appreciated! ^^