Bringing Down the Landlord - A Chinese Card Game
Fresh off the success of my recent multiplayer Ultimate Tic-Tac-Toe, I wanted to see how far I can go with PeerJS. As such, I've decided to create an old Chinese card game called Bringing Down the Landlord, or 斗地主.
This is a game I frequently play with my grandparents and extended family. It was created during the Chinese Communist Revolution, if you're wondering about the name. The game itself is a shedding type game (like Uno) played with three people - I move more detailed instructions here.
A story I've never told before is that the first game I ever coded period was a card game - War. I never posted it, mainly because it was entirely text-based and really bad. Immediately after that, I used what I had learned to make Blackjack, which I do have on here, listed in the menu after Tetris. Chronologically, that's the earliest game I made hosted on this site. I bring this up now because despite all my first games being card games, I haven't made a single game involving cards since then. It felt like a nice return to form to be dealing with Fisher-Yates Shuffles and modding by 13 to get rid of card suits again.
Of course, given that years had passed since Blackjack, I wanted to see if I could go beyond just aligning .gif files in a table. So I made my own playing cards in CSS. They were rather heavily inspired by this set I found on Google called Helveticards, and while my cards aren't perfect, I'm okay with how they turned out. I threw them up on CodePen here. On top of that, cards also smoothly transition onto and off of screen, collapsing and layering on top of each other to save space as necessary. It's a nice effect. Also, apparently unicode has characters for every single playing card now, so my cards all have unicode-compliant fallbacks in case CSS breaks somehow.
However, since PeerJS runs off WebRTC, a one-to-one connection, running a game for three people unfortunately is going to have some issues. Since I can't route everyone through a single, central server, instead, the host of the game is in charge of relaying messages from one player to the other. This requires two connections from the host, meaning the host gets two different game codes that they need to share - one per player. It's an unfortunate workaround, but it works.
Finally, since this is a Chinese game, I found it only appropriate to attempt to localize it. The entire game can be swapped into Chinese at the click of a mouse. Since I just went in and directly translated everything, some of the phrasing in Chinese is still a bit stilted right now. I'll smooth those out in the coming days. Also on the way is mobile support - after all, my grandparents all use iPads.
In other news, my web host seems to be going through some instability right now, which CloudFlare's strict SSL rules didn't like, so CloudFlare is temporarily disabled. The only real difference you may notice is that my site might be kind of slow for a few days and also if you don't type https in the URL, the website won't redirect you. I'm hoping to have this fixed within a few days.
Posted By: Michael Xing