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: PvP #4

Merged
merged 19 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
396 changes: 392 additions & 4 deletions docs/spec/CodeCharacter-API.yml

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions library/.openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
.openapi-generator-ignore
README.md
build.gradle.kts
pom.xml
settings.gradle
src/main/kotlin/delta/codecharacter/SpringDocConfiguration.kt
src/main/kotlin/delta/codecharacter/core/ApiUtil.kt
src/main/kotlin/delta/codecharacter/core/AuthApi.kt
src/main/kotlin/delta/codecharacter/core/CodeApi.kt
src/main/kotlin/delta/codecharacter/core/CurrentUserApi.kt
Expand All @@ -14,6 +8,7 @@ src/main/kotlin/delta/codecharacter/core/LeaderboardApi.kt
src/main/kotlin/delta/codecharacter/core/MapApi.kt
src/main/kotlin/delta/codecharacter/core/MatchApi.kt
src/main/kotlin/delta/codecharacter/core/NotificationApi.kt
src/main/kotlin/delta/codecharacter/core/PvpGameApi.kt
src/main/kotlin/delta/codecharacter/core/UserApi.kt
src/main/kotlin/delta/codecharacter/dtos/ActivateUserRequestDto.kt
src/main/kotlin/delta/codecharacter/dtos/AuthStatusResponseDto.kt
Expand Down Expand Up @@ -46,6 +41,11 @@ src/main/kotlin/delta/codecharacter/dtos/NotificationDto.kt
src/main/kotlin/delta/codecharacter/dtos/PasswordLoginRequestDto.kt
src/main/kotlin/delta/codecharacter/dtos/PasswordLoginResponseDto.kt
src/main/kotlin/delta/codecharacter/dtos/PublicUserDto.kt
src/main/kotlin/delta/codecharacter/dtos/PvPGameDto.kt
src/main/kotlin/delta/codecharacter/dtos/PvPGameStatusDto.kt
src/main/kotlin/delta/codecharacter/dtos/PvPLeaderBoardResponseDto.kt
src/main/kotlin/delta/codecharacter/dtos/PvPMatchDto.kt
src/main/kotlin/delta/codecharacter/dtos/PvPUserStatsDto.kt
src/main/kotlin/delta/codecharacter/dtos/RatingHistoryDto.kt
src/main/kotlin/delta/codecharacter/dtos/RegisterUserRequestDto.kt
src/main/kotlin/delta/codecharacter/dtos/ResetPasswordRequestDto.kt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import io.swagger.v3.oas.models.info.License
import io.swagger.v3.oas.models.Components
import io.swagger.v3.oas.models.security.SecurityScheme

// @jakarta.annotation.Generated(value = ["org.openapitools.codegen.languages.KotlinSpringServerCodegen"])
@Configuration
class SpringDocConfiguration {

Expand Down
4 changes: 2 additions & 2 deletions library/src/main/kotlin/delta/codecharacter/core/CodeApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ interface CodeApi {
value = ["/user/code/revisions"],
produces = ["application/json"]
)
fun getCodeRevisions(@Parameter(description = "code type", schema = Schema(allowableValues = ["NORMAL", "DAILY_CHALLENGE"], defaultValue = "NORMAL")) @Valid @RequestParam(value = "type", required = false, defaultValue = "NORMAL") type: CodeTypeDto): ResponseEntity<List<CodeRevisionDto>> {
fun getCodeRevisions(@Parameter(description = "code type", schema = Schema(allowableValues = ["NORMAL", "DAILY_CHALLENGE", "PVP"], defaultValue = "NORMAL")) @Valid @RequestParam(value = "type", required = false, defaultValue = "NORMAL") type: CodeTypeDto): ResponseEntity<List<CodeRevisionDto>> {
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
}

Expand All @@ -97,7 +97,7 @@ interface CodeApi {
value = ["/user/code/latest"],
produces = ["application/json"]
)
fun getLatestCode(@Parameter(description = "code type", schema = Schema(allowableValues = ["NORMAL", "DAILY_CHALLENGE"], defaultValue = "NORMAL")) @Valid @RequestParam(value = "type", required = false, defaultValue = "NORMAL") type: CodeTypeDto): ResponseEntity<CodeDto> {
fun getLatestCode(@Parameter(description = "code type", schema = Schema(allowableValues = ["NORMAL", "DAILY_CHALLENGE", "PVP"], defaultValue = "NORMAL")) @Valid @RequestParam(value = "type", required = false, defaultValue = "NORMAL") type: CodeTypeDto): ResponseEntity<CodeDto> {
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import delta.codecharacter.dtos.DailyChallengeGetRequestDto
import delta.codecharacter.dtos.DailyChallengeLeaderBoardResponseDto
import delta.codecharacter.dtos.DailyChallengeMatchRequestDto
import delta.codecharacter.dtos.GenericErrorDto
import delta.codecharacter.dtos.MatchDto
import io.swagger.v3.oas.annotations.*
import io.swagger.v3.oas.annotations.enums.*
import io.swagger.v3.oas.annotations.media.*
Expand Down Expand Up @@ -102,4 +103,23 @@ interface DailyChallengesApi {
fun getDailyChallengeLeaderBoard(@Parameter(description = "Index of the page") @Valid @RequestParam(value = "page", required = false) page: kotlin.Int?,@Parameter(description = "Size of the page") @Valid @RequestParam(value = "size", required = false) size: kotlin.Int?): ResponseEntity<List<DailyChallengeLeaderBoardResponseDto>> {
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
}

@Operation(
summary = "Get user daily challenge matches",
operationId = "getUserDCMatches",
description = """Get daily-challenge matches played by authenticated user""",
responses = [
ApiResponse(responseCode = "200", description = "OK", content = [Content(array = ArraySchema(schema = Schema(implementation = MatchDto::class)))]),
ApiResponse(responseCode = "401", description = "Unauthorized")
],
security = [ SecurityRequirement(name = "http-bearer") ]
)
@RequestMapping(
method = [RequestMethod.GET],
value = ["/dc/matches"],
produces = ["application/json"]
)
fun getUserDCMatches(@Parameter(description = "Index of the page") @Valid @RequestParam(value = "page", required = false) page: kotlin.Int?,@Parameter(description = "Size of the page") @Valid @RequestParam(value = "size", required = false) size: kotlin.Int?): ResponseEntity<List<MatchDto>> {
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
}
}
20 changes: 20 additions & 0 deletions library/src/main/kotlin/delta/codecharacter/core/LeaderboardApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package delta.codecharacter.core

import delta.codecharacter.dtos.LeaderboardEntryDto
import delta.codecharacter.dtos.PvPLeaderBoardResponseDto
import delta.codecharacter.dtos.TierTypeDto
import io.swagger.v3.oas.annotations.*
import io.swagger.v3.oas.annotations.enums.*
Expand Down Expand Up @@ -56,4 +57,23 @@ interface LeaderboardApi {
fun getLeaderboard(@Parameter(description = "Index of the page") @Valid @RequestParam(value = "page", required = false) page: kotlin.Int?,@Parameter(description = "Size of the page") @Valid @RequestParam(value = "size", required = false) size: kotlin.Int?,@Parameter(description = "Leaderboard Tier", schema = Schema(allowableValues = ["TIER_PRACTICE", "TIER1", "TIER2", "TIER3", "TIER4"])) @Valid @RequestParam(value = "tier", required = false) tier: TierTypeDto?): ResponseEntity<List<LeaderboardEntryDto>> {
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
}

@Operation(
summary = "Get PvP leaderboard",
operationId = "getPvPLeaderboard",
description = """Get PvP leaderboard""",
responses = [
ApiResponse(responseCode = "200", description = "OK", content = [Content(array = ArraySchema(schema = Schema(implementation = PvPLeaderBoardResponseDto::class)))]),
ApiResponse(responseCode = "401", description = "Unauthorized")
],
security = [ SecurityRequirement(name = "http-bearer") ]
)
@RequestMapping(
method = [RequestMethod.GET],
value = ["/pvpleaderboard"],
produces = ["application/json"]
)
fun getPvPLeaderboard(@Parameter(description = "Index of the page") @Valid @RequestParam(value = "page", required = false) page: kotlin.Int?,@Parameter(description = "Size of the page") @Valid @RequestParam(value = "size", required = false) size: kotlin.Int?): ResponseEntity<List<PvPLeaderBoardResponseDto>> {
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
}
}
30 changes: 25 additions & 5 deletions library/src/main/kotlin/delta/codecharacter/core/MatchApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package delta.codecharacter.core
import delta.codecharacter.dtos.CreateMatchRequestDto
import delta.codecharacter.dtos.GenericErrorDto
import delta.codecharacter.dtos.MatchDto
import delta.codecharacter.dtos.PvPMatchDto
import io.swagger.v3.oas.annotations.*
import io.swagger.v3.oas.annotations.enums.*
import io.swagger.v3.oas.annotations.media.*
Expand Down Expand Up @@ -65,7 +66,7 @@ interface MatchApi {
operationId = "getTopMatches",
description = """Get top matches""",
responses = [
ApiResponse(responseCode = "200", description = "OK", content = [Content(array = ArraySchema(schema = Schema(implementation = MatchDto::class)))]),
ApiResponse(responseCode = "200", description = "OK", content = [Content(array = ArraySchema(schema = Schema(implementation = kotlin.Any::class)))]),
ApiResponse(responseCode = "401", description = "Unauthorized")
],
security = [ SecurityRequirement(name = "http-bearer") ]
Expand All @@ -75,14 +76,14 @@ interface MatchApi {
value = ["/top-matches"],
produces = ["application/json"]
)
fun getTopMatches(): ResponseEntity<List<MatchDto>> {
fun getTopMatches(): ResponseEntity<List<kotlin.Any>> {
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
}

@Operation(
summary = "Get user matches",
operationId = "getUserMatches",
description = """Get matches played by authenticated user""",
operationId = "getUserNormalMatches",
description = """Get normal matches played by authenticated user""",
responses = [
ApiResponse(responseCode = "200", description = "OK", content = [Content(array = ArraySchema(schema = Schema(implementation = MatchDto::class)))]),
ApiResponse(responseCode = "401", description = "Unauthorized")
Expand All @@ -94,7 +95,26 @@ interface MatchApi {
value = ["/user/matches"],
produces = ["application/json"]
)
fun getUserMatches(): ResponseEntity<List<MatchDto>> {
fun getUserNormalMatches(@Parameter(description = "Index of the page") @Valid @RequestParam(value = "page", required = false) page: kotlin.Int?,@Parameter(description = "Size of the page") @Valid @RequestParam(value = "size", required = false) size: kotlin.Int?): ResponseEntity<List<MatchDto>> {
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
}

@Operation(
summary = "Get user pvp matches",
operationId = "getUserPvPMatches",
description = """Get pvp matches played by authenticated user""",
responses = [
ApiResponse(responseCode = "200", description = "OK", content = [Content(array = ArraySchema(schema = Schema(implementation = PvPMatchDto::class)))]),
ApiResponse(responseCode = "401", description = "Unauthorized")
],
security = [ SecurityRequirement(name = "http-bearer") ]
)
@RequestMapping(
method = [RequestMethod.GET],
value = ["/user/pvpmatches"],
produces = ["application/json"]
)
fun getUserPvPMatches(@Parameter(description = "Index of the page") @Valid @RequestParam(value = "page", required = false) page: kotlin.Int?,@Parameter(description = "Size of the page") @Valid @RequestParam(value = "size", required = false) size: kotlin.Int?): ResponseEntity<List<PvPMatchDto>> {
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
}
}
56 changes: 56 additions & 0 deletions library/src/main/kotlin/delta/codecharacter/core/PvpGameApi.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.1.0).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package delta.codecharacter.core

import io.swagger.v3.oas.annotations.*
import io.swagger.v3.oas.annotations.enums.*
import io.swagger.v3.oas.annotations.media.*
import io.swagger.v3.oas.annotations.responses.*
import io.swagger.v3.oas.annotations.security.*
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity

import org.springframework.web.bind.annotation.*
import org.springframework.validation.annotation.Validated
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.beans.factory.annotation.Autowired

import jakarta.validation.constraints.DecimalMax
import jakarta.validation.constraints.DecimalMin
import jakarta.validation.constraints.Email
import jakarta.validation.constraints.Max
import jakarta.validation.constraints.Min
import jakarta.validation.constraints.NotNull
import jakarta.validation.constraints.Pattern
import jakarta.validation.constraints.Size
import jakarta.validation.Valid

import kotlin.collections.List
import kotlin.collections.Map

@Validated
@RequestMapping("\${api.base-path:}")
interface PvpGameApi {

@Operation(
summary = "Get pvp game logs by game ID",
operationId = "getPvpGameLogsByGameId",
description = """Get pvp game logs by game ID""",
responses = [
ApiResponse(responseCode = "200", description = "OK", content = [Content(schema = Schema(implementation = kotlin.String::class))])
],
security = [ SecurityRequirement(name = "http-bearer") ]
)
@RequestMapping(
method = [RequestMethod.GET],
value = ["/pvpgames/{gameId}/logs"],
produces = ["application/json"]
)
fun getPvpGameLogsByGameId(@Parameter(description = "UUID of the game", required = true) @PathVariable("gameId") gameId: java.util.UUID): ResponseEntity<kotlin.String> {
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package delta.codecharacter.dtos
import java.util.Objects
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.annotation.JsonValue
import delta.codecharacter.dtos.CodeTypeDto
import delta.codecharacter.dtos.LanguageDto
import jakarta.validation.constraints.DecimalMax
import jakarta.validation.constraints.DecimalMin
Expand All @@ -22,6 +23,7 @@ import io.swagger.v3.oas.annotations.media.Schema
* @param message
* @param language
* @param createdAt
* @param codeType
* @param parentRevision
*/
data class CodeRevisionDto(
Expand All @@ -42,6 +44,10 @@ data class CodeRevisionDto(
@Schema(example = "null", required = true, description = "")
@get:JsonProperty("createdAt", required = true) val createdAt: java.time.Instant,

@field:Valid
@Schema(example = "null", required = true, description = "")
@get:JsonProperty("codeType", required = true) val codeType: CodeTypeDto = CodeTypeDto.NORMAL,

@Schema(example = "123e4567-e89b-12d3-a456-426614174111", description = "")
@get:JsonProperty("parentRevision") val parentRevision: java.util.UUID? = null
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ import io.swagger.v3.oas.annotations.media.Schema

/**
*
* Values: NORMAL,DAILY_CHALLENGE
* Values: NORMAL,DAILY_CHALLENGE,PVP
*/
enum class CodeTypeDto(val value: kotlin.String) {

@JsonProperty("NORMAL") NORMAL("NORMAL"),
@JsonProperty("DAILY_CHALLENGE") DAILY_CHALLENGE("DAILY_CHALLENGE")
@JsonProperty("DAILY_CHALLENGE") DAILY_CHALLENGE("DAILY_CHALLENGE"),
@JsonProperty("PVP") PVP("PVP")
}

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import io.swagger.v3.oas.annotations.media.Schema
* @param opponentUsername Username of the opponent
* @param mapRevisionId Revision ID of the map
* @param codeRevisionId Revision of the code
* @param codeRevisionId2 Revision of the code (for SELF-PVP mode)
*/
data class CreateMatchRequestDto(

Expand All @@ -35,7 +36,10 @@ data class CreateMatchRequestDto(
@get:JsonProperty("mapRevisionId") val mapRevisionId: java.util.UUID? = null,

@Schema(example = "null", description = "Revision of the code")
@get:JsonProperty("codeRevisionId") val codeRevisionId: java.util.UUID? = null
@get:JsonProperty("codeRevisionId") val codeRevisionId: java.util.UUID? = null,

@Schema(example = "null", description = "Revision of the code (for SELF-PVP mode)")
@get:JsonProperty("codeRevisionId2") val codeRevisionId2: java.util.UUID? = null
) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ import io.swagger.v3.oas.annotations.media.Schema

/**
* Match Mode
* Values: SELF,MANUAL,AUTO,DAILYCHALLENGE
* Values: SELF,MANUAL,AUTO,DAILYCHALLENGE,PVP,SELFPVP
*/
enum class MatchModeDto(val value: kotlin.String) {

@JsonProperty("SELF") SELF("SELF"),
@JsonProperty("MANUAL") MANUAL("MANUAL"),
@JsonProperty("AUTO") AUTO("AUTO"),
@JsonProperty("DAILYCHALLENGE") DAILYCHALLENGE("DAILYCHALLENGE")
@JsonProperty("DAILYCHALLENGE") DAILYCHALLENGE("DAILYCHALLENGE"),
@JsonProperty("PVP") PVP("PVP"),
@JsonProperty("SELFPVP") SELFPVP("SELFPVP")
}

42 changes: 42 additions & 0 deletions library/src/main/kotlin/delta/codecharacter/dtos/PvPGameDto.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package delta.codecharacter.dtos

import java.util.Objects
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.annotation.JsonValue
import delta.codecharacter.dtos.PvPGameStatusDto
import jakarta.validation.constraints.DecimalMax
import jakarta.validation.constraints.DecimalMin
import jakarta.validation.constraints.Email
import jakarta.validation.constraints.Max
import jakarta.validation.constraints.Min
import jakarta.validation.constraints.NotNull
import jakarta.validation.constraints.Pattern
import jakarta.validation.constraints.Size
import jakarta.validation.Valid
import io.swagger.v3.oas.annotations.media.Schema

/**
* PvP Game model
* @param id
* @param scorePlayer1
* @param scorePlayer2
* @param status
*/
data class PvPGameDto(

@Schema(example = "123e4567-e89b-12d3-a456-426614174000", required = true, description = "")
@get:JsonProperty("id", required = true) val id: java.util.UUID,

@Schema(example = "69", required = true, description = "")
@get:JsonProperty("scorePlayer1", required = true) val scorePlayer1: kotlin.Int,

@Schema(example = "69", required = true, description = "")
@get:JsonProperty("scorePlayer2", required = true) val scorePlayer2: kotlin.Int,

@field:Valid
@Schema(example = "null", required = true, description = "")
@get:JsonProperty("status", required = true) val status: PvPGameStatusDto
) {

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package delta.codecharacter.dtos

import java.util.Objects
import com.fasterxml.jackson.annotation.JsonValue
import com.fasterxml.jackson.annotation.JsonProperty
import jakarta.validation.constraints.DecimalMax
import jakarta.validation.constraints.DecimalMin
import jakarta.validation.constraints.Email
import jakarta.validation.constraints.Max
import jakarta.validation.constraints.Min
import jakarta.validation.constraints.NotNull
import jakarta.validation.constraints.Pattern
import jakarta.validation.constraints.Size
import jakarta.validation.Valid
import io.swagger.v3.oas.annotations.media.Schema

/**
*
* Values: IDLE,EXECUTING,EXECUTED,EXECUTE_ERROR
*/
enum class PvPGameStatusDto(val value: kotlin.String) {

@JsonProperty("IDLE") IDLE("IDLE"),
@JsonProperty("EXECUTING") EXECUTING("EXECUTING"),
@JsonProperty("EXECUTED") EXECUTED("EXECUTED"),
@JsonProperty("EXECUTE_ERROR") EXECUTE_ERROR("EXECUTE_ERROR")
}

Loading
Loading