Giter Club home page Giter Club logo

webludo-server's People

Contributors

oniskanen avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

webludo-server's Issues

Cannot play with less than four players

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.

Improvement: Track penalties per player

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

Redo deprecated Elixir Config usages

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

Migrate backend to Azure

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.

Improvement: Grace period for calling missed hembo

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.

Fix warnings in tests

Current test output prints dozens (hundreds?) of warnings that make it difficult to spot actual issues. Clean up time!

Extra roll granted to miska

Miska had 3 ylintä maalipaikkaa, oli syöntiruudussa, tuli 6 ja korotusmahdollisuus, mutta painettiin roll mutta tuli vielä uusi roll

Improvement: Simulating Pop-o-Matic probabilities

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.

Go through credo suggestions

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).

Improvement: Add delayed announcements

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_updatedevent.

CI: Fix test runner

To start the CI pipeline work, tests should be executed whenever a PR is opened or updated.

Feature: Add team support

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.

Feature: Game variants

Allowing players to choose different rules during game setup has been raised a few times now.

Some initial variants:

  1. Penalty on out of turn rolls
  2. Allowing suicide
  3. Fair vs pop-o-matic probabilities on rolls
  4. Choosing piece to send back during a raise
  5. Applying penalty at end of turn (when rolling several 6's and eating a piece in Start space)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.