feat(werewolf-example): support customizing the number of each individual role(#299)#417
Conversation
…r of each individual role(agentscope-ai#299)
|
|
There was a problem hiding this comment.
Pull request overview
This PR adds support for customizing the number of each individual role in the Werewolf game, addressing issue #299. Users can now configure the count of villagers, werewolves, seers, witches, and hunters through a new configuration modal in the UI.
Key Changes:
- New GameConfiguration class: Encapsulates customizable role counts with validation logic
- Backend refactoring: Modified GameState to support multiple instances of special roles (seers, witches, hunters) instead of single instances
- UI configuration modal: Added a settings interface allowing users to customize role counts before starting a game
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| GameConfiguration.java | New class that holds customizable role counts with validation |
| WerewolfWebController.java | Accepts and validates role count parameters from the frontend |
| WerewolfWebGame.java | Uses GameConfiguration to initialize games and handles multiple special role instances |
| GameState.java | Refactored to store lists of seers/witches/hunters instead of single instances |
| index.html | Added configuration modal UI with input fields for each role count |
| app.js | Implements configuration modal logic and sends custom counts to backend |
| i18n.js | Added translations for configuration UI labels in Chinese and English |
| style.css | Added styling for the configuration modal and button |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...e-examples/werewolf-hitl/src/main/java/io/agentscope/examples/werewolf/entity/GameState.java
Show resolved
Hide resolved
...s/werewolf-hitl/src/main/java/io/agentscope/examples/werewolf/web/WerewolfWebController.java
Outdated
Show resolved
Hide resolved
...s/werewolf-hitl/src/main/java/io/agentscope/examples/werewolf/web/WerewolfWebController.java
Outdated
Show resolved
Hide resolved
...-examples/werewolf-hitl/src/main/java/io/agentscope/examples/werewolf/GameConfiguration.java
Show resolved
Hide resolved
agentscope-examples/werewolf-hitl/src/main/resources/static/css/style.css
Outdated
Show resolved
Hide resolved
...-examples/werewolf-hitl/src/main/java/io/agentscope/examples/werewolf/GameConfiguration.java
Show resolved
Hide resolved
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…examples/werewolf/web/WerewolfWebController.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…r of each individual role(#299)
AgentScope-Java Version
[The version of AgentScope-Java you are working on, e.g. 1.0.5, check your pom.xml dependency version or run
mvn dependency:tree | grep agentscope-parent:pom(only mac/linux)]Description
support customizing the number of each individual role(#299)


效果:
Checklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test)