Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(game): idiot spared life event #618

Merged
merged 2 commits into from
Jul 8, 2024

Conversation

antoinezanardi
Copy link
Owner

@antoinezanardi antoinezanardi commented Jul 8, 2024

Summary by CodeRabbit

  • New Features

    • Added a confirm dialog before starting a game.
    • Disabled player cards based on the current play type.
    • Introduced new "Idiot" role with specific game events and interactions.
    • Added sound effect "dumb-huh."
  • Bug Fixes

    • Fixed player card targetability based on play type.
  • Tests

    • Added unit and acceptance tests for new "Idiot" role and game events.
  • Chores

    • Updated dependencies, including prettier-plugin-gherkin and tsx.
    • Incremented application version to 1.25.0.

@antoinezanardi antoinezanardi added the 🚀 feature New feature or request label Jul 8, 2024
@antoinezanardi antoinezanardi self-assigned this Jul 8, 2024
Copy link

coderabbitai bot commented Jul 8, 2024

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Files selected but had no reviewable changes (1)
  • tests/stryker/incremental.json

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The update to Werewolves Assistant Web (version 1.25.0) introduces new game features and events: a confirmation dialog in the game lobby before starting a game, player card functionality, and the addition of the "Idiot" role with corresponding events and sound effects. The update improves testing setups, including the simulation of game events for varied player roles and additional unit tests for ensuring functionality.

Changes

Files/Groups Change Summary
.run/Idiot Role.run.xml Configuration for a Cucumber.js run with specific arguments and environment settings.
CHANGELOG.md Documented new features, enhancements, and dependency updates for version 1.25.0.
.../game/GamePlaying/GameEventsMonitor/GameEventsMonitorCurrentEvent.vue Imported and added GameIdiotIsSparedEvent component to game event monitor.
.../game/GamePlaying/GameEventsMonitor/GameIdiotIsSparedEvent.vue Introduced a new component dedicated to handling the "Idiot is spared" game event.
.../game/game-event/GameEventWithTexts/GameEventWithTexts.vue Added an event handler for game-event-text-change from GameEventTextsManager.
.../game/game-event/GameEventWithTexts/game-event-with-texts.types.ts Added a new type GameEventWithTextsEmits for emitting game event text changes.
app/stores/audio/constants/audio.constants.ts Added the sound effect "dumb-huh" to the sound effects list.
app/stores/game/game-event/constants/game-event.constants.ts Added the new game event type "idiot-is-spared" to the predefined list.
app/stores/game/game-event/useGameEventsStore.ts Updated game event functions and added a new function for handling revealed role player events.
modules/i18n/locales/en.json Added messages for the GameIdiotIsSparedEvent event.
modules/i18n/locales/fr.json Added messages for the GameIdiotIsSparedEvent event and updated a message for GamePlayerDiesEvent.
package.json Updated the version number from 1.23.0 to 1.25.0.
tests/acceptance/features/game/features/role/idiot.feature Introduced scenarios involving the "Idiot" role.
.../game-options/game-options.given-steps.ts Added a step to prevent Idiot's death when Elder dies in game options.
.../player/player-attribute/player-attribute.then-steps.ts Renamed and added functions related to player attributes in game scenarios.
.../GamePlaying/GameEventsMonitor/GameIdiotIsSparedEvent/GameIdiotIsSparedEvent.nuxt.spec.ts Added tests for the GameIdiotIsSparedEvent component.
.../GameEventWithTexts/GameEventTextsManager/GameEventTextsManager.nuxt.spec.ts Added tests ensuring the game-event-text-change event is emitted.
.../GameEventWithTexts/GameEventWithTexts.nuxt.spec.ts Added tests to verify event emission from GameEventWithTexts.
tests/unit/specs/stores/audio/useAudioStore.spec.ts Adjusted the expected function call counts and parameters for the audio store tests.
tests/unit/specs/stores/game/game-event/useGameEventsStore.spec.ts Added and modified test cases for game events based on game history records.

Poem

In the game of wolves and men,
The Idiot laughs and spares the den.
Events unfold, new sounds take flight,
Cards are turned, reveals in sight.
To each role and player,
A tale is told with flair.
🐇✨ In version twenty-five, we thrive! 🎮🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b84e26e and 8e9e9d6.

Files ignored due to path filters (2)
  • public/audio/sound-effects/dumb-huh.webm is excluded by !**/*.webm
  • tests/unit/specs/components/pages/game/GamePlaying/GameEventsMonitor/GameEventsMonitorCurrentEvent/GameIdiotIsSparedEvent/__snapshots__/GameIdiotIsSparedEvent.nuxt.spec.ts.snap is excluded by !**/*.snap
Files selected for processing (22)
  • .run/Idiot Role.run.xml (1 hunks)
  • CHANGELOG.md (1 hunks)
  • app/components/pages/game/GamePlaying/GameEventsMonitor/GameEventsMonitorCurrentEvent/GameEventsMonitorCurrentEvent.vue (2 hunks)
  • app/components/pages/game/GamePlaying/GameEventsMonitor/GameEventsMonitorCurrentEvent/GameIdiotIsSparedEvent/GameIdiotIsSparedEvent.vue (1 hunks)
  • app/components/shared/game/game-event/GameEventWithTexts/GameEventTextsManager/GameEventTextsManager.vue (2 hunks)
  • app/components/shared/game/game-event/GameEventWithTexts/GameEventTextsManager/game-event-texts-manager.types.ts (1 hunks)
  • app/components/shared/game/game-event/GameEventWithTexts/GameEventWithTexts.vue (1 hunks)
  • app/components/shared/game/game-event/GameEventWithTexts/game-event-with-texts.types.ts (1 hunks)
  • app/stores/audio/constants/audio.constants.ts (1 hunks)
  • app/stores/game/game-event/constants/game-event.constants.ts (1 hunks)
  • app/stores/game/game-event/useGameEventsStore.ts (3 hunks)
  • modules/i18n/locales/en.json (1 hunks)
  • modules/i18n/locales/fr.json (2 hunks)
  • package.json (1 hunks)
  • tests/acceptance/features/game/features/role/idiot.feature (1 hunks)
  • tests/acceptance/features/game/step-definitions/game-options/game-options.given-steps.ts (1 hunks)
  • tests/acceptance/features/game/step-definitions/player/player-attribute/player-attribute.then-steps.ts (1 hunks)
  • tests/unit/specs/components/pages/game/GamePlaying/GameEventsMonitor/GameEventsMonitorCurrentEvent/GameIdiotIsSparedEvent/GameIdiotIsSparedEvent.nuxt.spec.ts (1 hunks)
  • tests/unit/specs/components/shared/game/game-event/GameEventWithTexts/GameEventTextsManager/GameEventTextsManager.nuxt.spec.ts (1 hunks)
  • tests/unit/specs/components/shared/game/game-event/GameEventWithTexts/GameEventWithTexts.nuxt.spec.ts (2 hunks)
  • tests/unit/specs/stores/audio/useAudioStore.spec.ts (2 hunks)
  • tests/unit/specs/stores/game/game-event/useGameEventsStore.spec.ts (2 hunks)
Files skipped from review due to trivial changes (5)
  • .run/Idiot Role.run.xml
  • CHANGELOG.md
  • app/components/shared/game/game-event/GameEventWithTexts/game-event-with-texts.types.ts
  • app/stores/audio/constants/audio.constants.ts
  • package.json
Additional comments not posted (27)
app/stores/game/game-event/constants/game-event.constants.ts (1)

14-14: New event type added.

The event type "idiot-is-spared" has been correctly added to the list of game event types.

app/components/shared/game/game-event/GameEventWithTexts/GameEventWithTexts.vue (2)

16-16: Ensure event handler alignment.

The event handler onGameEventTextChangeFromGameEventTextsManager is correctly integrated to handle game-event-text-change events.


22-31: Correct imports and setup for event handling.

The GameEventWithTextsEmits type and onGameEventTextChangeFromGameEventTextsManager function are correctly defined and used.

tests/unit/specs/components/shared/game/game-event/GameEventWithTexts/GameEventWithTexts.nuxt.spec.ts (2)

1-1: LGTM! Imports are necessary for type checking.

The added type imports ensure proper typing of props and emits.


51-61: LGTM! Tests for event emission are necessary.

The new describe block and test ensure that the gameEventTextChange event is emitted correctly.

app/components/shared/game/game-event/GameEventWithTexts/GameEventTextsManager/GameEventTextsManager.vue (3)

42-42: LGTM! Imports are necessary for type checking.

The added type imports ensure proper typing of props and emits.


47-48: LGTM! Properly defining emits is crucial.

The defineEmits function ensures that the component's emits are properly typed and handled.


81-84: LGTM! The watch function ensures correct event emission.

The watch function ensures that the gameEventTextChange event is emitted whenever the currentGameEventText changes.

app/components/pages/game/GamePlaying/GameEventsMonitor/GameEventsMonitorCurrentEvent/GameEventsMonitorCurrentEvent.vue (2)

27-27: LGTM! Importing the new component is necessary.

The import statement includes the GameIdiotIsSparedEvent component, which is necessary for the new functionality.


58-58: LGTM! Correctly mapping the new event type.

The addition ensures that the GameIdiotIsSparedEvent component is used when the event type is "idiot-is-spared".

tests/acceptance/features/game/features/role/idiot.feature (1)

1-99: LGTM! Comprehensive acceptance tests.

The scenarios cover various aspects of the "Idiot" role and ensure that the new functionality is thoroughly tested.

app/stores/game/game-event/useGameEventsStore.ts (1)

Line range hint 25-31:
Verify the impact of the removed game parameter.

The removal of the game parameter simplifies the function signature. Ensure that this modification does not impact the function's logic and usage in other parts of the codebase.

Verification successful

Verification successful: The removal of the game parameter does not impact the function's logic or usage.

The function getLastGameHistoryRecordCharmEvents is used correctly within the context provided, and the removal of the game parameter simplifies the function signature without causing issues.

  • app/stores/game/game-event/useGameEventsStore.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of the removed `game` parameter in `getLastGameHistoryRecordCharmEvents`.

# Test: Search for the function usage. Expect: No errors due to the removed parameter.
rg --type python $'getLastGameHistoryRecordCharmEvents'

Length of output: 85


Script:

#!/bin/bash
# Description: Verify the impact of the removed `game` parameter in `getLastGameHistoryRecordCharmEvents`.

# Test: Search for the function usage. Expect: No errors due to the removed parameter.
rg --type ts 'getLastGameHistoryRecordCharmEvents'

Length of output: 303


Script:

#!/bin/bash
# Description: Show the surrounding code to understand the usage and impact of the removed `game` parameter.

# Display 5 lines before and after the function usage to provide context.
rg --type ts 'getLastGameHistoryRecordCharmEvents' -A 5 -B 5

Length of output: 2071

tests/unit/specs/components/shared/game/game-event/GameEventWithTexts/GameEventTextsManager/GameEventTextsManager.nuxt.spec.ts (1)

111-117: LGTM! Verify the event payload.

The test correctly checks if the gameEventTextChange event is emitted. Ensure that the event payload is also verified to maintain the component's integrity.

tests/unit/specs/components/pages/game/GamePlaying/GameEventsMonitor/GameEventsMonitorCurrentEvent/GameIdiotIsSparedEvent/GameIdiotIsSparedEvent.nuxt.spec.ts (4)

39-42: LGTM!

The snapshot test ensures that the component's structure and appearance remain consistent.


44-49: LGTM!

The snapshot test ensures that the component's structure and appearance remain consistent when fully rendered.


52-62: LGTM!

The test correctly checks if the appropriate event texts are passed to the component.


117-124: LGTM!

The test correctly checks if the appropriate sound effects are played based on the emitted event text changes.

tests/unit/specs/stores/audio/useAudioStore.spec.ts (1)

Line range hint 24-38:
LGTM!

The test correctly checks if the appropriate number of sound effects are created when the store is initialized.

tests/acceptance/features/game/step-definitions/game-options/game-options.given-steps.ts (1)

146-150: LGTM!

The new Given step to prevent the revealed idiot's death on elder's death follows the established pattern and looks good.

tests/acceptance/features/game/step-definitions/player/player-attribute/player-attribute.then-steps.ts (1)

159-163: LGTM!

The new Then step to check if the player has the attribute "cant-vote by survivors" follows the established pattern and looks good.

tests/unit/specs/stores/game/game-event/useGameEventsStore.spec.ts (1)

423-471: LGTM!

The new test cases for the "idiot-is-spared" event ensure that the event is generated correctly when the conditions are met. The tests are comprehensive and follow the established pattern.

modules/i18n/locales/en.json (1)

1400-1404: LGTM! Addition of new event strings is consistent.

The new event "GameIdiotIsSparedEvent" has been added correctly and is consistent with the existing structure.

modules/i18n/locales/fr.json (2)

1316-1316: LGTM!

The addition of the "playerCanRevealRole" key-value pair is correct and consistent with the existing keys and values.


1400-1404: LGTM!

The addition of the "GameIdiotIsSparedEvent" key-value pairs is correct and consistent with the existing keys and values.

app/components/shared/game/game-event/GameEventWithTexts/GameEventTextsManager/game-event-texts-manager.types.ts (1)

5-7: LGTM!

The type definition for GameEventTextsManagerEmits is correct and appropriate.

app/components/pages/game/GamePlaying/GameEventsMonitor/GameEventsMonitorCurrentEvent/GameIdiotIsSparedEvent/GameIdiotIsSparedEvent.vue (2)

1-16: LGTM!

The template block is well-structured and correctly binds the properties and events.


18-59: LGTM!

The script setup block is well-structured with appropriate imports and setup logic.

Comment on lines +54 to +60
function getRevealedRolePlayerGameEvents(game: Game): GameEvent[] {
const { lastGameHistoryRecord } = game;
if (lastGameHistoryRecord?.revealedPlayers?.some(player => player.role.current === "idiot") === true) {
return [GameEvent.create({ type: "idiot-is-spared" })];
}
return [];
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Add unit tests for the new function.

The function correctly checks for the "idiot" role and returns the appropriate game event. Ensure that unit tests cover this new functionality.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?

Copy link

sonarcloud bot commented Jul 8, 2024

@antoinezanardi antoinezanardi merged commit b5b77d1 into develop Jul 8, 2024
14 checks passed
@antoinezanardi antoinezanardi deleted the feat/idiot-spared-life-event branch July 8, 2024 19:22
antoinezanardi pushed a commit that referenced this pull request Jul 18, 2024
## [1.26.0](v1.25.0...v1.26.0) (2024-07-18)

### 🚀 Features

* **game:** idiot spared life event ([#618](#618)) ([b5b77d1](b5b77d1))
* **game:** votes duration ([#646](#646)) ([d1384bb](d1384bb))
* **img:** add placeholder while images are loading ([#624](#624)) ([4d7419a](4d7419a))
* **pied-piper:** charmed people are revealed game option ([#639](#639)) ([05da133](05da133))
* **werewolf:** werewolf can eat each other game options ([#640](#640)) ([63923f3](63923f3))

### 🐛 Bug Fixes

* **deps:** update dependency @fortawesome/fontawesome-free to ^6.6.0 ([#643](#643)) ([c452a5d](c452a5d))

### ✅ Tests

* **three-brothers:** acceptance tests ([#626](#626)) ([b939bc1](b939bc1))
* **two-sisters:** acceptance tests ([#625](#625)) ([6bf5de2](6bf5de2))

### 🧹 Chore

* **deps:** update dependency @eslint/config-inspector to ^0.5.2 ([#647](#647)) ([9e7f69d](9e7f69d))
* **deps:** update dependency @nuxtjs/tailwindcss to ^6.12.1 ([#630](#630)) ([871619a](871619a))
* **deps:** update dependency eslint to ^9.7.0 ([#632](#632)) ([2a24fb9](2a24fb9))
* **deps:** update dependency husky to ^9.1.0 ([#648](#648)) ([67439d4](67439d4))
* **deps:** update dependency prettier to ^3.3.3 ([#633](#633)) ([299f29a](299f29a))
* **deps:** update dependency qs to ^6.12.3 ([#621](#621)) ([49cf119](49cf119))
* **deps:** update dependency rimraf to ^6.0.1 ([#629](#629)) ([7613fee](7613fee))
* **deps:** update dependency rimraf to v6 ([#623](#623)) ([6764092](6764092))
* **deps:** update dependency sass to ^1.77.7 ([#627](#627)) ([4f8f044](4f8f044))
* **deps:** update dependency sass to ^1.77.8 ([#631](#631)) ([442abf4](442abf4))
* **deps:** update dependency tailwindcss to ^3.4.5 ([#637](#637)) ([6ae364c](6ae364c))
* **deps:** update dependency tailwindcss to ^3.4.6 ([#642](#642)) ([87253ce](87253ce))
* **deps:** update dependency type-fest to ^4.22.0 ([#644](#644)) ([ae93b7b](ae93b7b))
* **deps:** update dependency vue to ^3.4.32 ([#645](#645)) ([b2e2084](b2e2084))
* **deps:** update node.js to >=20.15.1 ([#617](#617)) ([6629992](6629992))
* **deps:** update playwright monorepo to ^1.45.2 ([#641](#641)) ([152eb1a](152eb1a))
* **deps:** update pnpm to v9.5.0 ([#615](#615)) ([b84e26e](b84e26e))
* **deps:** update typescript-eslint monorepo to ^7.16.0 ([#619](#619)) ([6209cbe](6209cbe))
* **deps:** update typescript-eslint monorepo to ^7.16.1 ([#638](#638)) ([800d22c](800d22c))
* **deps:** update vitest monorepo to ^2.0.2 ([#628](#628)) ([a1d4940](a1d4940))
* **deps:** update vitest monorepo to v2 (major) ([#616](#616)) ([d5eb23f](d5eb23f))
* **locale:** improve some french i18n ([#649](#649)) ([2bbc1b4](2bbc1b4))
* **sandbox-api:** bump sandbox api version to 1-33-0 ([#635](#635)) ([8a10d59](8a10d59))
@antoinezanardi
Copy link
Owner Author

🎉 This PR is included in version 1.26.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 feature New feature or request released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant