Skip to content

Commit

Permalink
feat: pvp auto-match (#6)
Browse files Browse the repository at this point in the history
* feat: pvp auto-match

* fix: add tiers for pvp leaderboard

* update: add pvp shedulers
  • Loading branch information
bhoopesh369 authored Feb 13, 2024
1 parent 06adde8 commit 80052cb
Show file tree
Hide file tree
Showing 23 changed files with 469 additions and 102 deletions.
24 changes: 19 additions & 5 deletions docs/spec/CodeCharacter-API.yml
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,11 @@ paths:
in: query
name: size
description: Size of the page
- schema:
$ref: '#/components/schemas/TierType'
in: query
name: tier
description: Leaderboard Tier
description: Get PvP leaderboard
parameters: []

Expand Down Expand Up @@ -1661,23 +1666,31 @@ paths:
components:
schemas:
UserMatchStats:
title: UserMatchStats
title: UserMatchStat
type: array
description: User Match Stats array model
items:
anyOf:
- $ref: '#/components/schemas/UserMatchStat'
required:
- stat

UserMatchStat:
title: UserMatchStat
type: object
description: User Match Stats model
description: User Match Stat model
properties:
avgAtk:
type: number
default: 0
dc_wins:
type: number
default: 0
coins:
type: number
default: 0
required:
- avgAtk
- dc_wins
- coins

PasswordLoginRequest:
title: PasswordLoginRequest
type: object
Expand Down Expand Up @@ -2599,6 +2612,7 @@ components:
- DAILYCHALLENGE
- PVP
- SELFPVP
- AUTOPVP
description: Match Mode
Verdict:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ interface LeaderboardApi {
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>> {
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?,@Parameter(description = "Leaderboard Tier", schema = Schema(allowableValues = ["TIER_PRACTICE", "TIER1", "TIER2", "TIER3", "TIER4"])) @Valid @RequestParam(value = "tier", required = false) tier: TierTypeDto?): ResponseEntity<List<PvPLeaderBoardResponseDto>> {
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import io.swagger.v3.oas.annotations.media.Schema

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

Expand All @@ -25,6 +25,7 @@ enum class MatchModeDto(val value: kotlin.String) {
@JsonProperty("AUTO") AUTO("AUTO"),
@JsonProperty("DAILYCHALLENGE") DAILYCHALLENGE("DAILYCHALLENGE"),
@JsonProperty("PVP") PVP("PVP"),
@JsonProperty("SELFPVP") SELFPVP("SELFPVP")
@JsonProperty("SELFPVP") SELFPVP("SELFPVP"),
@JsonProperty("AUTOPVP") AUTOPVP("AUTOPVP")
}

Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,23 @@ import jakarta.validation.constraints.Pattern
import jakarta.validation.constraints.Size
import jakarta.validation.Valid
import io.swagger.v3.oas.annotations.media.Schema
import java.math.BigDecimal

/**
* User Match Stat model
* @param avgAtk
* @param dcWins
* @param coins
* @param avgAtk
* @param dcWins
* @param coins
*/
data class UserMatchStatDto(

@Schema(example = "null", required = true, description = "")
@get:JsonProperty("avgAtk", required = true) val avgAtk: java.math.BigDecimal = BigDecimal.ZERO,
@get:JsonProperty("avgAtk", required = true) val avgAtk: java.math.BigDecimal,

@Schema(example = "null", required = true, description = "")
@get:JsonProperty("dc_wins", required = true) val dcWins: java.math.BigDecimal = BigDecimal.ZERO,
@get:JsonProperty("dc_wins", required = true) val dcWins: java.math.BigDecimal,

@Schema(example = "null", required = true, description = "")
@get:JsonProperty("coins", required = true) val coins: java.math.BigDecimal = BigDecimal.ZERO
@get:JsonProperty("coins", required = true) val coins: java.math.BigDecimal
) {

}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package delta.codecharacter.dtos

import java.util.Objects
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

/**
* User Match Stats model
* @param avgAtk
* @param dcWins
* @param coins
*/
data class UserMatchStatsDto(

@Schema(example = "null", required = true, description = "")
@get:JsonProperty("avgAtk", required = true) val avgAtk: java.math.BigDecimal,

@Schema(example = "null", required = true, description = "")
@get:JsonProperty("dc_wins", required = true) val dcWins: java.math.BigDecimal,

@Schema(example = "null", required = true, description = "")
@get:JsonProperty("coins", required = true) val coins: java.math.BigDecimal
) {

}

Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,23 @@ import jakarta.validation.constraints.Pattern
import jakarta.validation.constraints.Size
import jakarta.validation.Valid
import io.swagger.v3.oas.annotations.media.Schema
import java.math.BigDecimal

/**
*
* @param avgAtk
* @param dcWins
* @param coins
*
* @param avgAtk
* @param dcWins
* @param coins
*/
data class UserMatchStatsInnerDto(

@Schema(example = "null", required = true, description = "")
@get:JsonProperty("avgAtk", required = true) val avgAtk: java.math.BigDecimal = BigDecimal.ZERO,
@get:JsonProperty("avgAtk", required = true) val avgAtk: java.math.BigDecimal,

@Schema(example = "null", required = true, description = "")
@get:JsonProperty("dc_wins", required = true) val dcWins: java.math.BigDecimal = BigDecimal.ZERO,
@get:JsonProperty("dc_wins", required = true) val dcWins: java.math.BigDecimal,

@Schema(example = "null", required = true, description = "")
@get:JsonProperty("coins", required = true) val coins: java.math.BigDecimal = BigDecimal.ZERO
@get:JsonProperty("coins", required = true) val coins: java.math.BigDecimal
) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import java.util.UUID
class CodeRevisionService(@Autowired private val codeRevisionRepository: CodeRevisionRepository) {

fun createCodeRevision(userId: UUID, createCodeRevisionRequestDto: CreateCodeRevisionRequestDto) {
println(createCodeRevisionRequestDto)
val (code, message, language) = createCodeRevisionRequestDto
val parentCodeRevision =
codeRevisionRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,13 @@ class GameService(
destruction = destructionPercentage, coinsUsed = coinsUsed, status = gameStatus
)
val game = gameRepository.save(newGameEntity)
if(!codeTutorialMatchRepository.findById(game.matchId).isPresent) {
gameLogService.saveGameLog(game.id, gameResult.log)
}
else{

if(codeTutorialMatchRepository.findById(game.matchId).isPresent) {
gameRepository.deleteById(game.id)
return game
}

gameLogService.saveGameLog(game.id, gameResult.log)
return game
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class LeaderboardController(@Autowired private val publicUserService: PublicUser
override fun getPvPLeaderboard(
page: Int?,
size: Int?,
tier: TierTypeDto?,
): ResponseEntity<List<PvPLeaderBoardResponseDto>> {
return ResponseEntity.ok(publicUserService.getPvPLeaderboard(page, size))
return ResponseEntity.ok(publicUserService.getPvPLeaderboard(page, size, tier))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ enum class MatchModeEnum {
SELFPVP,
MANUAL,
AUTO,
AUTOPVP,
PVP
}
Loading

0 comments on commit 80052cb

Please sign in to comment.