ajax333221 / isepic-chess

♞ JavaScript chess utility library.
MIT License
16 stars 3 forks source link

Full support for comments #23

Open ajax333221 opened 3 years ago

ajax333221 commented 3 years ago

Currently all comments are lost in the PGN import process (not really a bug, but the feature is simply not there), only auto-generated comments like {3-fold repetition} are being used.

Also these methods should probably be added: -board.setComment(str, index): sets the comment at index with the value from the string, if the comment was set correctly then it will return the comment object, otherwise null will be returned. The index default is the current move. -board.setComments(arr): attempts to set multiple comment objects stored in an array (same structure than the returned values in board.getComments() and board.removeComments()), returns true if all the comments were set correctly, false otherwise. -board.getComment(index): if there is a comment at index, return the comment object, otherwise return null. The index default is the current move. -board.getComments(): returns array with all the comment objects. -board.removeComment(index): if there is a comment at index, return the unreferenced comment object and remove it. The index default is the current move. -board.removeComments(): returns array with all the unreferenced comment objects and remove them.

Note: "comment object" means "referenced comment object", unless it specifically says "unreferenced" then it is referenced.

Note2: the comment object will consist of: 1) a move index value and 2) a string with the comment.