Boardgame.io: Implement a Pass event

Created on 27 Sep 2019  路  7Comments  路  Source: boardgameio/boardgame.io

This will be simple event that merely ends the turn and also removes the player from ctx.playOrder.

feature good first issue

Most helpful comment

@danielimmke A pass is similar to a no-op move that merely calls endTurn (and you can in fact create a move to do exactly this). However, it also accomplishes another important thing which is to remove the player from playOrder. This will cause the turn to skip over the player the next time it comes around. It's also possible to simulate this using a move and a custom turn order, but we're merely formalizing this into a convenient event that makes it easier for users.

Now that I think about it, it probably makes sense to support two behaviors (one that removes the player from the turn order and one that does not):

1. pass()

Identical to endTurn().

2. pass({ remove: true })

Also removes the player from playOrder. Once playOrder is empty, we should automatically end the phase.

As far as the implementation is concerned, I would recommend just calling endTurn directly from the "pass" event rather than duplicating any logic.

All 7 comments

Could this also be used as a "surrender" event?

Or can we make the ctx.playOrder removal optional and/or add a callback for after this?

I think a surrender event might be better implemented as a plugin because it needs to store state (while the pass event is stateless).

What do you mean by making the removal from playOrder optional? I would think that it is necessary to do that to implement a pass move, no?

I'd like to work on this. I've been onboarding onto the codebase and think I could have a PR within the week for it.

Thanks @danielimmke. Looking forward to it.

Hey @nicolodavis thanks for replying. I have a very basic version of this working but wanted to make sure I 100% understood the requirements before submitting a PR. A "Pass" to me is just the same as ending a turn without doing anything. So I created a new event but copied the EndTurn method and removed the check that stops EndTurn from happening (around the comment // Prevent ending the turn if moveLimit haven't been made.)

This seems to work in my testing. It increments the turn and switches the player. I wanted to make sure I wasn't missing something. The other question I had was, it seems like a move calls endTurn automatically at the end. Could a user implement this functionality right now by just creating a move called pass that doesn't do anything? Are we just formalizing that as an event?

@danielimmke A pass is similar to a no-op move that merely calls endTurn (and you can in fact create a move to do exactly this). However, it also accomplishes another important thing which is to remove the player from playOrder. This will cause the turn to skip over the player the next time it comes around. It's also possible to simulate this using a move and a custom turn order, but we're merely formalizing this into a convenient event that makes it easier for users.

Now that I think about it, it probably makes sense to support two behaviors (one that removes the player from the turn order and one that does not):

1. pass()

Identical to endTurn().

2. pass({ remove: true })

Also removes the player from playOrder. Once playOrder is empty, we should automatically end the phase.

As far as the implementation is concerned, I would recommend just calling endTurn directly from the "pass" event rather than duplicating any logic.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

julienroulle picture julienroulle  路  9Comments

jchadwick picture jchadwick  路  4Comments

bliu13 picture bliu13  路  8Comments

br0p0p picture br0p0p  路  4Comments

adngdb picture adngdb  路  5Comments