Question about implementing hearts (following after the tutorial)

Game development with Board Game Arena Studio
Post Reply
User avatar
taptothebeat
Posts: 1
Joined: 09 April 2016, 20:13

Question about implementing hearts (following after the tutorial)

Post by taptothebeat »

Hello! So I went through the hearts tutorial, and it seems to work to the extent it was meant to.

For my own understanding, I would like to be able to check if a card is valid when attempting to play (aka follow suit). And if it does not for a notification in red to appear, like how it does when you try playing a card when it is not your turn. Does anyone know how to do this? A code example would be fantastic, but any help or guidance at all would be appreciated.

My inclination is to put the logic in game.php's playCard, but unsure how to process the red notification while staying in the same state. My inclination could also be 100% wrong lol, so yup, thank you in advance. (:
User avatar
Victoria_La
Posts: 620
Joined: 28 December 2015, 20:55

Re: Question about implementing hearts (following after the tutorial)

Post by Victoria_La »

You can do server server side checks, it pretty simple, you just throw an user exception and text will show up in red.
State transition would not happen. Any db changes would be rolled back.

Code: Select all

        throw new BgaUserException(self::_('Bad move'));
Post Reply

Return to “Developers”