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

How to create actions for not-current player #132

Closed
janosimas opened this issue Mar 6, 2018 · 6 comments
Closed

How to create actions for not-current player #132

janosimas opened this issue Mar 6, 2018 · 6 comments

Comments

@janosimas
Copy link
Contributor

Hi, I'm implementing a game to test the framework and it's great
but I'm having some issues...

How can I create a move that another player execute?
Like, force another player to chose and discard a card.

How to create a turn with fixed phases?
phase 1 -> phase 2 -> end turn
I used endPhaseIf in phase 1 and it goes to phase 2
if I use the endTurnIf in phase 2, the next turn is in phase 2, not in phase 1.

@Stefan-Hanke
Copy link
Contributor

I think a combination of a custom turn order, the FlowWithPhases, and some custom logic inside your game could do the trick. Can you show some code?

@janosimas
Copy link
Contributor Author

I didn't start this action, as I just started to learn the framework there are a lot of changes I'm making every review.

This is the code repository: https://github.com/janosimas/dominion

The 'normal' turn has two phases, an action phase for playing action cards and a buy phase to buy new cards for your deck. The action cards I'm testing are the more simple ones, draw cards, increase number of actions...
But there are other cards that, for example, make the opponents choose and discard cards.

If I understand right, I would have to have a phase for each different complex action with different allowed moves. The turn of the player who played the card would end, and would be the turn of the player who should discard, then go back to the player who is playing.
Is that right?

How can I change to an specific phase, not just 'flow' to the next?

@Stefan-Hanke
Copy link
Contributor

Yeah, my initial guess was that you're on a Dominion clone and were speaking about the Militia card.

From the source, it looks like returning a phase name from endPhaseIf will start that phase instead of flowing to the next.

However, the phase framework was (IIRC) made for games like Catan were you have a dedicated setup phase (placing initial houses) and a play phase. I'd personally liked when games are enabled to stick to their terminology, it'll make everything downstream easier to reason about.

The game needs to lead the framework to believe that another player is on turn - it does not allow moves from another player other than the current one. This makes problems because in a multiplayer Dominion, each other player could make their move, however the framework currently dictates the next one on turn. That would have to be stretched a bit framework-side, for now I'd stick to a two-player only game.

@Stefan-Hanke
Copy link
Contributor

The flow of playing Militia would go along the lines:

  • Player A plays Militia
  • This state is stored in G somewhere
  • The custom Turnorder make the player that needs to act on Militia the next player
  • That player now is only allowed to drop cards down to three, which finishes his turn
  • The custom Turnorder returns control to Player A.

To keep the notion of a "turn", a kind of "subturn" is necessary. Perhaps a custom flow implementation is in order for this to work properly.

I'd very much see this implementation come true, however I'll have no time this WE - busy playing board games ;-)

@nicolodavis
Copy link
Member

Just to add to what @Stefan-Hanke has already addressed here:

The game state is managed by a state machine. It can be in one of many phases and the current player can be in one of many states. You can model many turns within a phase (Catan), or many phases within a turn (Dominion). The concept of phase and turn are independent of each other.

The framework provides many ways to transition between these states. The easiest way to transition is to use the events:

  • endTurn
  • endPhase

These transition the game using a round-robin order (when you end the turn, it flows to the "next" player; when you end the phase, it flows to the "next" phase).

If you want behavior that's different from this, you need a custom turn order. Stefan's reply above shows you how you can leverage it to implement the Militia card.

I do think it would be nice if we can change the current player without ending the turn. I'll add this as a feature request.

Also note that the special string "any" is used to indicate that any player can play right now (asynchronously). This will be necessary to implement cards like Pirate Ship.

@nicolodavis
Copy link
Member

Closing this in favor of #141

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants