Skip to content

feat: advantage and disadvantage dice rolls#20

Merged
valb-mig merged 5 commits into
mainfrom
develop
Mar 19, 2026
Merged

feat: advantage and disadvantage dice rolls#20
valb-mig merged 5 commits into
mainfrom
develop

Conversation

@valb-mig
Copy link
Copy Markdown
Collaborator

Closes #18

Overview

Implements advantage and disadvantage mechanics for dice rolls, following the standard tabletop RPG convention: roll two dice of the same type and keep the highest (advantage) or lowest (disadvantage) result.


What changed

RollAttribute enum

  • Added RPGPlayground\Domain\Enums\Roll\RollAttribute with Advantage and Disadvantage cases
  • Replaces the previous RollAttributes class with const string — now type-safe

RollDiceInput

  • Added optional ?RollAttribute $attribute parameter to create()
  • Defaults to null — no breaking change for existing callers

RollDiceUseCase

  • Extracted private roll() method to handle dice collection
  • When attribute is set, an extra roll is added and max() or min() is applied before modifiers
  • Modifiers are still applied after advantage/disadvantage resolution

Tests

  • Added advantage and disadvantage sections to RollDiceUseCaseTest
  • Added attribute coverage to RollDiceInputTest
  • D1 used as deterministic dice to guarantee assertions

Behaviour

Attribute Result
null sum of all rolls
Advantage highest of two rolls
Disadvantage lowest of two rolls

Modifiers are always applied after attribute resolution, regardless of mode.

@valb-mig valb-mig self-assigned this Mar 19, 2026
@valb-mig valb-mig added the enhancement New feature or request label Mar 19, 2026
@valb-mig valb-mig merged commit 9e249e0 into main Mar 19, 2026
6 checks passed
@valb-mig valb-mig deleted the develop branch March 19, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(feat): Advantage dices

1 participant