SteamWar/SpigotCore
Archiviert
13
0

Merge pull request 'Add ranked rework' (#181) from Ranked into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Reviewed-on: #181
Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Lixfel 2022-03-10 12:07:07 +01:00
Commit d3385f5197
6 geänderte Dateien mit 74 neuen und 59 gelöschten Zeilen

Datei anzeigen

@ -35,4 +35,5 @@ public class PacketIdManager {
//0x2(X) Server Information System //0x2(X) Server Information System
public static final byte I_AM_A_LOBBY = 0x20; public static final byte I_AM_A_LOBBY = 0x20;
public static final byte FIGHT_INFO = 0x21; public static final byte FIGHT_INFO = 0x21;
public static final byte FIGHT_ENDS = 0x22;
} }

Datei anzeigen

@ -0,0 +1,73 @@
/*
* 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.comms.packets;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import de.steamwar.comms.PacketIdManager;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.List;
@AllArgsConstructor
@Getter
public class FightEndsPacket extends SpigotPacket {
private byte win;
private int blueSchem;
private int redSchem;
private List<Integer> bluePlayers;
private List<Integer> redPlayers;
public FightEndsPacket(ByteArrayDataInput byteArrayDataInput) {
win = byteArrayDataInput.readByte();
blueSchem = byteArrayDataInput.readInt();
redSchem = byteArrayDataInput.readInt();
int blueSize = byteArrayDataInput.readInt();
for (int i = 0; i < blueSize; i++) {
bluePlayers.add(byteArrayDataInput.readInt());
}
int redSize = byteArrayDataInput.readInt();
for (int i = 0; i < redSize; i++) {
redPlayers.add(byteArrayDataInput.readInt());
}
}
@Override
public int getName() {
return PacketIdManager.FIGHT_ENDS;
}
@Override
public void writeVars(ByteArrayDataOutput byteArrayDataOutput) {
byteArrayDataOutput.writeByte(win);
byteArrayDataOutput.writeInt(blueSchem);
byteArrayDataOutput.writeInt(redSchem);
byteArrayDataOutput.writeInt(bluePlayers.size());
for (int i : bluePlayers) {
byteArrayDataOutput.writeInt(i);
}
byteArrayDataOutput.writeInt(redPlayers.size());
for (int i : redPlayers) {
byteArrayDataOutput.writeInt(i);
}
}
}

Datei anzeigen

@ -1,32 +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.sql;
public class Elo {
private Elo(){}
public static int getElo(int userId, String gameMode){
return Provider.impl.getElo(userId, gameMode);
}
public static void setElo(int userId, String gameMode, int elo){
Provider.impl.setElo(userId, gameMode, elo);
}
}

Datei anzeigen

@ -39,9 +39,6 @@ public interface Provider {
List<CheckedSchematic> getLastDeclinedOfNode(int node); List<CheckedSchematic> getLastDeclinedOfNode(int node);
List<CheckedSchematic> getLastDelined(int schemOwner); List<CheckedSchematic> getLastDelined(int schemOwner);
int getElo(int userId, String gameMode);
void setElo(int userId, String gameMode, int elo);
Event getEvent(int eventID); Event getEvent(int eventID);
EventFight getEventFight(int fightID); EventFight getEventFight(int fightID);
void setEventFightResult(EventFight fight, int winner); void setEventFightResult(EventFight fight, int winner);

Datei anzeigen

@ -78,22 +78,6 @@ public class SQLProvider implements Provider {
return new CheckedSchematic(rs.getInt("NodeId"), rs.getInt("Validator"), rs.getTimestamp("StartTime"), rs.getTimestamp("EndTime"), rs.getString("DeclineReason")); return new CheckedSchematic(rs.getInt("NodeId"), rs.getInt("Validator"), rs.getTimestamp("StartTime"), rs.getTimestamp("EndTime"), rs.getString("DeclineReason"));
} }
private static final Statement getElo = new Statement("SELECT Elo FROM Elo WHERE UserID = ? AND GameMode = ?");
@Override
public int getElo(int userId, String gameMode) {
return getElo.select(rs -> {
if(rs.next())
return rs.getInt("Elo");
return 1000;
}, userId, gameMode);
}
private static final Statement setElo = new Statement("INSERT INTO Elo (UserID, GameMode, Elo) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE Elo = VALUES(Elo)");
@Override
public void setElo(int userId, String gameMode, int elo) {
setElo.update(userId, gameMode, elo);
}
private static final Statement getEvent = new Statement("SELECT * FROM Event WHERE EventID = ?"); private static final Statement getEvent = new Statement("SELECT * FROM Event WHERE EventID = ?");
@Override @Override
public Event getEvent(int eventID) { public Event getEvent(int eventID) {

Datei anzeigen

@ -64,14 +64,6 @@ public class StandaloneProvider implements Provider {
return new ArrayList<>(); return new ArrayList<>();
} }
@Override
public int getElo(int userId, String gameMode) {
return 1000;
}
@Override
public void setElo(int userId, String gameMode, int elo) {}
@Override @Override
public Event getEvent(int eventID) { public Event getEvent(int eventID) {
return new Event(eventID, "DummyEvent", Timestamp.from(Instant.now()), Timestamp.from(Instant.now()), 6, false, false); return new Event(eventID, "DummyEvent", Timestamp.from(Instant.now()), Timestamp.from(Instant.now()), 6, false, false);