-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from dungeon-hub/develop
Bring main up to date
- Loading branch information
Showing
68 changed files
with
1,797 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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,7 @@ | ||
package net.dungeonhub.enums | ||
|
||
enum class QueueStep { | ||
Confirmation, | ||
Transcript, | ||
Approving | ||
} |
11 changes: 11 additions & 0 deletions
11
model/src/main/kotlin/net/dungeonhub/enums/ScoreResetType.kt
This file contains 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,11 @@ | ||
package net.dungeonhub.enums | ||
|
||
import dev.kordex.core.commands.application.slash.converters.ChoiceEnum | ||
|
||
enum class ScoreResetType : ChoiceEnum { | ||
Default, | ||
Event, | ||
Both; | ||
|
||
override val readableName = name | ||
} |
This file contains 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,32 @@ | ||
package net.dungeonhub.enums | ||
|
||
import dev.kordex.core.commands.application.slash.converters.ChoiceEnum | ||
import net.dungeonhub.model.carry_type.CarryTypeModel | ||
|
||
enum class ScoreType( | ||
override val readableName: String, | ||
val displayName: String, | ||
val leaderboardSuffix: String? | ||
) : ChoiceEnum { | ||
Default("current", "Current"), | ||
Alltime("alltime", "Alltime", "(all-time)"), | ||
Event("event", "Event", "(event)"); | ||
|
||
constructor(name: String, displayName: String) : this(name, displayName, null) | ||
|
||
fun getLeaderboardTitle(carryType: CarryTypeModel?): String { | ||
val suffix = if (leaderboardSuffix.isNullOrBlank()) "" else " $leaderboardSuffix" | ||
|
||
if (carryType == null) { | ||
return "Leaderboard | Total score$suffix" | ||
} | ||
|
||
return "Leaderboard | ${carryType.displayName}-Carries$suffix" | ||
} | ||
|
||
companion object { | ||
fun fromName(name: String): ScoreType? = entries.firstOrNull { currentType: ScoreType -> | ||
currentType.readableName.equals(name, ignoreCase = true) | ||
} | ||
} | ||
} |
This file contains 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,9 @@ | ||
package net.dungeonhub.enums | ||
|
||
enum class WarningAction { | ||
Timeout, | ||
Ban, | ||
RemoveRole, | ||
RemoveRoleGroup, | ||
AddRole; | ||
} |
6 changes: 6 additions & 0 deletions
6
model/src/main/kotlin/net/dungeonhub/enums/WarningComparison.kt
This file contains 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,6 @@ | ||
package net.dungeonhub.enums | ||
|
||
enum class WarningComparison { | ||
Equal, | ||
GreaterOrEqual; | ||
} |
This file contains 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,8 @@ | ||
package net.dungeonhub.enums | ||
|
||
enum class WarningType { | ||
Strike, | ||
Minor, | ||
Major, | ||
Serious; | ||
} |
5 changes: 5 additions & 0 deletions
5
model/src/main/kotlin/net/dungeonhub/expections/EntityUnknownException.kt
This file contains 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,5 @@ | ||
package net.dungeonhub.expections | ||
|
||
class EntityUnknownException( | ||
val id: Long | ||
) : IllegalStateException() |
6 changes: 6 additions & 0 deletions
6
model/src/main/kotlin/net/dungeonhub/model/auth/JwtTokenModel.kt
This file contains 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,6 @@ | ||
package net.dungeonhub.model.auth | ||
|
||
import java.time.Instant | ||
|
||
@JvmRecord | ||
data class JwtTokenModel(val token: String, val validUntil: Instant) |
44 changes: 44 additions & 0 deletions
44
model/src/main/kotlin/net/dungeonhub/model/carry/CarryModel.kt
This file contains 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,44 @@ | ||
package net.dungeonhub.model.carry | ||
|
||
import net.dungeonhub.structure.model.Model | ||
import net.dungeonhub.model.carry_difficulty.CarryDifficultyModel | ||
import net.dungeonhub.model.discord_user.DiscordUserModel | ||
import net.dungeonhub.service.MoshiService | ||
import java.time.Instant | ||
|
||
data class CarryModel( | ||
val id: Long, | ||
val amount: Long, | ||
val carryDifficulty: CarryDifficultyModel, | ||
val player: DiscordUserModel, | ||
val carrier: DiscordUserModel, | ||
val approver: Long?, | ||
val attachmentLink: String?, | ||
val time: Instant? | ||
): Model { | ||
val carryTier = carryDifficulty.carryTier | ||
val carryType = carryDifficulty.carryType | ||
|
||
val scoreMultiplier = carryDifficulty.score | ||
|
||
fun calculatePrice(): Long { | ||
val bulkPrice = carryDifficulty.bulkPrice | ||
val bulkAmount = carryDifficulty.bulkAmount | ||
|
||
if (bulkPrice != null && bulkAmount != null && bulkAmount <= amount) { | ||
return bulkPrice.toLong() | ||
} | ||
|
||
return carryDifficulty.price.toLong() | ||
} | ||
|
||
fun calculateScore(): Long { | ||
return scoreMultiplier * amount | ||
} | ||
|
||
companion object { | ||
fun fromString(json: String): CarryModel { | ||
return MoshiService.moshi.adapter(CarryModel::class.java).fromJson(json)!! | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
model/src/main/kotlin/net/dungeonhub/model/carry_difficulty/CarryDifficultyCreationModel.kt
This file contains 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,14 @@ | ||
package net.dungeonhub.model.carry_difficulty | ||
|
||
import net.dungeonhub.structure.model.CreationModel | ||
|
||
class CarryDifficultyCreationModel( | ||
var identifier: String, | ||
var displayName: String, | ||
var thumbnailUrl: String? = null, | ||
var bulkPrice: Int? = null, | ||
var bulkAmount: Int? = null, | ||
var priceName: String? = null, | ||
var price: Int, | ||
var score: Int | ||
) : CreationModel |
65 changes: 65 additions & 0 deletions
65
model/src/main/kotlin/net/dungeonhub/model/carry_difficulty/CarryDifficultyModel.kt
This file contains 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 net.dungeonhub.model.carry_difficulty | ||
|
||
import net.dungeonhub.model.carry_tier.CarryTierModel | ||
import net.dungeonhub.model.carry_type.CarryTypeModel | ||
import net.dungeonhub.service.MoshiService | ||
import net.dungeonhub.structure.model.UpdateableModel | ||
import kotlin.math.max | ||
|
||
class CarryDifficultyModel( | ||
val id: Long, | ||
val identifier: String, | ||
val displayName: String, | ||
val carryTier: CarryTierModel, | ||
val price: Int, | ||
bulkPrice: Int?, | ||
bulkAmount: Int?, | ||
score: Int, | ||
thumbnailUrl: String?, | ||
priceName: String? | ||
) : UpdateableModel<CarryDifficultyUpdateModel, CarryDifficultyModel> { | ||
val bulkPrice = bulkPrice | ||
get() = if (field != null && field > 0) field else null | ||
|
||
val bulkAmount = bulkAmount | ||
get() = if (field != null && field > 0) field else null | ||
|
||
val score = score | ||
get() = max(field, 0) | ||
|
||
val thumbnailUrl: String? = thumbnailUrl | ||
get() = field ?: carryTier.thumbnailUrl | ||
|
||
val priceName = priceName | ||
get() = (if (!field.isNullOrBlank()) field else null) ?: displayName | ||
|
||
val carryType: CarryTypeModel | ||
get() = carryTier.carryType | ||
|
||
fun toJson(): String { | ||
return MoshiService.moshi.adapter(CarryDifficultyModel::class.java).toJson(this) | ||
} | ||
|
||
override fun getUpdateModel(): CarryDifficultyUpdateModel { | ||
return CarryDifficultyUpdateModel(null, null, null, null, null, null, null) | ||
} | ||
|
||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as CarryDifficultyModel | ||
|
||
return id == other.id | ||
} | ||
|
||
override fun hashCode(): Int { | ||
return id.hashCode() | ||
} | ||
|
||
companion object { | ||
fun fromJson(json: String): CarryDifficultyModel { | ||
return MoshiService.moshi.adapter(CarryDifficultyModel::class.java).fromJson(json)!! | ||
} | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
model/src/main/kotlin/net/dungeonhub/model/carry_difficulty/CarryDifficultyUpdateModel.kt
This file contains 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,89 @@ | ||
package net.dungeonhub.model.carry_difficulty | ||
|
||
import net.dungeonhub.service.MoshiService | ||
import net.dungeonhub.structure.model.UpdateModel | ||
|
||
class CarryDifficultyUpdateModel( | ||
var displayName: String?, | ||
thumbnailUrl: String?, | ||
bulkPrice: Int?, | ||
bulkAmount: Int?, | ||
priceName: String?, | ||
var price: Int?, | ||
var score: Int? | ||
) : UpdateModel<CarryDifficultyModel> { | ||
var thumbnailUrl = thumbnailUrl | ||
set(value) { | ||
field = value | ||
resetThumbnailUrl = value == null | ||
} | ||
|
||
var bulkPrice = bulkPrice | ||
set(value) { | ||
field = value | ||
resetBulkPrice = value == null | ||
} | ||
|
||
var bulkAmount = bulkAmount | ||
set(value) { | ||
field = value | ||
resetBulkAmount = value == null | ||
} | ||
|
||
var priceName = priceName | ||
set(value) { | ||
field = value | ||
resetPriceName = value == null | ||
} | ||
|
||
var resetThumbnailUrl = false | ||
private set | ||
var resetBulkPrice = false | ||
private set | ||
var resetBulkAmount = false | ||
private set | ||
var resetPriceName = false | ||
private set | ||
|
||
/*override fun apply(model: CarryDifficultyModel): CarryDifficultyModel { | ||
if (displayName != null) { | ||
model.setDisplayName(displayName) | ||
} | ||
if (thumbnailUrl != null) { | ||
model.setThumbnailUrl(thumbnailUrl) | ||
} | ||
if (bulkPrice != null) { | ||
model.setBulkPrice(bulkPrice) | ||
} | ||
if (bulkAmount != null) { | ||
model.setBulkAmount(bulkAmount) | ||
} | ||
if (priceName != null) { | ||
model.setPriceName(priceName) | ||
} | ||
if (price != null) { | ||
model.setPrice(price) | ||
} | ||
if (score != null) { | ||
model.setScore(score) | ||
} | ||
return model | ||
}*/ | ||
|
||
fun toJson(): String { | ||
return MoshiService.moshi.adapter(CarryDifficultyUpdateModel::class.java).toJson(this) | ||
} | ||
|
||
companion object { | ||
fun fromJson(json: String): CarryDifficultyUpdateModel { | ||
return MoshiService.moshi.adapter(CarryDifficultyUpdateModel::class.java).fromJson(json)!! | ||
} | ||
} | ||
} |
Oops, something went wrong.