-
Notifications
You must be signed in to change notification settings - Fork 4
add method to create a party + lobby dto #472
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b05e9aa
wrote create party endpoint + wrote
angelayu0530 5716d9e
Lobby Dto
angelayu0530 093a9c6
co pilot pr changes
angelayu0530 cb6430e
other copiliot changes
angelayu0530 a8f7655
Update src/main/java/com/patina/codebloom/api/duel/DuelController.java
angelayu0530 f928828
Checkstyles
angelayu0530 4a75993
added check for if a party is already in a lobby and fixed the protec…
angelayu0530 5e51a29
removing db collisons check
angelayu0530 9463830
changes with protector
angelayu0530 1df446b
checkstyle
angelayu0530 7d28ca6
duel tests for create party
angelayu0530 31da6bc
moved files
angelayu0530 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
Some comments aren't visible on the classic Files Changed page.
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
47 changes: 47 additions & 0 deletions
47
src/main/java/com/patina/codebloom/api/duel/dto/LobbyDto.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,47 @@ | ||
| package com.patina.codebloom.api.duel.dto; | ||
|
|
||
| import java.time.OffsetDateTime; | ||
|
|
||
| import com.patina.codebloom.common.db.models.lobby.Lobby; | ||
| import com.patina.codebloom.common.db.models.lobby.LobbyStatus; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import lombok.Builder; | ||
| import lombok.EqualsAndHashCode; | ||
| import lombok.Getter; | ||
| import lombok.ToString; | ||
| import lombok.extern.jackson.Jacksonized; | ||
|
|
||
| @Getter | ||
| @Builder | ||
| @Jacksonized | ||
| @ToString | ||
| @EqualsAndHashCode | ||
| public class LobbyDto { | ||
| @Schema(requiredMode = Schema.RequiredMode.REQUIRED) | ||
| private String id; | ||
| @Schema(requiredMode = Schema.RequiredMode.REQUIRED) | ||
| private String joinCode; | ||
| @Schema(requiredMode = Schema.RequiredMode.REQUIRED) | ||
| private LobbyStatus status; | ||
| @Schema(requiredMode = Schema.RequiredMode.REQUIRED) | ||
| private OffsetDateTime expiresAt; | ||
| @Schema(requiredMode = Schema.RequiredMode.REQUIRED) | ||
| private OffsetDateTime createdAt; | ||
| @Schema(requiredMode = Schema.RequiredMode.REQUIRED) | ||
| private int playerCount; | ||
| @Schema(requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) | ||
| private String winnerId; | ||
|
|
||
| public static LobbyDto fromLobby(final Lobby lobby) { | ||
| return LobbyDto.builder() | ||
| .id(lobby.getId()) | ||
| .joinCode(lobby.getJoinCode()) | ||
| .status(lobby.getStatus()) | ||
| .expiresAt(lobby.getExpiresAt()) | ||
| .createdAt(lobby.getCreatedAt()) | ||
| .playerCount(lobby.getPlayerCount()) | ||
| .winnerId(lobby.getWinnerId()) | ||
| .build(); | ||
| } | ||
| } |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/patina/codebloom/common/utils/duel/PartyCodeGenerator.java
angelayu0530 marked this conversation as resolved.
Show resolved
Hide resolved
|
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,22 @@ | ||
| package com.patina.codebloom.common.utils.duel; | ||
|
|
||
| import java.security.SecureRandom; | ||
|
|
||
| public class PartyCodeGenerator { | ||
| private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; | ||
| private static final int CODE_LENGTH = 6; | ||
| private static final SecureRandom RANDOM = new SecureRandom(); | ||
|
|
||
| /** | ||
| * Generates a random party code | ||
| * | ||
| * @return A random party code (e.g., "ABC123") | ||
| */ | ||
| public static String generateCode() { | ||
| StringBuilder codeBuilder = new StringBuilder(CODE_LENGTH); | ||
| for (int i = 0; i < CODE_LENGTH; i++) { | ||
| codeBuilder.append(CHARACTERS.charAt(RANDOM.nextInt(CHARACTERS.length()))); | ||
| } | ||
| return codeBuilder.toString(); | ||
| } | ||
| } |
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.