Add new Referee Stuff
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Chaoscaot 2024-03-15 22:38:54 +01:00
Ursprung 507d4a2f14
Commit 0f652ecad4
5 geänderte Dateien mit 89 neuen und 39 gelöschten Zeilen

@ -1 +1 @@
Subproject commit 53d629970ab6912476475d9d7d3786bd2c218117
Subproject commit d93b846c1f827e2586450496e01d8e46960b4011

Datei anzeigen

@ -45,6 +45,7 @@ val config = Json.decodeFromStream<Config>(File("config.json").inputStream())
fun main() {
SchematicType.Normal.name().length
SteamwarUser.get("Chaoscaot").setPassword("TestTest")
Thread {
while (true) {
Thread.sleep(1000 * 10)

Datei anzeigen

@ -143,10 +143,8 @@ fun Route.configureDataRoutes() {
}
}
inline fun <T> catchException(yield: () -> T): T? {
return try {
yield()
} catch (e: Exception) {
null
}
inline fun <T> catchException(yield: () -> T): T? = try {
yield()
} catch (e: Exception) {
null
}

Datei anzeigen

@ -36,22 +36,57 @@ import java.sql.Timestamp
import java.time.Instant
@Serializable
data class ResponseEventFight(val id: Int, val spielmodus: String, val map: String, val blueTeam: ResponseTeam, val redTeam: ResponseTeam, val kampfleiter: ResponseUser, val start: Long, val ergebnis: Int, val group: String?) {
constructor(eventFight: EventFight): this(eventFight.fightID, eventFight.spielModus, eventFight.map, ResponseTeam(
Team.get(eventFight.teamBlue)), ResponseTeam(Team.get(eventFight.teamRed)),
ResponseUser.get(eventFight.kampfleiter), eventFight.startTime.time, eventFight.ergebnis, Groups.getGroup(eventFight.fightID)?.name)
data class ResponseEventFight(
val id: Int,
val spielmodus: String,
val map: String,
val blueTeam: ResponseTeam,
val redTeam: ResponseTeam,
val start: Long,
val ergebnis: Int,
val spectatePort: Int?,
val group: String?
) {
constructor(eventFight: EventFight) : this(
eventFight.fightID,
eventFight.spielModus,
eventFight.map,
ResponseTeam(Team.get(eventFight.teamBlue)),
ResponseTeam(Team.get(eventFight.teamRed)),
eventFight.startTime.time,
eventFight.ergebnis,
eventFight.spectatePort,
Groups.getGroup(eventFight.fightID)?.name
)
}
@Serializable
data class ResponseTeam(val id: Int, val name: String, val kuerzel: String, val color: String) {
constructor(team: Team): this(team.teamId, team.teamName, team.teamKuerzel, team.teamColor)
constructor(team: Team) : this(team.teamId, team.teamName, team.teamKuerzel, team.teamColor)
}
@Serializable
data class UpdateEventFight(val blueTeam: Int? = null, val redTeam: Int? = null, val kampfleiter: Int? = null, val start: Long? = null, val spielmodus: String? = null, val map: String? = null, val group: String? = null)
data class UpdateEventFight(
val blueTeam: Int? = null,
val redTeam: Int? = null,
val start: Long? = null,
val spielmodus: String? = null,
val map: String? = null,
val group: String? = null,
val spectatePort: Int? = null
)
@Serializable
data class CreateEventFight(val event: Int, val spielmodus: String, val map: String, val blueTeam: Int, val redTeam: Int, val start: Long, val kampfleiter: Int? = null, val group: String? = null)
data class CreateEventFight(
val event: Int,
val spielmodus: String,
val map: String,
val blueTeam: Int,
val redTeam: Int,
val start: Long,
val spectatePort: Int? = null,
val group: String? = null
)
fun Route.configureEventFightRoutes() {
route("/fights") {
@ -65,9 +100,17 @@ fun Route.configureEventFightRoutes() {
call.respond(HttpStatusCode.BadRequest, ResponseError("Invalid body"))
return@post
}
val eventFight = EventFight.create(fight.event, Timestamp.from(Instant.ofEpochMilli(fight.start)), fight.spielmodus, fight.map, fight.blueTeam, fight.redTeam, fight.kampfleiter ?: 0)
if(fight.group != null) {
if(fight.group != "null") {
val eventFight = EventFight.create(
fight.event,
Timestamp.from(Instant.ofEpochMilli(fight.start)),
fight.spielmodus,
fight.map,
fight.blueTeam,
fight.redTeam,
fight.spectatePort
)
if (fight.group != null) {
if (fight.group != "null") {
Groups.setGroup(eventFight.fightID, fight.group)
}
}
@ -90,26 +133,26 @@ fun Route.configureEventFightRoutes() {
call.respond(HttpStatusCode.BadRequest, ResponseError("Invalid body"))
return@put
}
if(updateFight.blueTeam != null && Team.get(updateFight.blueTeam) != null) {
if (updateFight.blueTeam != null && Team.get(updateFight.blueTeam) != null) {
fight.teamBlue = updateFight.blueTeam
}
if(updateFight.redTeam != null && Team.get(updateFight.redTeam) != null) {
if (updateFight.redTeam != null && Team.get(updateFight.redTeam) != null) {
fight.teamRed = updateFight.redTeam
}
if(updateFight.kampfleiter != null && SteamwarUser.get(updateFight.kampfleiter) != null) {
fight.kampfleiter = updateFight.kampfleiter
}
if(updateFight.start != null) {
if (updateFight.start != null) {
fight.startTime = Timestamp.from(Instant.ofEpochMilli(updateFight.start))
}
if(updateFight.map != null) {
if (updateFight.map != null) {
fight.map = updateFight.map
}
if(updateFight.spielmodus != null) {
if (updateFight.spielmodus != null) {
fight.spielModus = updateFight.spielmodus
}
if(updateFight.group != null) {
if(updateFight.group == "null") {
if (updateFight.spectatePort != null) {
fight.spectatePort = if (updateFight.spectatePort == 0) null else updateFight.spectatePort
}
if (updateFight.group != null) {
if (updateFight.group == "null") {
Groups.resetGroup(fightId, true)
} else {
Groups.setGroup(fightId, updateFight.group)

Datei anzeigen

@ -48,7 +48,7 @@ data class ResponseEvent(
val maxTeamMembers: Int,
val schemType: String?,
val publicSchemsOnly: Boolean,
val spectateSystem: Boolean
val referees: List<ResponseUser>,
) {
constructor(event: Event) : this(
event.eventID,
@ -59,7 +59,7 @@ data class ResponseEvent(
event.maximumTeamMembers,
event.schematicType?.toDB(),
event.publicSchemsOnly(),
event.spectateSystem()
Referee.get(event.eventID).map { ResponseUser(SteamwarUser.get(it)) }
)
}
@ -75,14 +75,15 @@ data class CreateEvent(val name: String, val start: Long, val end: Long)
@Serializable
data class UpdateEvent(
val name: String?,
val deadline: Long?,
val start: Long?,
val end: Long?,
val maxTeamMembers: Int?,
val schemType: String?,
val publicSchemsOnly: Boolean?,
val spectateSystem: Boolean?
val name: String? = null,
val deadline: Long? = null,
val start: Long? = null,
val end: Long? = null,
val maxTeamMembers: Int? = null,
val schemType: String? = null,
val publicSchemsOnly: Boolean? = null,
val addReferee: Set<Int>? = null,
val removeReferee: Set<Int>? = null,
)
fun Route.configureEventsRoute() {
@ -236,8 +237,15 @@ fun Route.configureEventsRoute() {
if (updateEvent.publicSchemsOnly != null) {
event.setPublicSchemsOnly(updateEvent.publicSchemsOnly)
}
if (updateEvent.spectateSystem != null) {
event.setSpectateSystem(updateEvent.spectateSystem)
if (updateEvent.addReferee != null) {
updateEvent.addReferee.forEach {
Referee.add(event.eventID, it)
}
}
if (updateEvent.removeReferee != null) {
updateEvent.removeReferee.forEach {
Referee.remove(event.eventID, it)
}
}
event.update()
call.respond(ResponseEvent(event))