Add Replay WIPISCH #334
@ -11,7 +11,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Fight {
|
||||
|
||||
private static final Statement getPage = new Statement("SELECT f.FightID, f.GameMode, f.Server, f.StartTime, f.BlueLeader, f.RedLeader, (b.NodeId IS NULL OR b.AllowReplay) AND (r.NodeId IS NULL OR r.AllowReplay) AS ReplayAllowed, f.Win FROM Fight f LEFT OUTER JOIN SchematicNode b ON f.BlueSchem = b.NodeId LEFT OUTER JOIN SchematicNode r ON f.RedSchem = r.NodeId ORDER BY FightID DESC LIMIT ?, ?");
|
||||
private static final Statement getPage = new Statement("SELECT f.FightID, f.GameMode, f.Server, f.StartTime, f.BlueLeader, f.RedLeader, (b.NodeId IS NULL OR b.AllowReplay) AND (r.NodeId IS NULL OR r.AllowReplay) AS ReplayAllowed, f.Win, (SELECT COUNT(1) FROM Replay WHERE Replay.FightID = f.FightID) as ReplayAvailable FROM Fight f LEFT OUTER JOIN SchematicNode b ON f.BlueSchem = b.NodeId LEFT OUTER JOIN SchematicNode r ON f.RedSchem = r.NodeId ORDER BY FightID DESC LIMIT ?, ?");
|
||||
|
||||
private final int fightID;
|
||||
private final String gameMode;
|
||||
@ -23,6 +23,7 @@ public class Fight {
|
||||
private final int win;
|
||||
|
||||
private final boolean replayAllowed;
|
||||
private final boolean replayAvailable;
|
||||
|
||||
private final List<FightPlayer> bluePlayers = new ArrayList<>();
|
||||
private final List<FightPlayer> redPlayers = new ArrayList<>();
|
||||
@ -35,6 +36,7 @@ public class Fight {
|
||||
blueLeader = rs.getInt("BlueLeader");
|
||||
redLeader = rs.getInt("RedLeader");
|
||||
replayAllowed = rs.getBoolean("ReplayAllowed");
|
||||
replayAvailable = rs.getBoolean("ReplayAvailable");
|
||||
win = rs.getInt("Win");
|
||||
}
|
||||
|
||||
@ -116,6 +118,6 @@ public class Fight {
|
||||
}
|
||||
|
||||
|
||||
public boolean replayExists() {
|
||||
return getGameMode() != null && Replay.hasReplay(fightID);
|
||||
return getGameMode() != null && replayAvailable;
|
||||
}
|
||||
}
|
||||
|
@ -1,31 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.sql;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
|
||||
public class Replay {
|
||||
|
||||
private static final Statement hasReplay = new Statement("SELECT 1 FROM Replay WHERE FightID = ?");
|
||||
|
||||
public static boolean hasReplay(int id) {
|
||||
return hasReplay.select(ResultSet::next, id);
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren
Das würde ich unbedingt ins SQL-Statement mit einbauen, da wir im SQL-Statement ja gleich 45 Replays auf einmal holen. Wenn du immer einzeln auf das Replay prüfst, erhöhst du die SQL-Abfragenmenge auf 48 (von 3). Das dürfte wahrscheinlich (vor allem weil davon 45 auf der dicken Replay-Tabelle stattfinden) sehr langsam werden.