forked from SteamWar/SteamWar
Refactor event handling and tie-break logic implementation
Introduced new methods and structures in EventGroup, EventRelation, and EventFight to streamline point calculations, tie-break detection, and dependency resolution. Improved modularity by adding methods like getLastFight, needsTieBreak, and getDependents while optimizing the event result setting process. This refactor enhances clarity, reduces redundancy, and supports better maintainability of event-related logic.
This commit is contained in:
+14
-3
@@ -33,6 +33,8 @@ import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||
import de.steamwar.fightsystem.winconditions.Wincondition;
|
||||
import de.steamwar.network.NetworkSender;
|
||||
import de.steamwar.network.packets.common.FightEndsPacket;
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.sql.EventRelation;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import lombok.Getter;
|
||||
@@ -70,12 +72,21 @@ public class FightStatistics {
|
||||
}
|
||||
|
||||
private void setEventResult() {
|
||||
if (FightSystem.getLastWinner() == null)
|
||||
if (FightSystem.getLastWinner() == null) {
|
||||
Config.EventKampf.setErgebnis(0);
|
||||
else if (FightSystem.getLastWinner().isBlue())
|
||||
} else if (FightSystem.getLastWinner().isBlue()) {
|
||||
Config.EventKampf.setErgebnis(1);
|
||||
else
|
||||
} else {
|
||||
Config.EventKampf.setErgebnis(2);
|
||||
}
|
||||
|
||||
Config.EventKampf.getDependents().forEach(EventRelation::apply);
|
||||
|
||||
Config.EventKampf.getGroup().ifPresent(group -> {
|
||||
if (group.getLastFight().map(EventFight::getFightID).orElse(-1) == Config.EventKampf.getFightID() && !group.needsTieBreak()) {
|
||||
group.getDependents().forEach(EventRelation::apply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void disable() {
|
||||
|
||||
Reference in New Issue
Block a user