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

Javascript issues #54

Open
olufjen opened this issue Jul 10, 2023 · 6 comments
Open

Javascript issues #54

olufjen opened this issue Jul 10, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@olufjen
Copy link
Owner

olufjen commented Jul 10, 2023

The console log after opponent move:
ChessBoardstopDraggedPiece cfg ondrop true type function
chessboard.js:1285 ChessBoard tester d7 og true og d5 og true
chessboard.js:1292 ChessBoard brikke flyttet på brettet bP
?method=PUT:175 The onDrop function
chessboard.js:1300 Result is none bP new position [object Object] old position [object Object] orientation white
chessboard.js:1314 ChessBoard brikke på brettet bP
newPosition is result of call to deepCopy.
The deepCopy function:
return JSON.parse(JSON.stringify(thing));
See example:
https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_parse_json

@olufjen
Copy link
Owner Author

olufjen commented Jul 10, 2023

The elements of new position has the following property names :
a8,b8,c8,d8,e8,f8,g8,h8,a7,b7,c7,e7,f7,g7,h7,d4,a2,b2,c2,e2,f2,g2,h2,a1,b1,c1,d1,e1,f1,g1,h1,d5
The elements of old position has the following property names ::
a8,b8,c8,d8,e8,f8,g8,h8,a7,b7,c7,d7,e7,f7,g7,h7,d4,a2,b2,c2,e2,f2,g2,h2,a1,b1,c1,d1,e1,f1,g1,h1
And their values are:
Values of new position bR,bN,bB,bQ,bK,bB,bN,bR,bP,bP,bP,bP,bP,bP,bP,wP,wP,wP,wP,wP,wP,wP,wP,wR,wN,wB,wQ,wK,wB,wN,wR,bP
Values of old position bR,bN,bB,bQ,bK,bB,bN,bR,bP,bP,bP,bP,bP,bP,bP,bP,wP,wP,wP,wP,wP,wP,wP,wP,wR,wN,wB,wQ,wK,wB,wN,wR

@olufjen
Copy link
Owner Author

olufjen commented Jul 13, 2023

The following events are added:
$('body').on('mousedown mousemove', '.' + CSS.piece, stopDefault);
calls e.preventDefault()
// mouse drag pieces
boardEl.on('mousedown', '.' + CSS.square, mousedownSquare);
containerEl.on('mousedown', '.' + CSS.sparePieces + ' .' + CSS.piece,
mousedownSparePiece);

// mouse enter / leave square
boardEl.on('mouseenter', '.' + CSS.square, mouseenterSquare)
.on('mouseleave', '.' + CSS.square, mouseleaveSquare);
if (cfg.playerMove === false){
console.log('Add an event for player move');
}
$(window).on('mousemove', mousemoveWindow)
.on('mouseup', mouseupWindow);

@olufjen
Copy link
Owner Author

olufjen commented Jul 29, 2023

If opponent wrong move click a different button!

@olufjen
Copy link
Owner Author

olufjen commented Aug 1, 2023

The first piece marked bN
and its positions remain marked as available even when a new piece is marked

@olufjen
Copy link
Owner Author

olufjen commented Aug 5, 2023

The following calls in chessboard.js:
init();
checkDeps();
initDom();
addEvents(),

and a new function to check available positions for an opponent piece.
checkOpponentpiece()
This function checks if opponent has touched a piece.
The opponent touches a piece by holding the mouse over a piece and then leave this piece's position
The call to showSquare then highlights all positions available to this piece.

At present it also highlights player's pieces.

@olufjen olufjen added the enhancement New feature or request label Aug 9, 2023
@olufjen
Copy link
Owner Author

olufjen commented Sep 6, 2023

Touches a piece on the board:

start ready! with piece pp oldpos p newpos p
(index):173 playerMove is true No of available moves 1
(index):175 The available moves are xx
(index):180 The available moves are empty xx
(index):185 A piece is selected but not moved. The first available move is xx
chessboard.js:1829 Before call to init window name window document
chessboard.js:1818 ChessBoard init set:
chessboard.js:340 checkDeps ChessBoard check dependencies of board2
chessboard.js:359 The container E1 The board2


chessboard.js:360 n.fn.init [div#board2, context: div#board2]
chessboard.js:396 checkDeps: ChessBoard ok with container
chessboard.js:397 n.fn.init [div#board2, context: div#board2]
chessboard.js:570 buildBoardContainer:

chessboard.js:1772 initDom playerMove y
chessboard.js:1776 initDom sparepieces set xxx
chessboard.js:1779 initDom playermove set
chessboard.js:1795 initDom draws the board
chessboard.js:996 Inside drawboard
chessboard.js:1761 Events added on
chessboard.js:1762 n.fn.init [div.board-b72b1, prevObject: n.fn.init(1), context: div#board2, selector: '.board-b72b1']
chessboard.js:1806 checkOpponentpiece(), opponentMove is true
chessboard.js:1808 checkOpponentpiece() There is no move from opponent pp
chessboard.js:1810 The available moves are xx
chessboard.js:1833 The window document [object HTMLDocument]
chessboard.js:1835 The widget: clear,destroy,fen,flip,move,orientation,position,resize,start
(index):262 start chessboard now rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR
(index):287 {clear: ƒ, destroy: ƒ, fen: ƒ, flip: ƒ, move: ƒ, …}
(index):288 end ready!!!
favicon.ico:1

    GET http://localhost:8080/favicon.ico 404

Event functions:
chessboard.js:1178 ChessBoard startposisjon b8 - beginDraggingPiece function
chessboard.js:1646 mouseupWindow ChessBoardmove: b8
chessboard.js:1292 ChessBoardstopDraggedPiece b8
chessboard.js:1299 ChessBoardstopDraggedPiece cfg ondrop true type function
chessboard.js:1321 ChessBoard tester b8 og true og b8 og true
chessboard.js:1328 ChessBoard brikke flyttet på brettet bN
(index):208 The onDrop function
(index):209 b8
(index):210 bN
(index):211 b8
(index):212 {a8: 'bR', c8: 'bB', d8: 'bQ', e8: 'bK', f8: 'bB', …}
(index):213 {a8: 'bR', b8: 'bN', c8: 'bB', d8: 'bQ', e8: 'bK', …}
chessboard.js:1336 Result is none bN new position a8,c8,d8,e8,f8,g8,h8,a7,b7,c7,d7,e7,f7,g7,h7,a2,b2,c2,d2,e2,f2,g2,h2,a1,b1,c1,d1,e1,f1,g1,h1,b8 old position a8,b8,c8,d8,e8,f8,g8,h8,a7,b7,c7,d7,e7,f7,g7,h7,a2,b2,c2,d2,e2,f2,g2,h2,a1,b1,c1,d1,e1,f1,g1,h1 orientation white
chessboard.js:1352 ChessBoard brikke på brettet bN - 1354 !!
chessboard.js:1169 ChessBoard brikke på brettet brett submitted xbN
(index):132 Form submit #btnmove

Etter form submit:

start ready! with piece bN oldpos p newpos p
?method=PUT:173 playerMove is false No of available moves 1
?method=PUT:175 The available moves are yy
?method=PUT:185 A piece is selected but not moved. The first available move is yy
chessboard.js:1829 Before call to init window name window document
chessboard.js:1818 ChessBoard init set:
chessboard.js:340 checkDeps ChessBoard check dependencies of board2
chessboard.js:359 The container E1 The board2


chessboard.js:360 n.fn.init [div#board2, context: div#board2]
chessboard.js:396 checkDeps: ChessBoard ok with container
chessboard.js:397 n.fn.init [div#board2, context: div#board2]
chessboard.js:570 buildBoardContainer:

chessboard.js:1772 initDom playerMove y
chessboard.js:1776 initDom sparepieces set xxx
chessboard.js:1782 initDom playermove not set
chessboard.js:1795 initDom draws the board
chessboard.js:996 Inside drawboard
chessboard.js:1736 Add player move
chessboard.js:1761 Events added on
chessboard.js:1762 n.fn.init [div.board-b72b1, prevObject: n.fn.init(1), context: div#board2, selector: '.board-b72b1']
chessboard.js:1806 checkOpponentpiece(), opponentMove is true
chessboard.js:1808 checkOpponentpiece() There is no move from opponent bN
chessboard.js:1810 The available moves are yy
chessboard.js:1833 The window document [object HTMLDocument]
chessboard.js:1835 The widget: clear,destroy,fen,flip,move,orientation,position,resize,start
?method=PUT:262 start chessboard now rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR
?method=PUT:270 Player has made a move!
?method=PUT:275 Tegnet brettet på nytt
?method=PUT:287 {clear: ƒ, destroy: ƒ, fen: ƒ, flip: ƒ, move: ƒ, …}
?method=PUT:288 end ready!!!

Output from RapporterChessStartServerResourceHTML:
Collecting parameters:

posisjon=b8
piece=bN
startposisjon=b8
tilgjengeligpos=xx
formValue=nokkel

Piece name:
Piece name BlackKnight1 Finding available positions false
Game and moveflagg null true No move
rnbqkbnr/pppppppp/11111111/11111111/11111111/11111111/PPPPPPPP/RNBQKBNR

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

No branches or pull requests

1 participant