dnsbty / level10 Goto Github PK
View Code? Open in Web Editor NEWPhoenix LiveView multiplayer card game
Home Page: https://level10.games
License: MIT License
Phoenix LiveView multiplayer card game
Home Page: https://level10.games
License: MIT License
Currently we show a scoring screen after every round with the scores and level. We should also create a screen for the end game that will display the final scores.
If a user selects a valid combination of cards and then taps on a group, those cards should be added to the specified group
We should probably put some sort of cap on the number of players that can join a game. I feel like 5 players is ideal, but we should be able to support up to 6 per game.
If a player selects one or more cards in their hand and then taps on a group that has already been completed, the selected cards should be attempted to be added to the specified group.
This will get a little more complicated with wilds if we want to make it so that wilds are in a static position and can't be replaced.
During the game, we should make sure that cursors always show the possibilities. The pointer cursor should be used for anything that is clickable at the moment, and the default cursor should be used otherwise.
Create a function that will take in a game struct and do the following:
Currently groups are validated, but wilds aren't taken into account. Add wild usage into the group validation logic.
We should add an indicator to show the size of each player's hand so that it will be more obvious if someone is getting close to completing the current round. This will also take care of the problem with seeing whether or not a player has drawn yet.
Rather than this, it should rotate and have a different player to first each round to make it more fair
We should track the number of users that are currently connected, whether in a lobby or game. That number should be exposed on the LiveDashboard so that we can log in and see that number easily
See the active_users
example at the bottom of this section of the telemetry docs: https://hexdocs.pm/telemetry_metrics/Telemetry.Metrics.html#module-vm-metrics
In iOS Safari, tapping on a table to add a card doesn’t work
Having game state in an Agent was great for getting up and running quickly, but we can probably tune things a little better if we move into a GenServer.
We should make it so that games can be joined by a URL so that you can text out the URL rather than having to send the URL and join code separately
We should add a button to the lobby page that allows a user to invite someone via text message. It could prepopulate the text message body using this method: https://wire2air.zendesk.com/hc/en-us/articles/360022140831-Creating-a-Click-To-Text-link-that-sends-a-text-message
The message could be something like this:
Come play Level 10 with me!
https://level10.games/join/ABCD
Currently Presence is inaccurate if a user opens a second session with the same player ID and then leaves either session.
Rather than store only if a user is present or not, we should maintain a count of the user's presences, and only remove them if that count reaches 0.
Right now if the creator leaves the game while in the lobby, the game becomes unplayable because no one else can start it. We should change it so that the next player in the list will become the creator at that point.
If there is no one else left in the list of players, we should then go ahead and delete the game.
We should have a function that starts a new round. This would take in a game struct and move it to the next round. It should do the following:
We should display a scoring page with all of the players in a game, their current level, and current score displayed. The screen should also have a button to go to the next round as soon as all the players are ready.
We should also link the "Check the Scores" button from the "Round Complete" modal to take the players to this page.
We should probably add a bunch of telemetry events for better observability:
We should show a place for the user to put their cards in order to complete the level
Whenever a player discards a card or plays new cards to the table, check to see if they have any cards left in their hand. If not, mark the round as ended.
We'll want a struct for managing the state of the game. This will depend on #1 and #3. I'm seeing this looking something like the following:
%{
"Dennis" => [
{:set, [%Card{}, %Card{}, %Card{}]},
{:run, [%Card{}, %Card{}, %Card{}]}
]
}
Allow users to send selected cards to a group on the table.
This should allow them to click on a group with the proper cards selected. It should validate that the selected cards meet the group criteria, and if they do, move them out of their hand and into the group on the table.
Currently we're just assuming that the player in question has the cards specified in their hand. The server should verify that any cards being played exist in the player's hand before taking them out.
If the top card in the discard pile is a skip, don't allow players to pick it up.
We should add Phoenix Presence to be able to detect if a player is currently online. This way the other players will know if they need to tell them it's their turn or not.
Any time the discard pile is drawn from or discarded to, the PubSub should be updated and the game process should update the display
When a game is finished, it should be automatically closed out so that finished games won't use up memory on the server.
We should display the draw pile and discard pile on the game screen
We should display a list of players on the game screen along with the requirements each player has to complete the current level.
When a skip card is discarded, the player whose turn would normally be next is instead skipped over so the turn goes to the next player.
Once it’s a new player’s turn it should reset whether the player has already drawn or not so that they can draw again without refreshing
We want to be able to close out a game. This should remove the game process and its state from the server.
Whenever a player attempts to join a game that doesn't exist, the live view process appears to be crashing. We should handle that crash and display an error message.
I believe that we did this previously, but perhaps Horde's registry handles missing names differently or something like that.
Similar to #29 but also do it for live games
We'll want a struct for representing the users in the game. For the first version I see it having the following fields:
Further down the road, we might want more fields like:
Elixir's Registry only works on the local process. Swap it out with Erlang's :global
to set things up for clustering and make scaling possible.
:global
docs: http://erlang.org/doc/man/global.html
Relevant blog post: https://scottyscripts.com/2019/11/25/erlang-in-elixir-erlangs-global-module.html
Relevant Elixir Forum thread: https://elixirforum.com/t/genserver-and-global-registration/13344
Perhaps longer term, syn
should be considered instead based on these benchmarks but it seems like until we're seeing a ton of traffic, :global
ought to work just fine
Rather than store the player ID in the URL, we should store it in a cookie so that you can come back to the game if your battery dies or anything like that and the URL gets corrupted
Whenever a round begins, we'll want to create and shuffle a deck. We'll probably also want to make sure we can use the shuffle functionality again in case the draw pile ever runs out so that we can shuffle the discard pile and move it to the draw pile.
So this should create a new deck:
Then it should shuffle that deck (or a different one that is passed in) so that the cards will be in a random order.
Depending on how we handle the levels in the Game struct, we'll want to have the basic templates set up for them somewhere else. Perhaps a Levels
module with a get function that takes in a level number and returns something like
[set: 3, run: 4]
or
[color: 7]
Right now errors are shown at the top of the page, so if a player is scrolled down they may miss the message
We'll want to create a struct to represent a card.
I think these should have three keys:
Firefox on Android seems to work fine but Safari and Chrome overlay the cards to where they aren’t legible
We should play a sound to indicate when it's your turn and get your attention in case you're playing in the background
Create a function that will validate if a list of cards meets the requirements to be a group
Show an indicator in the game view of whose turn it is. Potentially it could also be shown if they've drawn yet or not
We want to store game state in agents, and then use registries to find the proper agent based on a game code.
Whenever a run is played, we should track the position where each wild should belong so that it will be easier to see the range of the run. This would also allow for us to turn off wild replacement so that only the front and end of the run can be added to
Cards on the table should be sorted before being displayed so that runs will be in order and numeric cards will be most easily visible.
On the scoring page, display indicators next to players that have marked that they're ready for the next round so that it's more obvious who you're waiting on
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.