-
Notifications
You must be signed in to change notification settings - Fork 86
Add game recreation flow and local-dev test game management #4698
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
Draft
Copilot
wants to merge
64
commits into
master
Choose a base branch
from
copilot/add-local-map-file-and-channels
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 14 commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
d128215
Add local sample game bootstrap service
Copilot 80aa191
Format local sample game bootstrap
Copilot f64ec7c
Refine local sample game bootstrap
Copilot f01db7c
Fix local startup validation edge cases
Copilot 9752e72
Harden local sample channel naming
Copilot be26e67
Add recreate game and local dev commands
Copilot ea4f6ab
Format recreate game and local dev workflow
Copilot 48ccc1f
Tighten local dev source path resolution
Copilot b6a5efa
Relax local dev clean confirmation casing
Copilot ee8eb94
Merge master package moves into recreate workflow
Copilot 73f5adb
Address package-move review followups
Copilot 845c3fa
Harden recreate and local dev safety checks
Copilot 4dea2b7
Resolve merge conflict with master
Copilot 08c76a0
Merge remote-tracking branch 'origin/master' into copilot/add-local-m…
Copilot 6f1abb2
F
wholton 2e719d3
F
wholton e6938a9
Update recreate guild selection and local dev clone flow
Copilot c55e559
Address recreate flow review feedback
Copilot 6abb0fd
Polish recreate review fixes
Copilot 8c73ab9
Finalize recreate cleanup
Copilot f998407
Resolve final recreate review nits
Copilot 179ef3b
Clarify capacity selection and test mocks
Copilot 649dd93
Tidy recreate docs and test setup
Copilot dce08e3
Update GameManager.java
wholton 763dd5c
Update GameLoadService.java
wholton a876cbf
Apply suggestion from @Copilot
wholton 9209027
Require opt-in for local dev startup
Copilot 64e553a
Use game guild for recreate game
Copilot 7aed034
Add recreate game fallback coverage
Copilot 59b7841
Remove args-based local dev startup gating
Copilot d0323e0
Format local dev env flag cleanup
Copilot 3eb4f64
F
wholton 2e469e3
Wire recreate-game into command save flow
Copilot ef902be
Return recreate-game summary directly
Copilot 0e3d857
Format recreate-game summary refactor
Copilot 4f50d4c
Document recreate-game result helper
Copilot 313fc6e
Delete RecreateGameTest.java
wholton 6285a15
Switch local-dev action handling
Copilot 237d64c
Handle unknown local-dev action
Copilot b903991
Add explicit return to local-dev create branch
Copilot f48147c
Add explicit return to local-dev default branch
Copilot 09444bb
Merge remote-tracking branch 'origin/master' into copilot/add-local-m…
wholton 24bf5e9
Switch local test games to numeric suffix names
Copilot 4d72d63
Format updated local test naming tests
Copilot 1f1a08c
Tighten local test name regex
Copilot c0e0dd2
Simplify local test suffix naming
Copilot 40e7f1b
Format simplified local test naming tests
Copilot 012a6c0
Merge remote-tracking branch 'origin/master' into copilot/add-local-m…
wholton 42516d3
Implement local dev source file recreation
Copilot 35f964c
Format local dev source file changes
Copilot 4d21c14
Address local dev recreation review feedback
Copilot 9627037
Harden temp local dev source handling
Copilot 677a33b
Clarify local dev source file handling
Copilot 97170b5
Format local dev source path logging
Copilot 5c3c941
Merge branch 'copilot/add-local-map-file-and-channels' of https://git…
wholton ee37422
Merge remote-tracking branch 'origin/master' into copilot/add-local-m…
wholton b35319b
Implement Fog of War recreate flow
Copilot 2ef9531
Format Fog of War recreate support
Copilot 670977d
Expand Fog of War recreate test coverage
Copilot 1ca9ea4
Clarify Fog of War recreate intent
Copilot 4db2c0e
Polish Fog of War recreate notes
Copilot cb52772
Merge branch 'copilot/add-local-map-file-and-channels' of https://git…
wholton 2611057
Merge remote-tracking branch 'origin/master' into copilot/add-local-m…
wholton 95e7006
F
wholton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/ti4/discord/interactions/commands/admin/RecreateGame.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| package ti4.discord.interactions.commands.admin; | ||
|
|
||
| import net.dv8tion.jda.api.entities.Guild; | ||
| import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; | ||
| import net.dv8tion.jda.api.interactions.commands.OptionMapping; | ||
| import net.dv8tion.jda.api.interactions.commands.OptionType; | ||
| import ti4.discord.interactions.commands.Subcommand; | ||
| import ti4.game.Game; | ||
| import ti4.game.persistence.GameManager; | ||
| import ti4.game.persistence.ManagedGame; | ||
| import ti4.helpers.Constants; | ||
| import ti4.message.MessageHelper; | ||
| import ti4.service.game.RecreateGameService; | ||
|
|
||
| class RecreateGame extends Subcommand { | ||
|
|
||
| RecreateGame() { | ||
| super(Constants.RECREATE_GAME, "Recreate a game's channels and roles."); | ||
| addOption(OptionType.STRING, Constants.GAME_NAME, "Game to recreate", true, true); | ||
| } | ||
|
|
||
| @Override | ||
| public void execute(SlashCommandInteractionEvent event) { | ||
| String gameName = event.getOption(Constants.GAME_NAME, OptionMapping::getAsString); | ||
| if (gameName == null || !GameManager.isValid(gameName)) { | ||
| MessageHelper.replyToMessage(event, "Invalid game name."); | ||
| return; | ||
| } | ||
|
|
||
| ManagedGame managedGame = GameManager.getManagedGame(gameName); | ||
| if (managedGame == null) { | ||
| MessageHelper.replyToMessage(event, "Game could not be loaded."); | ||
| return; | ||
| } | ||
| Game game = managedGame.getGame(); | ||
| Guild guild = game.getGuild() != null ? game.getGuild() : event.getGuild(); | ||
| if (guild == null) { | ||
| MessageHelper.replyToMessage(event, "Could not determine which guild should host this game."); | ||
| return; | ||
| } | ||
|
|
||
| RecreateGameService.RecreateGameResult result = RecreateGameService.recreateGame(game, guild); | ||
| MessageHelper.replyToMessage(event, result.getSummary()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/main/java/ti4/discord/interactions/commands/developer/LocalDevelopment.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| package ti4.discord.interactions.commands.developer; | ||
|
|
||
| import net.dv8tion.jda.api.entities.Guild; | ||
| import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; | ||
| import net.dv8tion.jda.api.interactions.commands.OptionMapping; | ||
| import net.dv8tion.jda.api.interactions.commands.OptionType; | ||
| import net.dv8tion.jda.api.interactions.commands.build.OptionData; | ||
| import ti4.discord.interactions.commands.Subcommand; | ||
| import ti4.helpers.Constants; | ||
| import ti4.message.MessageHelper; | ||
| import ti4.service.game.LocalDevelopmentSampleGameService; | ||
| import ti4.service.game.RecreateGameService; | ||
|
|
||
| class LocalDevelopment extends Subcommand { | ||
|
|
||
| private static final String ACTION_CREATE = "create"; | ||
| private static final String ACTION_CLEAN = "clean"; | ||
|
|
||
| LocalDevelopment() { | ||
| super(Constants.LOCAL_DEV, "Manage local development test games."); | ||
| addOptions(new OptionData(OptionType.STRING, Constants.ACTION, "Local development action") | ||
| .setRequired(true) | ||
| .addChoice("Create", ACTION_CREATE) | ||
| .addChoice("Clean", ACTION_CLEAN)); | ||
| addOptions(new OptionData(OptionType.STRING, Constants.SOURCE, "Source game name") | ||
| .setRequired(false) | ||
| .setAutoComplete(true)); | ||
|
wholton marked this conversation as resolved.
Outdated
|
||
| addOptions( | ||
| new OptionData(OptionType.STRING, Constants.CONFIRM, "Type YES to confirm cleanup").setRequired(false)); | ||
| } | ||
|
|
||
| @Override | ||
| public void execute(SlashCommandInteractionEvent event) { | ||
| Guild guild = event.getGuild(); | ||
| if (guild == null) { | ||
| MessageHelper.replyToMessage(event, "This command must be run in a server."); | ||
| return; | ||
| } | ||
|
|
||
| String action = event.getOption(Constants.ACTION, ACTION_CREATE, OptionMapping::getAsString); | ||
| if (ACTION_CLEAN.equals(action)) { | ||
| String confirm = event.getOption(Constants.CONFIRM, "", OptionMapping::getAsString); | ||
| if (!"YES".equalsIgnoreCase(confirm)) { | ||
| MessageHelper.replyToMessage(event, "Cleanup requires `confirm: YES`."); | ||
| return; | ||
| } | ||
| var result = LocalDevelopmentSampleGameService.cleanTestGames(guild); | ||
| MessageHelper.replyToMessage(event, result.getSummary()); | ||
| return; | ||
| } | ||
|
|
||
| String sourceGame = event.getOption( | ||
| Constants.SOURCE, | ||
| LocalDevelopmentSampleGameService.DEFAULT_SOURCE_GAME_NAME, | ||
| OptionMapping::getAsString); | ||
| RecreateGameService.RecreateGameResult result = LocalDevelopmentSampleGameService.createAndRecreateTestGame( | ||
| guild, event.getUser().getId(), sourceGame); | ||
| if (result == null) { | ||
| MessageHelper.replyToMessage( | ||
| event, "Failed to create a local development test game from `" + sourceGame + "`."); | ||
| return; | ||
| } | ||
| MessageHelper.replyToMessage(event, result.getSummary()); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.