-
Notifications
You must be signed in to change notification settings - Fork 2
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
[#27] check #59
Conversation
@@ -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>>; |
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.
to jest chujowe, myślę co z tym zrobić
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.
ale widzę ten sam ruch w innym prze :P
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.
u mnie jest na public, bo sie bardzo przyadło :P
4e17e14
to
cf2a49d
Compare
const isMovePossible = !this.isCheck(piece); | ||
|
||
this.movePiece(potentialMove, square); | ||
piece!.hasMoved = false; |
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.
to tylko działa, jeśli bierka się wcześniej nie ruszyła - trzeba by zapisywać jej poprzedni status do stałej
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.
hmm, ale ona zawsze będzie się ruszać, o tutaj:
this.movePiece(square, potentialMove);
src/services/game-logic/Board.ts
Outdated
@@ -27,6 +27,14 @@ class Board { | |||
return this.state[square.row][square.column]; | |||
} | |||
|
|||
public checkAllSquares = (f: any) => { |
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.
czym jet F? jednoliterowe zmienne to zuo. 'callback' brzmi lepiej, a jeszcze lepiej jak od razu wiadomo co ten callback ma robić :)
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.
poprawiłam :)
}; | ||
|
||
moveNotResultWithCheck(move: Square, piece: Piece | null, square: Square) { | ||
const potentialMove: Square = { row: move.row, column: move.column }; |
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.
const potentialMove = new Square(move.row, move.column) ?
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.
poprawione
return isMovePossible; | ||
} | ||
|
||
private isCheck(piece: Piece | null): Boolean { |
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.
boolean, nie Boolean
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.
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; |
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.
niepotrzebne typowanie
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.
poprawione
.filter((move) => this.moveNotResultWithCheck(move, piece, square)); | ||
}; | ||
|
||
moveNotResultWithCheck(move: Square, piece: Piece | null, square: Square) { |
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.
brak typu zwracanego
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.
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; |
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.
rozdzielmy to na oddzielne linie i opakujmy w { }
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.
poprawione
@@ -23,7 +23,11 @@ class King extends Piece { | |||
row: this.position.row + row, |
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.
do wyrzucenia linia 20 const [row, column] = positions;
nie jest to używane nigdzie
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.
poprawione
No description provided.