Skip to content

Commit e68376a

Browse files
bhoopesh369MughilSrinivasanshubham-1806
authored
feat: PvP (#4)
* wip: pvp * new queue for pvp, playerCode * update: rename file * feat: pvp * feat: match tests for pvp * feat: store codes for pvp seperate * feat: pvp game tests * fix: pvp response * feat: add self match for pvp * update: pagination for get user-matches * feat : PvP leaderboard (#5) * feat : PvP leaderboard * fix : commit bugs * fix : commit bugs * fix: pvp leaderbord * fix: variable names * fix: queue name * fix: pvp fixes * fix: pvp commit history * fix(player_code): python state typecast * fix: pvp initial code * feat: abilities --------- Co-authored-by: Mughil Srinivasan R S <[email protected]> Co-authored-by: shubham-1806 <[email protected]>
1 parent 4b7add5 commit e68376a

File tree

71 files changed

+2081
-141
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+2081
-141
lines changed

docs/spec/CodeCharacter-API.yml

Lines changed: 392 additions & 4 deletions
Large diffs are not rendered by default.

library/.openapi-generator/FILES

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
.openapi-generator-ignore
2-
README.md
3-
build.gradle.kts
4-
pom.xml
5-
settings.gradle
61
src/main/kotlin/delta/codecharacter/SpringDocConfiguration.kt
7-
src/main/kotlin/delta/codecharacter/core/ApiUtil.kt
82
src/main/kotlin/delta/codecharacter/core/AuthApi.kt
93
src/main/kotlin/delta/codecharacter/core/CodeApi.kt
104
src/main/kotlin/delta/codecharacter/core/CurrentUserApi.kt
@@ -14,6 +8,7 @@ src/main/kotlin/delta/codecharacter/core/LeaderboardApi.kt
148
src/main/kotlin/delta/codecharacter/core/MapApi.kt
159
src/main/kotlin/delta/codecharacter/core/MatchApi.kt
1610
src/main/kotlin/delta/codecharacter/core/NotificationApi.kt
11+
src/main/kotlin/delta/codecharacter/core/PvpGameApi.kt
1712
src/main/kotlin/delta/codecharacter/core/UserApi.kt
1813
src/main/kotlin/delta/codecharacter/dtos/ActivateUserRequestDto.kt
1914
src/main/kotlin/delta/codecharacter/dtos/AuthStatusResponseDto.kt
@@ -46,6 +41,11 @@ src/main/kotlin/delta/codecharacter/dtos/NotificationDto.kt
4641
src/main/kotlin/delta/codecharacter/dtos/PasswordLoginRequestDto.kt
4742
src/main/kotlin/delta/codecharacter/dtos/PasswordLoginResponseDto.kt
4843
src/main/kotlin/delta/codecharacter/dtos/PublicUserDto.kt
44+
src/main/kotlin/delta/codecharacter/dtos/PvPGameDto.kt
45+
src/main/kotlin/delta/codecharacter/dtos/PvPGameStatusDto.kt
46+
src/main/kotlin/delta/codecharacter/dtos/PvPLeaderBoardResponseDto.kt
47+
src/main/kotlin/delta/codecharacter/dtos/PvPMatchDto.kt
48+
src/main/kotlin/delta/codecharacter/dtos/PvPUserStatsDto.kt
4949
src/main/kotlin/delta/codecharacter/dtos/RatingHistoryDto.kt
5050
src/main/kotlin/delta/codecharacter/dtos/RegisterUserRequestDto.kt
5151
src/main/kotlin/delta/codecharacter/dtos/ResetPasswordRequestDto.kt

library/src/main/kotlin/delta/codecharacter/SpringDocConfiguration.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import io.swagger.v3.oas.models.info.License
1010
import io.swagger.v3.oas.models.Components
1111
import io.swagger.v3.oas.models.security.SecurityScheme
1212

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

library/src/main/kotlin/delta/codecharacter/core/CodeApi.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ interface CodeApi {
7878
value = ["/user/code/revisions"],
7979
produces = ["application/json"]
8080
)
81-
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>> {
81+
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>> {
8282
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
8383
}
8484

@@ -97,7 +97,7 @@ interface CodeApi {
9797
value = ["/user/code/latest"],
9898
produces = ["application/json"]
9999
)
100-
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> {
100+
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> {
101101
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
102102
}
103103

library/src/main/kotlin/delta/codecharacter/core/DailyChallengesApi.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import delta.codecharacter.dtos.DailyChallengeGetRequestDto
99
import delta.codecharacter.dtos.DailyChallengeLeaderBoardResponseDto
1010
import delta.codecharacter.dtos.DailyChallengeMatchRequestDto
1111
import delta.codecharacter.dtos.GenericErrorDto
12+
import delta.codecharacter.dtos.MatchDto
1213
import io.swagger.v3.oas.annotations.*
1314
import io.swagger.v3.oas.annotations.enums.*
1415
import io.swagger.v3.oas.annotations.media.*
@@ -102,4 +103,23 @@ interface DailyChallengesApi {
102103
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>> {
103104
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
104105
}
106+
107+
@Operation(
108+
summary = "Get user daily challenge matches",
109+
operationId = "getUserDCMatches",
110+
description = """Get daily-challenge matches played by authenticated user""",
111+
responses = [
112+
ApiResponse(responseCode = "200", description = "OK", content = [Content(array = ArraySchema(schema = Schema(implementation = MatchDto::class)))]),
113+
ApiResponse(responseCode = "401", description = "Unauthorized")
114+
],
115+
security = [ SecurityRequirement(name = "http-bearer") ]
116+
)
117+
@RequestMapping(
118+
method = [RequestMethod.GET],
119+
value = ["/dc/matches"],
120+
produces = ["application/json"]
121+
)
122+
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>> {
123+
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
124+
}
105125
}

library/src/main/kotlin/delta/codecharacter/core/LeaderboardApi.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package delta.codecharacter.core
77

88
import delta.codecharacter.dtos.LeaderboardEntryDto
9+
import delta.codecharacter.dtos.PvPLeaderBoardResponseDto
910
import delta.codecharacter.dtos.TierTypeDto
1011
import io.swagger.v3.oas.annotations.*
1112
import io.swagger.v3.oas.annotations.enums.*
@@ -56,4 +57,23 @@ interface LeaderboardApi {
5657
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>> {
5758
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
5859
}
60+
61+
@Operation(
62+
summary = "Get PvP leaderboard",
63+
operationId = "getPvPLeaderboard",
64+
description = """Get PvP leaderboard""",
65+
responses = [
66+
ApiResponse(responseCode = "200", description = "OK", content = [Content(array = ArraySchema(schema = Schema(implementation = PvPLeaderBoardResponseDto::class)))]),
67+
ApiResponse(responseCode = "401", description = "Unauthorized")
68+
],
69+
security = [ SecurityRequirement(name = "http-bearer") ]
70+
)
71+
@RequestMapping(
72+
method = [RequestMethod.GET],
73+
value = ["/pvpleaderboard"],
74+
produces = ["application/json"]
75+
)
76+
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>> {
77+
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
78+
}
5979
}

library/src/main/kotlin/delta/codecharacter/core/MatchApi.kt

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package delta.codecharacter.core
88
import delta.codecharacter.dtos.CreateMatchRequestDto
99
import delta.codecharacter.dtos.GenericErrorDto
1010
import delta.codecharacter.dtos.MatchDto
11+
import delta.codecharacter.dtos.PvPMatchDto
1112
import io.swagger.v3.oas.annotations.*
1213
import io.swagger.v3.oas.annotations.enums.*
1314
import io.swagger.v3.oas.annotations.media.*
@@ -65,7 +66,7 @@ interface MatchApi {
6566
operationId = "getTopMatches",
6667
description = """Get top matches""",
6768
responses = [
68-
ApiResponse(responseCode = "200", description = "OK", content = [Content(array = ArraySchema(schema = Schema(implementation = MatchDto::class)))]),
69+
ApiResponse(responseCode = "200", description = "OK", content = [Content(array = ArraySchema(schema = Schema(implementation = kotlin.Any::class)))]),
6970
ApiResponse(responseCode = "401", description = "Unauthorized")
7071
],
7172
security = [ SecurityRequirement(name = "http-bearer") ]
@@ -75,14 +76,14 @@ interface MatchApi {
7576
value = ["/top-matches"],
7677
produces = ["application/json"]
7778
)
78-
fun getTopMatches(): ResponseEntity<List<MatchDto>> {
79+
fun getTopMatches(): ResponseEntity<List<kotlin.Any>> {
7980
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
8081
}
8182

8283
@Operation(
8384
summary = "Get user matches",
84-
operationId = "getUserMatches",
85-
description = """Get matches played by authenticated user""",
85+
operationId = "getUserNormalMatches",
86+
description = """Get normal matches played by authenticated user""",
8687
responses = [
8788
ApiResponse(responseCode = "200", description = "OK", content = [Content(array = ArraySchema(schema = Schema(implementation = MatchDto::class)))]),
8889
ApiResponse(responseCode = "401", description = "Unauthorized")
@@ -94,7 +95,26 @@ interface MatchApi {
9495
value = ["/user/matches"],
9596
produces = ["application/json"]
9697
)
97-
fun getUserMatches(): ResponseEntity<List<MatchDto>> {
98+
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>> {
99+
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
100+
}
101+
102+
@Operation(
103+
summary = "Get user pvp matches",
104+
operationId = "getUserPvPMatches",
105+
description = """Get pvp matches played by authenticated user""",
106+
responses = [
107+
ApiResponse(responseCode = "200", description = "OK", content = [Content(array = ArraySchema(schema = Schema(implementation = PvPMatchDto::class)))]),
108+
ApiResponse(responseCode = "401", description = "Unauthorized")
109+
],
110+
security = [ SecurityRequirement(name = "http-bearer") ]
111+
)
112+
@RequestMapping(
113+
method = [RequestMethod.GET],
114+
value = ["/user/pvpmatches"],
115+
produces = ["application/json"]
116+
)
117+
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>> {
98118
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
99119
}
100120
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.1.0).
3+
* https://openapi-generator.tech
4+
* Do not edit the class manually.
5+
*/
6+
package delta.codecharacter.core
7+
8+
import io.swagger.v3.oas.annotations.*
9+
import io.swagger.v3.oas.annotations.enums.*
10+
import io.swagger.v3.oas.annotations.media.*
11+
import io.swagger.v3.oas.annotations.responses.*
12+
import io.swagger.v3.oas.annotations.security.*
13+
import org.springframework.http.HttpStatus
14+
import org.springframework.http.MediaType
15+
import org.springframework.http.ResponseEntity
16+
17+
import org.springframework.web.bind.annotation.*
18+
import org.springframework.validation.annotation.Validated
19+
import org.springframework.web.context.request.NativeWebRequest
20+
import org.springframework.beans.factory.annotation.Autowired
21+
22+
import jakarta.validation.constraints.DecimalMax
23+
import jakarta.validation.constraints.DecimalMin
24+
import jakarta.validation.constraints.Email
25+
import jakarta.validation.constraints.Max
26+
import jakarta.validation.constraints.Min
27+
import jakarta.validation.constraints.NotNull
28+
import jakarta.validation.constraints.Pattern
29+
import jakarta.validation.constraints.Size
30+
import jakarta.validation.Valid
31+
32+
import kotlin.collections.List
33+
import kotlin.collections.Map
34+
35+
@Validated
36+
@RequestMapping("\${api.base-path:}")
37+
interface PvpGameApi {
38+
39+
@Operation(
40+
summary = "Get pvp game logs by game ID",
41+
operationId = "getPvpGameLogsByGameId",
42+
description = """Get pvp game logs by game ID""",
43+
responses = [
44+
ApiResponse(responseCode = "200", description = "OK", content = [Content(schema = Schema(implementation = kotlin.String::class))])
45+
],
46+
security = [ SecurityRequirement(name = "http-bearer") ]
47+
)
48+
@RequestMapping(
49+
method = [RequestMethod.GET],
50+
value = ["/pvpgames/{gameId}/logs"],
51+
produces = ["application/json"]
52+
)
53+
fun getPvpGameLogsByGameId(@Parameter(description = "UUID of the game", required = true) @PathVariable("gameId") gameId: java.util.UUID): ResponseEntity<kotlin.String> {
54+
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
55+
}
56+
}

library/src/main/kotlin/delta/codecharacter/dtos/CodeRevisionDto.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package delta.codecharacter.dtos
33
import java.util.Objects
44
import com.fasterxml.jackson.annotation.JsonProperty
55
import com.fasterxml.jackson.annotation.JsonValue
6+
import delta.codecharacter.dtos.CodeTypeDto
67
import delta.codecharacter.dtos.LanguageDto
78
import jakarta.validation.constraints.DecimalMax
89
import jakarta.validation.constraints.DecimalMin
@@ -22,6 +23,7 @@ import io.swagger.v3.oas.annotations.media.Schema
2223
* @param message
2324
* @param language
2425
* @param createdAt
26+
* @param codeType
2527
* @param parentRevision
2628
*/
2729
data class CodeRevisionDto(
@@ -42,6 +44,10 @@ data class CodeRevisionDto(
4244
@Schema(example = "null", required = true, description = "")
4345
@get:JsonProperty("createdAt", required = true) val createdAt: java.time.Instant,
4446

47+
@field:Valid
48+
@Schema(example = "null", required = true, description = "")
49+
@get:JsonProperty("codeType", required = true) val codeType: CodeTypeDto = CodeTypeDto.NORMAL,
50+
4551
@Schema(example = "123e4567-e89b-12d3-a456-426614174111", description = "")
4652
@get:JsonProperty("parentRevision") val parentRevision: java.util.UUID? = null
4753
) {

library/src/main/kotlin/delta/codecharacter/dtos/CodeTypeDto.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ import io.swagger.v3.oas.annotations.media.Schema
1616

1717
/**
1818
*
19-
* Values: NORMAL,DAILY_CHALLENGE
19+
* Values: NORMAL,DAILY_CHALLENGE,PVP
2020
*/
2121
enum class CodeTypeDto(val value: kotlin.String) {
2222

2323
@JsonProperty("NORMAL") NORMAL("NORMAL"),
24-
@JsonProperty("DAILY_CHALLENGE") DAILY_CHALLENGE("DAILY_CHALLENGE")
24+
@JsonProperty("DAILY_CHALLENGE") DAILY_CHALLENGE("DAILY_CHALLENGE"),
25+
@JsonProperty("PVP") PVP("PVP")
2526
}
2627

0 commit comments

Comments
 (0)