Pig (card game)
June 18, 2022 ยท View on GitHub
Pig is a simple, collecting card game of 20th century American origin suitable for three to thirteen players that is played with a 52-card French-suited pack.
Forked from this commit of pig-dice-game (I entered the wrong commit message).
Development
npm installdocker-compose up -d- For local redis environmentnpm start- Navigate to one of the following:
Forking (on different GitHub account)
- Click the fork button
Forking (on same or different GitHub account)
- Create new empty repository on GitHub (or whatever)
git clone https://github.com/nick-ng/pig-card-game.git <new-repo> && cd <new-repo>- Change
pig-card-gameto whatever you want and change my name to your name or something. git add . && git commit -m "anything. this will get squashed in the next step"git reset $(git commit-tree HEAD^{tree} -m "forked https://github.com/nick-ng/pig-card-game")git remote remove origingit remote add origin <url-of-repo-you-made>git push --set-upstream origin main- Change branch permissions etc.
Deploying to Heroku
- Create an empty Heroku App. Note the app's name
- Get your Heroku API key from https://dashboard.heroku.com/account
- On GitHub repo for your fork, go to the Settings and click on Secrets > Actions
- Add 3 new repository secrets
HEROKU_API_KEY: API key from aboveHEROKU_APP_NAME: App name from aboveHEROKU_EMAIL: Email address of your Heroku account
- Push a commit to the
mainbranch.
ToDos
Check this GitHub Project for details.
Notes
Game State
On the server
{
"id": "1234-12345-12345-1234",
"host": "player-1's-uuid",
"maxPlayers": 26,
"players": [
{ "id": "player-1's-uuid", "name": "Alice" },
{ "id": "player-2's-uuid", "name": "Bob" },
{ "id": "player-3's-uuid", "name": "Charlie" }
],
"gameSettings": {
"cardsPerPlayer": 4
},
"gameSecrets": {
"player-1's-uuid": {
"password": "asdf",
"chosenCard": "",
"cardsInHand": [
"card-1's-uuid",
"card-4's-uuid",
"card-8's-uuid",
"card-12's-uuid"
]
},
"player-2's-uuid": {
"password": "bsdf",
"chosenCard": "card-2's-uuid",
"cardsInHand": [
"card-2's-uuid",
"card-3's-uuid",
"card-7's-uuid",
"card-11's-uuid"
]
}
},
"gameSecrets": {
"fullDeck": ["card-1's-uuid", "card-2's-uuid"]
},
"gameState": {
"state": "main",
"seatOrder": ["player-1's-uuid", "player-3's-uuid", "player-2's-uuid"],
"chosenCardPlayers": ["player-2's-uuid"],
"cardMap": {
"card-1's-uuid": "A",
"card-5's-uuid": "B",
"card-9's-uuid": "C"
}
},
"lastActionId": "0-0"
}
Sent to Alice
{
"id": "1234-12345-12345-1234",
"host": "player-1's-uuid",
"maxPlayers": 26,
"players": [
{ "id": "player-1's-uuid", "name": "Alice" },
{ "id": "player-2's-uuid", "name": "Bob" },
{ "id": "player-3's-uuid", "name": "Charlie" }
],
"gameSettings": {
"cardsPerPlayer": 4
},
"yourSecrets": {
"password": "asdf",
"chosenCard": "",
"cardsInHand": [
"card-1's-uuid",
"card-4's-uuid",
"card-8's-uuid",
"card-12's-uuid"
]
},
"gameState": {
"state": "main",
"seatOrder": ["player-1's-uuid", "player-3's-uuid", "player-2's-uuid"],
"chosenCardPlayers": ["player-2's-uuid"],
"cardMap": {
"card-1's-uuid": "A",
"card-5's-uuid": "B",
"card-9's-uuid": "C"
}
}
}
WebSocket API
If you get disconnected, you need to reconnect and re-listen to the game. You'll still be in the game so you don't need to rejoin it.