forked from SteamWar/SteamWar
Refactor event handling and group assignment logic
Replaced `fight.event` with `event.eventID` for consistency and improved event handling. Adjusted `setGroup` to accept `Integer` instead of `EventGroup` to simplify group assignment logic. Removed unused `event` field in `CreateEventFight` and streamlined related processing.
This commit is contained in:
@@ -153,9 +153,9 @@ public class EventFight implements Comparable<EventFight> {
|
|||||||
setFight.update(fight, fightID);
|
setFight.update(fight, fightID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGroup(EventGroup group) {
|
public void setGroup(Integer group) {
|
||||||
setGroup.update(group.getId(), fightID);
|
setGroup.update(group, fightID);
|
||||||
this.groupId = group.getId();
|
this.groupId = group;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasFinished() {
|
public boolean hasFinished() {
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ data class UpdateEventFight(
|
|||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class CreateEventFight(
|
data class CreateEventFight(
|
||||||
val event: Int,
|
|
||||||
val spielmodus: String,
|
val spielmodus: String,
|
||||||
val map: String,
|
val map: String,
|
||||||
val blueTeam: Int,
|
val blueTeam: Int,
|
||||||
@@ -91,6 +90,8 @@ fun Route.configureEventFightRoutes() {
|
|||||||
call.respond(EventFight.getEvent(event.eventID).map { ResponseEventFight(it) })
|
call.respond(EventFight.getEvent(event.eventID).map { ResponseEventFight(it) })
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
|
val event = call.receiveEvent() ?: return@post
|
||||||
|
|
||||||
val fight = call.receiveNullable<CreateEventFight>()
|
val fight = call.receiveNullable<CreateEventFight>()
|
||||||
if (fight == null) {
|
if (fight == null) {
|
||||||
call.respond(HttpStatusCode.BadRequest, ResponseError("Invalid body"))
|
call.respond(HttpStatusCode.BadRequest, ResponseError("Invalid body"))
|
||||||
@@ -98,7 +99,7 @@ fun Route.configureEventFightRoutes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val eventFight = EventFight.create(
|
val eventFight = EventFight.create(
|
||||||
fight.event,
|
event.eventID,
|
||||||
Timestamp.from(Instant.ofEpochMilli(fight.start)),
|
Timestamp.from(Instant.ofEpochMilli(fight.start)),
|
||||||
fight.spielmodus,
|
fight.spielmodus,
|
||||||
fight.map,
|
fight.map,
|
||||||
@@ -129,9 +130,9 @@ fun Route.configureEventFightRoutes() {
|
|||||||
|
|
||||||
if (updateFight.group != null) {
|
if (updateFight.group != null) {
|
||||||
if (updateFight.group == -1) {
|
if (updateFight.group == -1) {
|
||||||
fight.groupId = null
|
fight.setGroup(null)
|
||||||
} else {
|
} else {
|
||||||
fight.groupId = updateFight.group
|
fight.setGroup(updateFight.group)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user