Boardgame.io: no ctx.events in onTurnBegin

Created on 13 Jul 2018  路  4Comments  路  Source: boardgameio/boardgame.io

I have noticed that ctx.events has not yet been bound in the first onTurnBegin. I wonder when events are set in ctx. Is this a bug?

onTurnBegin (G, ctx) {
  console.log (ctx.events)
  // result
  // (in the first turn) undefined
  // (from the second turn) {endTurn: [Function]}
  return G
}

Most helpful comment

Fixed in 1a247919b0f28934e354e7a3dd377db4f161c60a and should be available in 0.24.1.

All 4 comments

This was a bug that was fixed recently. Which version are you using?

boardgame.io
0.24.0

$ head node_modules/boardgame.io/package.json 
{
  "name": "boardgame.io",
  "version": "0.24.0",
  "description": "library for turn-based games",
  "repository": "https://github.com/google/boardgame.io",
  "scripts": {
    "dev": "cross-env NODE_ENV=development babel-watch --presets es2015 examples/react/server.js",
    "docsify": "docsify serve docs",
    "docsify:update": "node ./scripts/docsify-update.js",
    "examples": "npm run dev",

this is code block

  flow: {
    onTurnBegin(G, ctx) {
      console.log('--[ start ] --')
      console.log (ctx.events) // this emit "undefined"

      return G
    },
  }

Ah, looks like the bug was not fixed correctly the last time (it only added the Random API, and not the Events API to the first onTurnBegin). Will fix this. Thanks for the report!

Fixed in 1a247919b0f28934e354e7a3dd377db4f161c60a and should be available in 0.24.1.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adngdb picture adngdb  路  5Comments

SaFrMo picture SaFrMo  路  7Comments

jstacoder picture jstacoder  路  7Comments

haoyangnz picture haoyangnz  路  5Comments

nicolodavis picture nicolodavis  路  7Comments