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

How does one access the moves/variations/comments/etc. of a Game object? #9

Closed
danegraphics opened this issue Dec 11, 2019 · 4 comments
Labels
enhancement New feature or request

Comments

@danegraphics
Copy link

I couldn't find anything in the documentation that allows one to access the content of a game object, such as the moves, the variations, the comments, etc. Only the names of the players and other things like that.

I need to be able to load PGNs, look at them/add comments and variations to them/etc, and then export the modified PGNs after.

How would I do that?

@danegraphics
Copy link
Author

danegraphics commented Dec 11, 2019

Turns out both Node and Variation are exposed and can be accessed, but only after calling Game.mainVariation().

Navigating a variation purely through next() is slightly annoying, but it's workable.

@yo35
Copy link
Owner

yo35 commented Dec 15, 2019

Hi,
I'm opened to any suggestion that would improve the API exposed by the Game and Variation objects.

@danegraphics
Copy link
Author

@yo35 - It would be very useful to be able to navigate the variation object through an array of nodes.

Instead of doing multiple next() calls to reach a certain move, you can simply do something like variation.nodeList()[7] to reach the 8th ply in a variation.

@yo35 yo35 added the enhancement New feature or request label Dec 20, 2019
@yo35 yo35 reopened this Dec 20, 2019
yo35 added a commit that referenced this issue Dec 20, 2019
@yo35
Copy link
Owner

yo35 commented Dec 20, 2019

Done in version 1.3.0.

WARNING: in order to provide a consistent API, I had to slightly break the API of the Node object, in particular regarding functions Node#next() and Node#play(..). Now, these methods always return a new instance of Node, instead of returning a pointer to this.

In other words, as of 1.3.0, a given Node instance always points at the same move within a Variation, which is also more understandable in my opinion.

@yo35 yo35 closed this as completed Dec 20, 2019
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

2 participants