Skip to content

Commit

Permalink
Fixes for the chess game
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed Oct 25, 2021
1 parent 16c393d commit 048bb92
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion ui/chess/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@open-wc/scoped-elements": "^2.0.0-next.4",
"@scoped-elements/material-web": "^0.0.14",
"chess.js": "^0.11.0",
"chessboard-element": "^1.1.0",
"chessboard-element": "^1.2.0",
"lit": "^2.0.2",
"lit-svelte-stores": "^0.1.3"
},
Expand Down
11 changes: 6 additions & 5 deletions ui/chess/src/elements/chess-game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,12 @@ export class ChessGame extends ScopedElementsMixin(LitElement) {
updated(changedValues: PropertyValues) {
super.updated(changedValues);

const board = this.shadowRoot?.getElementById('board');
if (board && (board as any).setPosition) {
(board as any).setPosition(this.chessGame().fen());
(board as any).position = this.chessGame().fen();
const board = this.shadowRoot?.getElementById('board') as
| ChessBoardElement
| undefined;
if (board && board.setPosition) {
board.setPosition(this.chessGame().fen());
board.requestUpdate();
}
}

Expand Down Expand Up @@ -377,7 +379,6 @@ export class ChessGame extends ScopedElementsMixin(LitElement) {
style="margin-right: 40px"
.orientation=${this.amIWhite() ? 'white' : 'black'}
?draggable-pieces=${!this.isGameOver()}
position="${this.chessGame().fen()}"
@drag-start=${this.onDragStart}
@drop=${this.onDrop}
@mouseover-square=${this.onMouseOverSquare}
Expand Down
2 changes: 2 additions & 0 deletions ui/elemental-chess/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export default {
preferBuiltins: false,
}),
replace({
"const srcSquareRect = srcSquare.getBoundingClientRect();": "if(!srcSquare) return {};const srcSquareRect = srcSquare.getBoundingClientRect();",
"this._draggedPieceElement.addEventListener('transitionend', transitionComplete);": "this._draggedPieceElement.addEventListener('transitionend', transitionComplete);resolve();",
'process.env.ENV': `"${process.env.ENV}"`,
'process.env.HC_PORT': `"${process.env.HC_PORT}"`,
"COMB = require('@holo-host/comb').COMB":
Expand Down
5 changes: 5 additions & 0 deletions ui/elemental-chess/web-dev-server.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ export default /** @type {import('@web/dev-server').DevServerConfig} */ ({

plugins: [
replace({
'const srcSquareRect = srcSquare.getBoundingClientRect();':
'if(!srcSquare) return {};const srcSquareRect = srcSquare.getBoundingClientRect();',

"this._draggedPieceElement.addEventListener('transitionend', transitionComplete);":
"this._draggedPieceElement.addEventListener('transitionend', transitionComplete);resolve();",
'process.env.ENV': JSON.stringify(process.env.ENV),
'process.env.HC_PORT': JSON.stringify(process.env.HC_PORT || 8888),
' COMB =': 'window.COMB =',
Expand Down

0 comments on commit 048bb92

Please sign in to comment.