Skip to content
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

Closed
wants to merge 0 commits into from
Closed

Chess #43

wants to merge 0 commits into from

Conversation

Rinzii
Copy link
Contributor

@Rinzii Rinzii commented Jun 29, 2022

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! ^^

@Rinzii Rinzii marked this pull request as draft June 29, 2022 13:46
@ZacharyPatten
Copy link
Collaborator

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.

@ZacharyPatten ZacharyPatten mentioned this pull request Jun 29, 2022
@ZacharyPatten ZacharyPatten changed the title Add the game Chess #17 Chess Jun 29, 2022
@Rinzii
Copy link
Contributor Author

Rinzii commented Jun 29, 2022

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 ^^

};

// position status for a piece on the board currently
public object[,] Cases { get; set; }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it object?


public T SetWhite<T>( char column, int row ) where T : Piece
{
var piece = Activator.CreateInstance(typeof(T), PieceColor.White) as T;

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.


public T SetBlack<T>(char column, int row) where T : Piece
{
var piece = Activator.CreateInstance(typeof(T), PieceColor.Black) as T;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Projects/Chess/Board.cs Outdated Show resolved Hide resolved
Projects/Chess/Board.cs Outdated Show resolved Hide resolved
Projects/Chess/Pieces/Move.cs Outdated Show resolved Hide resolved
Comment on lines 3 to 15
public class MoveOutcome
{
public MoveOutcome()
{
IsSuccess = true;
}

public bool IsSuccess { get; set; }

public bool Attack { get; set; }

public Piece CapturedPiece { get; set; }
}

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

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

{
Rules = new Collection<MovementRule>();

Color = (color == PieceColor.White ? PieceColor.White : PieceColor.Black);

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants