forked from SteamWar/SteamWar
Refactor PersonalKitTable to use explicit ID column initialization and update create method to utilize insert operation.
Signed-off-by: Chaoscaot <max@maxsp.de>
This commit is contained in:
@@ -60,15 +60,17 @@ class InternalKit(id: EntityID<CompositeID>): CompositeEntity(id) {
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun create(userId: Int, gamemode: String, kitName: String, rawInventory: String, rawArmor: String) = useDb {
|
fun create(userId: Int, gamemode: String, kitName: String, rawInventory: String, rawArmor: String) = useDb {
|
||||||
PersonalKitTable.insert {
|
new(
|
||||||
it[this.userId] = EntityID(userId, SteamwarUserTable)
|
CompositeID {
|
||||||
it[this.gamemode] = gamemode
|
it[PersonalKitTable.userId] = EntityID(userId, SteamwarUserTable)
|
||||||
it[this.kitName] = kitName
|
it[PersonalKitTable.gamemode] = gamemode
|
||||||
it[this.inventory] = rawInventory
|
it[PersonalKitTable.kitName] = kitName
|
||||||
it[this.armor] = rawArmor
|
}
|
||||||
it[this.inUse] = true
|
) {
|
||||||
|
this.inventory = rawInventory
|
||||||
|
this.armor = rawArmor
|
||||||
|
this.inUse = true
|
||||||
}
|
}
|
||||||
get(userId, gamemode, kitName)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@@ -80,10 +82,15 @@ class InternalKit(id: EntityID<CompositeID>): CompositeEntity(id) {
|
|||||||
|
|
||||||
var userID by PersonalKitTable.userId.transform({ EntityID(it, SteamwarUserTable) }, { it.value })
|
var userID by PersonalKitTable.userId.transform({ EntityID(it, SteamwarUserTable) }, { it.value })
|
||||||
private set
|
private set
|
||||||
var gamemode by PersonalKitTable.gamemode
|
private var gameMode by PersonalKitTable.gamemode
|
||||||
private set
|
val gamemode: String
|
||||||
var name by PersonalKitTable.kitName
|
get() = gameMode.value
|
||||||
|
|
||||||
|
var kitName by PersonalKitTable.kitName
|
||||||
private set
|
private set
|
||||||
|
val name: String
|
||||||
|
get() = kitName.value
|
||||||
|
|
||||||
var rawInventory by PersonalKitTable.inventory
|
var rawInventory by PersonalKitTable.inventory
|
||||||
private set
|
private set
|
||||||
var rawArmor by PersonalKitTable.armor
|
var rawArmor by PersonalKitTable.armor
|
||||||
@@ -99,7 +106,7 @@ class InternalKit(id: EntityID<CompositeID>): CompositeEntity(id) {
|
|||||||
set(value) = useDb { rawArmor = value }
|
set(value) = useDb { rawArmor = value }
|
||||||
|
|
||||||
fun setDefault() = useDb {
|
fun setDefault() = useDb {
|
||||||
find { PersonalKitTable.userId eq userID and (PersonalKitTable.gamemode eq gamemode) and (PersonalKitTable.inUse eq true) }
|
find { PersonalKitTable.userId eq userID and (PersonalKitTable.gamemode eq gameMode) and (PersonalKitTable.inUse eq true) }
|
||||||
.forEach { it.inUse = false }
|
.forEach { it.inUse = false }
|
||||||
inUse = true
|
inUse = true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user