question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Curious Flow: Second phase's onTurnBegin() is not calling

See original GitHub issue

Hello, I’d like to use your impressive framework, but I met a strange situation.

Here’s my simplified code: https://github.com/ybbarng/boardgame-io-test/blob/master/src/App.js

In phase1, each turn is automatically ended because endTurn() is called in onTurnBegin(). Because the phase1’s TurnOrder is ONCE, the phase will be moved to next phase2. At this time, onTurnBegin() of phase2 is not calling. I hope someone figure out my mistake or explain why this happens.

Context when it stuck,

The log of console:

phase1 onPhaseBegin
phase1 onTurnBegin 0
phase1 onTurnEnd 0
phase1 onTurnBegin 1
phase1 onTurnEnd 1
phase1 onPhaseEnd
phase2 onPhaseBegin

The debug pannel:

G: {}
ctx: {
  "numPlayers": 2,
  "turn": 2,
  "currentPlayer": "0",
  "actionPlayers": [
    "0"
  ],
  "currentPlayerMoves": 0,
  "playOrder": [
    "0",
    "1"
  ],
  "playOrderPos": 0,
  "stats": {
    "turn": {
      "numMoves": {},
      "allPlayed": false
    },
    "phase": {
      "numMoves": {},
      "allPlayed": false
    }
  },
  "allPlayed": false,
  "phase": "phase2",
  "prevPhase": "phase1",
  "allowedMoves": null
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:19 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
nicolodaviscommented, Aug 28, 2019

If you ever want to subdivide a turn into multiple “phases”, you should use stages. phases are for general game phases inside which multiple turns are played. stages are different parts of a single turn.

import { ActivePlayers } from 'boardgame.io/core'

const game = {
  turn: {
    activePlayers: {
      currentPlayer: 'A',  // put the player in Stage A at the beginning of the turn
    },

    stages: {
      A: {
        moves: {
          moveA: (G, ctx) => {
            ...

            // move the player to Stage B.
            ctx.events.setActivePlayers({ currentPlayer: 'B' });
          },
        },
      },

      B: {
        moves: { ... },
      },
    }
  }
}
1reaction
gadamgreycommented, Aug 28, 2019

npm run prepack was what I was missing, thanks.

FWIW here is the error I was seeing trying to reference the git branch directly. This was after installing cross-env globally:

> cross-env BABEL_ENV=rollup rollup --config rollup.npm.js

events.js:186
      throw er; // Unhandled 'error' event
      ^

Error: spawn rollup ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:77:11)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:77:11) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn rollup',
  path: 'rollup',
  spawnargs: [ '--config', 'rollup.npm.js' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! boardgame.io@0.32.1 build: `cross-env BABEL_ENV=rollup rollup --config rollup.npm.js`
npm ERR! Exit status 1
Read more comments on GitHub >

github_iconTop Results From Across the Web

Curious Flow: Second phase's onTurnBegin() is not calling ...
Essentially I'm trying to have a setup phase that happens at the beginning of a 2 player game. Each player can make a...
Read more >
How to Handle Multiple Phases in Coriolis Flow Measurement
This webinar will focus on multiphase challenges in allocation measurement such as volatile fluids and changing process and reservoir ...
Read more >
How two-phase flow (entrained gas) affects a Coriolis meter
This video is second in a series that explains how entrained gas can affect a Coriolis flowmeter and speak about the errors associated...
Read more >
Two Phase Flow Entrained Gas Applications - YouTube
This video is first in the series that explains how Micro Motion® Coriolis meters work in two - phase flow (entrained gas) applications....
Read more >
Webinar: Enhancing Coriolis Performance in Entrained Gas ...
Micro Motion Coriolis Flow and Density Measurement ... measurement can provide additional insight into two - phase flows Thanks for watching!
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found