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

[#27] check #59

Merged
merged 4 commits into from
Feb 14, 2021
Merged

[#27] check #59

merged 4 commits into from
Feb 14, 2021

Conversation

asiaziola
Copy link
Collaborator

@asiaziola asiaziola commented Feb 12, 2021

No description provided.

@@ -11,7 +11,7 @@ import { Queen } from './pieces/Queen';
class Board {
public static BOARD_SIZE = 8;

private state: Array<Array<Piece | null>>;
public state: Array<Array<Piece | null>>;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

to jest chujowe, myślę co z tym zrobić

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ale widzę ten sam ruch w innym prze :P

Copy link
Collaborator

Choose a reason for hiding this comment

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

u mnie jest na public, bo sie bardzo przyadło :P

const isMovePossible = !this.isCheck(piece);

this.movePiece(potentialMove, square);
piece!.hasMoved = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

to tylko działa, jeśli bierka się wcześniej nie ruszyła - trzeba by zapisywać jej poprzedni status do stałej

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hmm, ale ona zawsze będzie się ruszać, o tutaj:
this.movePiece(square, potentialMove);

@@ -27,6 +27,14 @@ class Board {
return this.state[square.row][square.column];
}

public checkAllSquares = (f: any) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

czym jet F? jednoliterowe zmienne to zuo. 'callback' brzmi lepiej, a jeszcze lepiej jak od razu wiadomo co ten callback ma robić :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

poprawiłam :)

};

moveNotResultWithCheck(move: Square, piece: Piece | null, square: Square) {
const potentialMove: Square = { row: move.row, column: move.column };
Copy link
Collaborator

Choose a reason for hiding this comment

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

const potentialMove = new Square(move.row, move.column) ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

poprawione

return isMovePossible;
}

private isCheck(piece: Piece | null): Boolean {
Copy link
Collaborator

Choose a reason for hiding this comment

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

boolean, nie Boolean

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

poprawione


private isCheck(piece: Piece | null): Boolean {
const color = piece?.color === Colors.BLACK ? Colors.WHITE : Colors.BLACK;
let currentPlayerKing: Square | undefined = this.getKingForCheck(piece)?.position;
Copy link
Collaborator

Choose a reason for hiding this comment

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

niepotrzebne typowanie

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

poprawione

.filter((move) => this.moveNotResultWithCheck(move, piece, square));
};

moveNotResultWithCheck(move: Square, piece: Piece | null, square: Square) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

brak typu zwracanego

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

poprawione

getKingForCheck = (piece: Piece | null): King | null => {
let king = null;
this.board.checkAllSquares((square: Piece) => {
if (square && square?.color === piece?.color && square.name === PieceNames.KING) king = square;
Copy link
Collaborator

Choose a reason for hiding this comment

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

rozdzielmy to na oddzielne linie i opakujmy w { }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

poprawione

@@ -23,7 +23,11 @@ class King extends Piece {
row: this.position.row + row,
Copy link
Collaborator

Choose a reason for hiding this comment

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

do wyrzucenia linia 20 const [row, column] = positions; nie jest to używane nigdzie

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

poprawione

@asiaziola asiaziola merged commit e78c63a into develop Feb 14, 2021
@asiaziola asiaziola deleted the 27-check branch February 14, 2021 10:17
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.

4 participants