Jide Oyelayo
CV

Lab / Bug Poker

Bug Poker

What this demonstrates: My bluffing card game for two to six players in rooms of their own, kept in step live by a real-time database in which every move is one atomic update. It runs as its own app, not in this tab.

Abstract poster for Bug Poker: six circles round an oval, five grey rings and one red disc, with a dark card lying face down on a dashed line between the red disc and the ring opposite it.

Bug Poker is a bluffing card game I built to play with friends online. One player opens a room and gets a four-letter code; the others join with that code and a nickname, up to six at a table. Each player sees only their own hand on screen, and every move shows on everyone’s screen as it happens. It is a separate app, so it is not played on this page.

The link leaves this site for the game’s own app, in this tab. A game needs at least two players, each in a browser tab of their own, and a room is shared live with whoever has its code.

How a game goes

The 64 cards show eight kinds of creature, eight of each, and all of them are dealt out at the start; in a game for two, ten are set aside first. On your turn you pass one card face down to another player and say which creature it is, truthfully or not. Whoever receives it either calls the claim true or false, or looks at the card and passes it on, with a claim of their own, to a player who has not yet held it. A right call sends the card face up to the player who made the claim; a wrong one sends it to the caller. Whoever takes the card starts the next round. Four face-up cards of one creature lose the game (five in a game for two, where a card cannot be passed on), and so does taking a card with your hand already empty, as there is nothing left to start the next round with. A game ends when one player loses, and everyone else wins, or when the host ends it early.

How it is built

It is a Next.js app exported as static files and served from Firebase Hosting, with each room kept in Firebase’s Realtime Database. The rules of the game are one module of pure functions. Given the room’s shared state and, where a move needs them, the player’s own hand or the face-down card, each returns the database writes that make the move, or throws if the move is not allowed. The player’s browser sends those writes as one atomic update, and every browser in the room watches it and redraws when it changes. The module has 30 unit tests: the deal for two, four and five players, whose turn it is and who may be passed to, passing, looking and passing on, and calling, with the losing rules for two players and for more.

The database security rules in the game’s repository keep a room honest as far as rules can without a server. Every move is one atomic update that must raise the room’s version number by exactly one, so two moves made from the same state cannot both land, and the rules let only the players in the current turn, or the host, make a move. They let a player read only their own hand, and the face-down card only once it has been passed to them. The host’s browser deals, though, so it holds every hand at the start of a game: the game trusts the host, as it trusts every player.

There are no accounts to make. To tell players apart, the app signs each browser tab in to Firebase anonymously, with nothing to fill in: a refresh keeps your seat, and a second tab in the same browser can join as a second player. Apart from a room’s code, the only thing you type is a nickname. The database keeps it in the room, beside the tab’s anonymous id and the state of the game, and anyone with the room’s code can read it there, so use a nickname, not your full name. Your browser keeps the nickname and the tab’s sign-in in its session storage, which goes when the tab is closed. The game is a separate service that I run on Firebase, a third-party platform, which sees each connection to the game as any host does, and each tab’s anonymous sign-in also leaves a record with Firebase’s sign-in service, which nothing in the app deletes. This page itself makes no connection to the game or to Firebase.

Limits

Bug Poker is made for playing with people you know. The database decides who may write and who may read, but the rules of the game run in each player’s browser and the game trusts them, the host’s most of all: a player who tampered with their own browser could cheat, and guarding against that would take a server, which I left out to keep the game on Firebase’s free plan. Anyone who has a room’s code can join it while it waits to start and read what its table shows, so share a code only with the people you are playing with. Rooms, and the nicknames in them, are not deleted after a game.

The rules module is the only part with tests: the code that talks to the database, the security rules and the pages have none, and no test plays a game through. There is no chat, ranking, computer player or variant of the rules. The app is not part of this site and is not held to the accessibility checks this site’s pages pass. The source is not public yet, so there is no link to it, and there is no case study of this project.