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

Clarification on documentation for SYNC_STAGE #166

Closed
chengemily opened this issue Mar 30, 2021 · 4 comments
Closed

Clarification on documentation for SYNC_STAGE #166

chengemily opened this issue Mar 30, 2021 · 4 comments

Comments

@chengemily
Copy link

chengemily commented Mar 30, 2021

Hi, I'm having trouble implementing SYNC_STAGE following the Synchronization documentation. I have a stage with multiple steps for which I want SYNC_STAGE, then for the rest of the game I would like SYNC_STEP. So far, I have set the default step rule to be SYNC_STEP in the logic and did not change the default step rule from WAIT in the player. Then, I extended the specific stage to have stepRule: stepRules.SYNC_STAGE in both player.js and logic.js. However, once both players reach the end of the stage and press Done, they cannot advance as the logic has not advanced past the first step. The documentation says that for SYNC_STAGE, the players wait for a message from the server to step-- however, I couldn't find how to send this message. Any advice? Thanks!

@shakty
Copy link
Member

shakty commented Mar 31, 2021

Hi,

This is a feature not used often, since levels have been introduced, so the API needs some refactor and the doc is a bit outdated.

To begin with pull the latest nodegame-client, or install latest dev, otherwise an error will be raised.

Say you have a stage with three steps, you can do the following:

In player.js:

    stager.extendStep('step1', {
        stepRule: stepRules.SOLO,
    });

    stager.extendStep('step2', {
        stepRule: stepRules.SOLO,
    });

    stager.extendStep('step3', {
        stepRule: stepRules.WAIT,
    });

In logic.js

    stager.extendStep('step1', {
        stepRule: stepRules.OTHERS_SYNC_STAGE,
        cb: function() {
            // Prevents to go to next step, instead goes to next stage.
            node.game.breakStage(true);
        }
    });

It is a bit cumbersome, but it will work.

@shakty
Copy link
Member

shakty commented Mar 31, 2021

I have updated the doc, it should be clearer now. There is a warning that the API is in refactor and it may change in the next release.

@shakty
Copy link
Member

shakty commented Apr 1, 2021

Can I close?

@chengemily
Copy link
Author

Great! Thank you! It works.

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

2 participants