Recommendations on Coding the "First Come First Served" Mechanic in a Card Game

Game development with Board Game Arena Studio
Post Reply
User avatar
thejonmonte
Posts: 3
Joined: 11 November 2023, 08:43

Recommendations on Coding the "First Come First Served" Mechanic in a Card Game

Post by thejonmonte »

Hello,

I'm thinking about creating a card game that I've played extensively with family and friends. The game is called Cambio (link to rules here: https://cambiocardgame.com/), and it is a memorization type card game where you have to end up with the lowest point value cards.

The main issue that arises with this game, however, is the common "first come first served" mechanic (for lack of a better word). In the game, there's a stacking rule where players compete to be the first to match the value of the most recently discarded card by placing a card of the same value onto the pile. Only the first player to successfully match the value can perform this action. Any subsequent attempts by other players to match the value after the first player has done so result in penalties.

This mechanic is present in games like Slapjack where the first person to slap the jack gets the card, or in Uno where the player with one card remaining must say "Uno!" before another player has, otherwise they receive another card as a penalty.

How would I code this mechanic with the BoardGameArena developer tools? I'm wondering about issues like network speeds in resolving who is the first person to do the action. I was thinking of having the player generate the timestamp client-side and send it to the server, then taking the lowest timestamp to determine the first person. However, I'm not sure if that's scalable with many players/mulitple concurrent games.

Any help on approaching this topic would be greatly appreciated :D Thanks!
User avatar
Jonathan2004
Posts: 23
Joined: 21 April 2020, 19:06

Re: Recommendations on Coding the "First Come First Served" Mechanic in a Card Game

Post by Jonathan2004 »

Hi,

On BGA, there is not many games with speed involved. I know only 1 called "Dobble", see https://boardgamearena.com/gamepanel?ga ... y_seemore=
User avatar
RicardoRix
Posts: 2121
Joined: 29 April 2012, 23:43

Re: Recommendations on Coding the "First Come First Served" Mechanic in a Card Game

Post by RicardoRix »

I think the easy answer is, that you just assume everyone has the same stable network connection and associated time delays. No client-side timing.
Otherwise, client side timing things would need to be encrypted perhaps to ensure authenticity. Even then how to do you stop hackers from resetting timers and the like? You may just need to ignore that possibility.
Ultimately I think you can do whatever you like. It will be up to users to take or leave whatever method you employ.

There is Reflection another BGA game where players race to complete a grid puzzle. And Concept as well.
User avatar
cigma
Posts: 911
Joined: 15 December 2020, 00:30

Re: Recommendations on Coding the "First Come First Served" Mechanic in a Card Game

Post by cigma »

Maybe you can find something like this programmed in the game Solo https://boardgamearena.com/gamepanel?game=solo, which is quite the same as Uno.
Players generally play 1 card in turn order, but if someone has the exact same card in hand as the last card played, they are allowed to play this identical copy - if they can play it faster than the next player in turn order can play their card. If they succeed, turn order switches to them (i. e. players in between are skipped).
EDIT: Solo also has this last card mechanism as in Uno.

Another game of this kind "First Come First Served" is Panic Lab https://boardgamearena.com/gamepanel?game=paniclab. Players have to deduce the right answer to a puzzle and compete for being first (within seconds, somewhat equal to "Dobble").
Last edited by cigma on 13 April 2024, 04:27, edited 2 times in total.
#zan_zendegi_azadi / #woman_life_freedom
#StandWithUkraine
Language is a source of misunderstanding. (Antoine de Saint-Exupery: The Little Prince) But it is also the source of understanding - it all depends on how you use it. :-)
User avatar
thejonmonte
Posts: 3
Joined: 11 November 2023, 08:43

Re: Recommendations on Coding the "First Come First Served" Mechanic in a Card Game

Post by thejonmonte »

Thank you all for your responses. How can I view the code for these existing games? I got read-only access for these games in Studio. When I go to "Manage games," I see the games listed but don't see an option to view the source code.
User avatar
RicardoRix
Posts: 2121
Joined: 29 April 2012, 23:43

Re: Recommendations on Coding the "First Come First Served" Mechanic in a Card Game

Post by RicardoRix »

after you get read-only access. The source folder will be available to download via FTP.
User avatar
quietmint
Posts: 265
Joined: 31 July 2017, 00:28

Re: Recommendations on Coding the "First Come First Served" Mechanic in a Card Game

Post by quietmint »

The client's clock is certainly wrong. Visit https://time.gov/ and look at "Your Device's Clock". My Android phone is 3 seconds fast and my Windows 11 laptop is 17 seconds fast. Inside Windows 11 "Date & Time" settings it shows the last successful network time synchronization (mine was 16 days ago, despite daily use of the device). This is just unintentional clock drift and says nothing of cheaters who could purposely manipulate their clock.

The short answer is your game should simply process requests in the order in which they are received. There's nothing particularly special you need to do for this. When you game receives the request from the client, you'd generally persist something in the database, send a notification to inform users, and execute a state transition. If multiple requests arrive around the same time, only one should succeed and all others should fail. Assuming the same state transition isn't possible from both the old state and the new state, you probably get this "for free" from BGA framework since the first request should perform the transition properly and the other later requests should be unable to perform the transition (receiving some error). If your situation isn't like this and isn't handled automatically (maybe you don't perform a state transition for this action) then instead you can check the state of the cards in the database (or whatever else you're persisting in the database) before taking the action to verify things are correct. For example, maybe the action moves a card, so you need to check the current location of the card to determine if the action is still possible or if another player already moved the card ahead of you.
Post Reply

Return to “Developers”