forked from SteamWar/SteamWar
Refactor EventRelation, EventGroup, and EventFight classes: ensure database operations are enclosed in useDb, add default values for group points, and override delete methods. Update Gradle build script to include lombok dependencies.
Signed-off-by: Chaoscaot <max@maxsp.de>
This commit is contained in:
@@ -150,7 +150,7 @@ class EventFight(id: EntityID<Int>) : IntEntity(id), Comparable<EventFight> {
|
|||||||
var spielmodus by EventFightTable.gamemode
|
var spielmodus by EventFightTable.gamemode
|
||||||
var map by EventFightTable.map
|
var map by EventFightTable.map
|
||||||
var groupId by EventFightTable.groupId
|
var groupId by EventFightTable.groupId
|
||||||
val group by lazy { Optional.ofNullable(groupId).map { EventGroup[it] } }
|
val group by lazy { useDb { Optional.ofNullable(groupId).map { EventGroup[it] } } }
|
||||||
var spectatePort by EventFightTable.spectatePort
|
var spectatePort by EventFightTable.spectatePort
|
||||||
private var fightStat by EventFightTable.fight.transform({ it?.let { EntityID(it, EventFightTable) } }, { it?.value })
|
private var fightStat by EventFightTable.fight.transform({ it?.let { EntityID(it, EventFightTable) } }, { it?.value })
|
||||||
var fight: Int?
|
var fight: Int?
|
||||||
@@ -191,4 +191,8 @@ class EventFight(id: EntityID<Int>) : IntEntity(id), Comparable<EventFight> {
|
|||||||
this@EventFight.teamRed = teamRed
|
this@EventFight.teamRed = teamRed
|
||||||
this@EventFight.spectatePort = spectatePort
|
this@EventFight.spectatePort = spectatePort
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun delete() = useDb {
|
||||||
|
super.delete()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -31,9 +31,9 @@ object EventGroupTable : IntIdTable("EventGroup", "Id") {
|
|||||||
val event = reference("EventID", EventTable)
|
val event = reference("EventID", EventTable)
|
||||||
val name = varchar("Name", 64)
|
val name = varchar("Name", 64)
|
||||||
val type = enumeration("Type", EventGroup.EventGroupType::class)
|
val type = enumeration("Type", EventGroup.EventGroupType::class)
|
||||||
val pointsPerWin = integer("PointsPerWin")
|
val pointsPerWin = integer("PointsPerWin").default(3)
|
||||||
val pointsPerLoss = integer("PointsPerLoss")
|
val pointsPerLoss = integer("PointsPerLoss").default(0)
|
||||||
val pointsPerDraw = integer("PointsPerDraw")
|
val pointsPerDraw = integer("PointsPerDraw").default(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
class EventGroup(id: EntityID<Int>) : IntEntity(id) {
|
class EventGroup(id: EntityID<Int>) : IntEntity(id) {
|
||||||
@@ -144,6 +144,8 @@ class EventGroup(id: EntityID<Int>) : IntEntity(id) {
|
|||||||
this@EventGroup.pointsPerDraw = pointsPerDraw
|
this@EventGroup.pointsPerDraw = pointsPerDraw
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun delete() = useDb { super.delete() }
|
||||||
|
|
||||||
enum class EventGroupType {
|
enum class EventGroupType {
|
||||||
GROUP_STAGE,
|
GROUP_STAGE,
|
||||||
ELIMINATION_STAGE
|
ELIMINATION_STAGE
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class EventRelation(id: EntityID<Int>) : IntEntity(id) {
|
|||||||
fromId = value!!
|
fromId = value!!
|
||||||
}
|
}
|
||||||
val fromFight: EventFight?
|
val fromFight: EventFight?
|
||||||
get() = fromFightId?.let { EventFight[it] }
|
get() = fromFightId?.let { useDb { EventFight[it] } }
|
||||||
var fromGroupId: Int?
|
var fromGroupId: Int?
|
||||||
get() = if (fromType == FromType.GROUP) fromId else null
|
get() = if (fromType == FromType.GROUP) fromId else null
|
||||||
set(value) = useDb {
|
set(value) = useDb {
|
||||||
@@ -97,7 +97,7 @@ class EventRelation(id: EntityID<Int>) : IntEntity(id) {
|
|||||||
fromId = value!!
|
fromId = value!!
|
||||||
}
|
}
|
||||||
val fromGroup: EventGroup?
|
val fromGroup: EventGroup?
|
||||||
get() = fromGroupId?.let { EventGroup[it] }
|
get() = fromGroupId?.let { useDb { EventGroup[it] } }
|
||||||
var fromPlace by EventRelationTable.fromPlace
|
var fromPlace by EventRelationTable.fromPlace
|
||||||
private set
|
private set
|
||||||
|
|
||||||
@@ -136,6 +136,10 @@ class EventRelation(id: EntityID<Int>) : IntEntity(id) {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun delete() = useDb {
|
||||||
|
super.delete()
|
||||||
|
}
|
||||||
|
|
||||||
enum class FightTeam {
|
enum class FightTeam {
|
||||||
BLUE, RED
|
BLUE, RED
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,4 +64,11 @@ sourceSets {
|
|||||||
exclude("**/*.java", "**/*.kt")
|
exclude("**/*.java", "**/*.kt")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
annotationProcessor libs.lombok
|
||||||
|
compileOnly libs.lombok
|
||||||
|
testCompileOnly libs.lombok
|
||||||
|
testAnnotationProcessor libs.lombok
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user