Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a Pass event #477

Closed
nicolodavis opened this issue Sep 27, 2019 · 7 comments
Closed

Implement a Pass event #477

nicolodavis opened this issue Sep 27, 2019 · 7 comments

Comments

@nicolodavis
Copy link
Member

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

@blunket
Copy link
Contributor

blunket commented Oct 2, 2019

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?

@nicolodavis
Copy link
Member Author

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

@nicolodavis
Copy link
Member Author

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?

@danielimmke
Copy link
Contributor

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.

@nicolodavis
Copy link
Member Author

Thanks @danielimmke. Looking forward to it.

@danielimmke
Copy link
Contributor

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?

@nicolodavis
Copy link
Member Author

@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.

@danielimmke danielimmke mentioned this issue Oct 13, 2019
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants