Skip to content

Stabilize the game, add tests and rewrite the README - #10

Merged
Tinix merged 17 commits into
mainfrom
fix/stabilize-game
Nov 22, 2026
Merged

Tinix merged 17 commits into
mainfrom
fix/stabilize-game

Conversation

@Tinix

@Tinix Tinix commented Nov 22, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the bugs that broke the game outside the happy path, covers the rules with tests, and documents how to install and play it. The game mechanics are unchanged.

Bugs fixed

  • A second game could not be started, and moving without a game crashed.
  • Invalid players and invalid moves were accepted or crashed.
  • Moves could be made after game over or out of turn.
  • Simultaneous moves could corrupt a round: each round is now one atomic operation.
  • The game died with the process that started it: it is now supervised.
  • The reported damage is now the damage really applied.

Improvements

  • Readable round summary that announces the winner.
  • Pure game rules with injectable randomness.
  • @moduledoc, @doc, @spec and doctests.
  • Standard lib/ex_mon/ layout.
  • Elixir 1.20.5, OTP 29.1.2 and updated dependencies.
  • Credo configuration is now loaded (it was credo.exs), and Dialyzer was added.
  • CI runs every check, also on pull requests to main.
  • New README with installation steps for Linux and macOS and a complete example game.
  • Code of Conduct contact filled in.

Breaking changes

  • Requires Elixir 1.20.
  • make_move/1 returns {:error, reason} for rejected moves.
  • create_player/4 rejects non-string player names and invalid or duplicated move names.
  • Game.update/1 and the other internal state helpers were removed.
  • Printed messages changed.

Testing

Run locally on Debian 13:

  • mix compile --warnings-as-errors, mix format --check-formatted, mix credo --strict, mix dialyzer
  • mix test --cover: 61 tests, 100% coverage
  • 20,000 seeded games produced the same states as the previous implementation

Not tested: the installation steps on macOS, Ubuntu, Fedora and Arch.

@Tinix
Tinix merged commit f2850de into main Nov 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant