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

There should be a way to associate a game and a board #109

Open
milescrawford opened this issue Dec 5, 2021 · 2 comments
Open

There should be a way to associate a game and a board #109

milescrawford opened this issue Dec 5, 2021 · 2 comments

Comments

@milescrawford
Copy link

It seems that I need to manually keep game and board objects synchronized, which seems odd.

Why can't I pass a game object to the board constructor, and have the board always display the progress of the game, for example? If I want to "undo" a move, I can't just pop a position from the game and have the board update - I need to somehow track or recover what the most recent move is, and update both in sync.

Am I missing something?

@milescrawford
Copy link
Author

milescrawford commented Dec 5, 2021

I'm trying just running something like this after each game update, but it seems wasteful:

    board.removeAllObjects();
    for ( var x = 0; x < game.size; x++) {
        for ( var y = 0; y < game.size; y++) {
            var obj = game.getStone(x,y);
            if (obj){
                board.addObject({x:x,y:y,c:obj});
            }
        }
    }

(edited: i made a mistake, this is working, though it seems wasteful)

@milescrawford
Copy link
Author

I have improved this to keeping a stack of state objects from board getState and using restoreState so at least this is done incrementally, but I still seem to be keeping extra copies of state and busywork just to keep the board displaying the state of the game.

In addition, I found another bug/pitfall #111

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

No branches or pull requests

1 participant