Open T-vK opened 5 years ago
that would be an excellent PR.
For anyone looking for a workaround, you can hack around it by doing the following:
GameEngine
and ClientEngine
subclassesdraw
method (or similar), add the following code: if (this.clientEngineRef.resolveGame) {
this.gameEngineRef.initialized = true;
}
GameEngine
subclass, add the following function: getPlayerGameOverResult() {
return this.initialized;
}
This works because ClientEngine
stores the resolve
function from ClientEngine::start()
's promise in a class variable that only ever gets called during ClientEngine::step()
, and even then only if GameEngine::getPlayerGameOverResult()
returns a truthy value.
Hacky? Yes. But, it does cause ClientEngine::start()
's behavior to match the documentation, so... 🤷♀
this comment was edited to make the workaround more reliable
Can we please change the code of ClientEngine.start so that it resolves once it's ready?
I was extremely confused that this just wouldn't work:
Or this:
It seems like a very bad idea to not resolve the promise immediately. (Not to mention that rejecting with undefined makes debugging a nightmare.)
I'd be willing to make a PR, but I wanted to discuss this first.