Page 1 of 1

[ANSWERED] Advise for Game State

Posted: 05 April 2021, 11:43
by Badguizmo
Hello.

I am actually developping "Riftforce" (yep, again :D ).
I have create the "basic" GameStates but I have a question :

In the game, the players have to choose 1 of 3 differents actions
1 - Play 1-3 card
2 - Activate 1-3 cards
3 - Check points.

For now I have created 4 GameStates
- 1 for letting the player choose which action he wants to perform
- 1 for each of the 3 actions.

For action 1 and 2, the players
1 - select 1 card from hand
2 - play it or activate it (i.e. : place it on the board, or select 1 card on the board)
3 - if less than 3 cards played, he can play/activate another card

What is better/easier ?
1 - Having 2 differents GameStates for action1 and 2 for step 2 (1 for select a card and the second to play it)
2 - Having only 1 GameState for each action(which can be named "Action-PlayCard" and "Action-ActivateCard)

For me the solution 1 helps on database saving action on Server side as there are separated gamestate. But it require more code (or not) to perform an "Undo / Redo turn".
The solution 2 could be easier to perform an undo (most is done on the client side) but maybe need more checks at the end of the turn.

Or maybe there is no good solution, only 2 (or more) different ways to do it.

Thank you in advance ;)

Re: Advise for Game State

Posted: 05 April 2021, 13:33
by tchobello
hi...

your game is not the easiest one to begin with but surely your favourite one: a common beginner mistake.

I'm not sure States work that way...

in a Player Turn :
you can select 1-3 cards from your hand and a place on board to play them. (click on cards and 'play' button )
you can activate a card on the board (click on board and 'activate' button )
launch the points calculation ('points' button)
these are client side actions.
that's all part of the same game state : Player Turn
you go then to server side via ajax :
can modify DB, can notify to display some stuff on client side, choose transition to another Game State.

if the player can still do some actions, you do a transition to the same state.
il the player has finished his actions, you do a transition to a EndTurn 'game' State where you change active player and then a transtion to 'playerturn' state for the other player to play his actions...

you don't really need to keep track of the action made... previous location & location_arg might be enough.
remember that game has to be fluid so if you ask player to validate their actions, you should not allow them to undo as they can check cards & places selected before validating...


good luck !

Re: Advise for Game State

Posted: 05 April 2021, 19:23
by Badguizmo
Hello.

For sure, not the easiest ;)
For the moment I am confident.

About the "undo" it is, for the moment, a request from the editor.
As soon as these steps are coded, I will check with them :D

Indeed I have define some different gamestates. I will re-check the guidelines about the gamestates.

Thanks for the precisions ^^

Re: Advise for Game State

Posted: 05 April 2021, 19:51
by paramesis
I disagree that starting with a game you like, and more importantly are motivated by, is a mistake. I would recommend running through enough steps of one of the tutorial projects to get the gist of basic concepts like game states and how information is conveyed and stored, but you shouldn't have to plod through the entire development process of an abstract you don't care about. Based on the frequent posts and activity, you don't seem to be discouraged by the challenge. Best of luck!

As for implementing undo, if a player's turn involves multiple actions that don't require input from the other player, it might be a good candidate for database undo.

Re: Advise for Game State

Posted: 05 April 2021, 20:07
by tchobello
paramesis wrote: 05 April 2021, 19:51 I disagree that starting with a game you like, and more importantly are motivated by, is a mistake.
I've never said something like this...
RiftForce is not an easy game to implement for a true beginner.

Re: Advise for Game State

Posted: 08 April 2021, 00:20
by Victoria_La
In my personal experience - if its not too many possible action (i.e. by the rulebook) I will do action per state, i.e
playCard
activateCard

But it starts getting more complex then you can reduce the number, i.e. for example if in game activateCard can be played out of turn,
or during passing or some other weird way - then you don't actuallyt know which state it was when you call it and it becomes mess and
state and actions would not align 1:1. It does not seems to be the case here.

Re: Advise for Game State

Posted: 09 April 2021, 01:02
by Badguizmo
Thank you all ;)