oniskanen / webludo-server Goto Github PK
View Code? Open in Web Editor NEWA Phoenix backend for beer-Ludo
A Phoenix backend for beer-Ludo
The fix here would be to store the chat messages on the server and update the client once it comes back online. To do this properly, we'll need end-to-end encryption for the messages so that we don't store them in a readable format
Solution is to add a short (500ms?) debounce on the server side.
If one goes to https://webludo.katris.dev, writes a random string to the name of the game, and presses join, the player is directed to a page for a game that is non-existent. (see attached screen shot for the non-existing game)
A really minor issue, but might be confusing for some.
Trying to roll out of turn should give a penalty with a corresponding announcement
I don't if it even should it be possible at this point :)
But, moments ago tested playing with 3 players on the live site at https://webludo.katris.dev/.
After creating a new game, players were able to join the game. The first player started with only 3 players were present. They were able to start the game and get their first piece moving. But after their turn, it seemed like it became the missing 4th players turn. No present player got a chance to throw or move after that.
Current 1.10 only receives security updates.
Current logic allows incrementing and decrementing a collective team penalty value. We should keep incrementing team penalty as is, but allow players individually to mark their own penalties done. Team remaining penalties can be calculated by # total team penalties - (sum # player penalties done) / team player count
Compiling the project gives the following warnings:
oniskanen@Demeter webludo-server % mix local.rebar
warning: use Mix.Config is deprecated. Use the Config module instead
│
8 │ use Mix.Config
│ ~~~~~~~~~~~~~~
│
└─ config/config.exs:8
warning: Mix.Config.config/2 is deprecated. Use the Config module instead
│
10 │ config :webludo,
│ ~~~~~~~~~~~~~~~~
│
└─ config/config.exs:10
warning: Mix.Config.config/3 is deprecated. Use the Config module instead
│
14 │ config :webludo, WebLudoWeb.Endpoint,
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
│
└─ config/config.exs:14
warning: Mix.Config.config/3 is deprecated. Use the Config module instead
│
22 │ config :logger, :console,
│ ~~~~~~~~~~~~~~~~~~~~~~~~~
│
└─ config/config.exs:22
warning: Mix.Config.config/3 is deprecated. Use the Config module instead
│
27 │ config :phoenix, :json_library, Jason
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
│
└─ config/config.exs:27
warning: Mix.Config.import_config/1 is deprecated. Use the Config module instead
│
31 │ import_config "#{Mix.env()}.exs"
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
│
└─ config/config.exs:31
warning: use Mix.Config is deprecated. Use the Config module instead
│
1 │ use Mix.Config
│ ~~~~~~~~~~~~~~
│
└─ config/dev.exs:1
warning: Mix.Config.config/3 is deprecated. Use the Config module instead
│
4 │ config :webludo, WebLudo.Repo,
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
│
└─ config/dev.exs:4
warning: Mix.Config.config/3 is deprecated. Use the Config module instead
│
18 │ config :webludo, WebLudoWeb.Endpoint,
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
│
└─ config/dev.exs:18
warning: Mix.Config.config/3 is deprecated. Use the Config module instead
│
55 │ config :webludo, WebLudoWeb.Endpoint,
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
│
└─ config/dev.exs:55
warning: Mix.Config.config/3 is deprecated. Use the Config module instead
│
66 │ config :logger, :console, format: "[$level] $message\n"
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
│
└─ config/dev.exs:66
warning: Mix.Config.config/3 is deprecated. Use the Config module instead
│
70 │ config :phoenix, :stacktrace_depth, 20
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
│
└─ config/dev.exs:70
warning: Mix.Config.config/3 is deprecated. Use the Config module instead
│
73 │ config :phoenix, :plug_init_mode, :runtime
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
│
└─ config/dev.exs:73
Current Gigalixir-based infra has a major issue in needing to be spun up before playing. Using a combination of Azure Container Apps and serverless Azure SQL should allow the backend to spin up on-demand without manual interaction.
Currently any other player can call out a missed "Jag bor i Hembo" call after the move animation has started for the move. As per the regular rules, the player calling Hembo has time until the next roll to call it. In addition, there should be a short grace period for calling "Jag bor i Hembo" without a penalty even after someone calls a missed Hembo.
Current test output prints dozens (hundreds?) of warnings that make it difficult to spot actual issues. Clean up time!
Miska had 3 ylintä maalipaikkaa, oli syöntiruudussa, tuli 6 ja korotusmahdollisuus, mutta painettiin roll mutta tuli vielä uusi roll
Let's improve the random number generator distribution to more closely mirror the real life Pop-o-Matic. Two studies on the topic: https://kvantti.ayy.fi/archive/2013_3.pdf (p. 23) and http://statistition.com/?p=440
The actual probability distribution is most likely out of reach for this hobby project, but giving the same number at 1/13 - 1/9 probability, neighboring numbers at uniform 1/6 to slightly below 1/6 and the opposite number at 1/4 - 1/3 probability is probably "good enough".
We'll need to track the previous roll across game changes to support this, but that shouldn't be too tricky.
oniskanen@Demeter webludo-server % mix credo
Checking 36 source files ...
Software Design
┃
┃ [D] → Found a TODO tag in a comment: # TODO: In 2 team games, assign teams opposite one another
┃ lib/webludo/logic.ex:1010 #(WebLudo.Logic.start_game)
┃ [D] → Found a TODO tag in a comment: # TODO: Investigate property based testing for broader
┃ coverage of different situations
┃ test/random/random_test.exs:6 #(WebLudo.RandomTest)
┃ [D] → Found a TODO tag in a comment: # TODO: Move tests that do not deal with teams to game_test
┃ test/logic/game_setup_test.exs:1 #()
Code Readability
┃
┃ [R] ↗ The condition of `if` should not be wrapped in parentheses.
┃ lib/webludo/logic.ex:914:5 #(WebLudo.Logic.agree_to_new_raise)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃ lib/webludo/logic.ex:287:8 #(WebLudo.Logic.is_move_onto_given_pieces?)
┃ [R] → Modules should have a @moduledoc tag.
┃ test/support/test_helpers.ex:1:11 #(WebLudo.TestHelpers)
┃ [R] → Modules should have a @moduledoc tag.
┃ lib/webludo_web/channels/lobby_channel.ex:1:11 #(WebLudoWeb.LobbyChannel)
┃ [R] → Modules should have a @moduledoc tag.
┃ lib/webludo_web/channels/game_channel.ex:1:11 #(WebLudoWeb.GameChannel)
┃ ... (11 more, use `--all` to show them)
Refactoring opportunities
┃
┃ [F] → Function body is nested too deep (max depth is 2, was 3).
┃ lib/webludo_web/channels/game_channel.ex:66:13 #(WebLudoWeb.GameChannel.handle_in)
┃ [F] → Cond statements should contain at least two conditions besides `true`, consider using `if`
┃ instead.
┃ lib/webludo/logic.ex:371:5 #(WebLudo.Logic.next_team_recurse)
┃ [F] → Function body is nested too deep (max depth is 2, was 4).
┃ lib/webludo/logic.ex:585:26 #(WebLudo.Logic.execute_move)
┃ [F] → Function body is nested too deep (max depth is 2, was 3).
┃ lib/webludo/logic.ex:1045:22 #(WebLudo.Logic.start_game)
┃ [F] → One `Enum.filter/2` is more efficient than `Enum.filter/2 |> Enum.filter/2`
┃ test/support/test_helpers.ex:90 #(WebLudo.TestHelpers.get_game_fixture)
┃ ... (12 more, use `--all` to show them)
Please report incorrect results: https://github.com/rrrene/credo/issues
Analysis took 0.8 seconds (0.09s to load, 0.7s running 55 checks on 36 files)
186 mods/funs, found 17 refactoring opportunities, 16 code readability issues, 3 software design suggestions.
Showing priority issues: ↑ ↗ → (use `mix credo explain` to explain issues, `mix credo --help` for options).
Some announcements would come logically only after the frontend has finished animations. Let's add a new delayed_animations
object under changes
whenever broadcasting a new game_updated
event.
This will allow building a frontend check when joining a game in the lobby. (Current flow navigates to the game page and shows a no game found error)
When all players have agreed on a new raising round, there should be an announcement saying so.
Currently if a player closes the page, the rest of the players do not get any indication that they aren't playing
To start the CI pipeline work, tests should be executed whenever a PR is opened or updated.
Multiple players should be able to join a single team. Initially we should target having the possibility to join a random team or join a pre-determined team.
On the frontend side, this will expand the pre-game selections quite a bit. Setting a name and clicking "Join" will enter you into the list of players, but without a set team. You will be able to toggle whether you wish to play or only spectate. You will be able to manually join a team # 1-4. The creator of the game will be shown as the host, with additional options. The host can choose to manually or randomly assign the players into teams. The game starts when the host clicks "Start game" (and there is at least one team set). When starting the game, the numbered teams are randomly assigned a team color and a random team is chosen as the starting team.
For the backend implementation, we need to split Player
into Player
and Team
. Team
contains 1..n
Players
. A Player
has a name and can roll for / choose to move pieces / choose to agree to a new raising round / mark penalties done. A Team
accumulates penalties and each Player
can mark penalties done, accumulating their personal finished penalties (which are summed and compared to the Team
penalties to see if the team has finished).
There's a potential pitfall with two or more players simultaneously finishing penalties summing up to more than the required amount. Allowing marking fractional penalties might help.
A Player
will be able to toggle whether or not they wish to participate in the game, which is recorded as a new database field.
Maybe on refresh due to the react app updating?
Allowing players to choose different rules during game setup has been raised a few times now.
Some initial variants:
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.