-
Notifications
You must be signed in to change notification settings - Fork 5
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
How to get comment of a move? #30
Comments
Great question, I don't seem to have created an easy interface to deal with comments yet. I'll look into improving that and will update the demo's to include comments. For now, you can do something like this (try in demo-player.html): <p>
Comments:<br>
<span ng-repeat="comment in Game.node.comments">{{comment}}<br></span>
</p> You can access the current tree node via I will add some enhancements to let |
I've had another look at the code and I think the easiest way for you to programmatically find nodes with comments would be something like this: //Load JGF data into a new game object
var game = new Game(jgf);
//Get the root node
var node = game.root;
var firstComment = '';
//Process children
while (node.children.length > 0) {
//Get the first variation
//Optionally, you can process all the children (variation nodes)
node = node.children[0];
//Check if comments present in node
if (typeof node.comments !== 'undefined') {
firstComment = node.comments.join('\n\n');
break;
}
} Let me know if that helps. |
Great! Even better if there are APIs for the above, something like:
Plus navigation APIs inside variations (I have not looked into this part yet), users can easily traverse among game comments and variations. |
Thanks for the suggestion, I will look into adding methods like that to the player. The Game service API contains methods for navigating between variations, try: Game.next(i); //Where i is the variation number
Game.lastFork() I will add the |
Added in 1.2.2 |
Thank you! |
I have added the following methods to the Game and Player services in version 1.2.5: Player.previousFork(); //renamed from Player.lastFork()
Player.nextFork();
Game.previousFork(); //renamed from Game.lastFork()
Game.nextFork(); I have also added some example code to the As for the comments, I don't feel this should be the responsibility of the player, as it feels like business logic to me which might be specific to your implementation of the player. However, you can feel free to extend the Player service using a decorator and add those methods if needed, or do it via scoped controller methods instead. Let me know if there's anything else I can help with. |
Thanks very much for the update! Regards comments, I'd like to suggest a scenario which may bring convenience for Player UI building. In a commented game record, typically pro game record, a comment show up every ten or so moves. So a game with very detail comments usually are broken down to fifteen to twenty or so diagrams. For example, if there are comments in move 17 and 29, in early part of a game. Of course, the user can click In the above scenario, a lookup/jump to next/previous comment API will be very helpful, for example:
|
Yeah, I suppose it could come in handy for review of games. Alright, I'll add something in for navigating to/from comments. I also like the idea of an API to number some or all of the moves. Will add that in as well. |
Added the following API methods in 1.3.0: Player.nextComment();
Player.previousComment();
Player.showMoveNumbers(fromMove, toMove);
Game.nextComment();
Game.previousComment();
Game.getMoveNodes(fromMove, toMove);
Game.getMoveNode(move); The following already existed: Game.getNode() //Get current node There's a small issue regarding setup nodes being counted as move nodes. I will address that shortly. But it should work fine for game records without setup nodes. |
Wonderful! Thank you! |
After a game is loaded, how can I
Thanks
The text was updated successfully, but these errors were encountered: