Turn goes twice when phase is end
See original GitHub issueHi, I’m facing a problem. I set endTurnIf
hook to always return true. When phase is end, it seems that the turn automatically goes twice.
ctx.turn
is added by 2ctx.currentPlayer
goes twice
I’ve not dug deeply yet, but I found that the endTurn
event is dispatched in function endPhaseEvent
and endPhase
event is dispatched in function endTurnEvent
in src/core/flow.js
. I feel the former should be removed. What do you think?
Reproduce steps
Here’s minimum code for reproducing. Prepares a project as tutorials, then rewrites src/App.js
as follows:
import { Client } from 'boardgame.io/react';
import { Game, TurnOrder } from 'boardgame.io/core';
const Foo = Game({
setup: () => {
return {
players: {
'0': { },
'1': { },
},
};
},
moves: {
skip: (G) => G,
},
flow: {
turnOrder: TurnOrder.DEFAULT,
endTurnIf: () => true,
phases: [
{
name: 'a',
allowedMoves: ['skip'],
endPhaseIf: (G, ctx) => ctx.turn === 2,
},
{
name: 'b',
},
],
}
});
const App = Client({
game: Foo,
});
export default App;
then run npm start
, and open the web cli (localhost:3000).
then,
- initial state => turn is 0. currentPlayer is 0.
- do
skip()
=> turn is 1. currentPlayer is 1. - do
skip()
=> turn is 3 (expected to 2). currentPlayer is 1 (expected to 0).
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Turn goes twice when phase is end · Issue #193 - GitHub
Hi, I'm facing a problem. I set endTurnIf hook to always return true. When phase is end, it seems that the turn automatically...
Read more >Ending turns and phases - MTG Wiki - Fandom
To “end the turn” as the result of an effect is to perform an expedited process that skips nearly everything else that would...
Read more >Traffic Signal Timing Manual: Chapter 4 - Office of Operations
The most commonly used left-turn phase sequence is the "lead-lead" sequence which has both opposing left-turn phases starting at the same time.
Read more >Phases of the cell cycle (article) | Khan Academy
The cell goes through 4 steps (prophase, metaphase, anaphase, and telophase.) The cells at the end of the process also have the same...
Read more >Ruleshammer: Unusual Fight Phases, what units come first ...
Lastly if there's a combination of a “Fight Again at End” and “Fight Twice” abilities then those units can fight twice again, potentially...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Fixed now (will be available in the next release). Thanks again for the report!
Thanks for the report (and especially for the steps to reproduce)! Will take a look in the next couple of days.