From 8239063a327cf45b68a8bfb9119b4c12aa5ac4d9 Mon Sep 17 00:00:00 2001 From: alyssa Date: Wed, 30 Oct 2024 08:56:52 +0000 Subject: [PATCH] remove old achievement update code --- .../main/java/online/screen/EntropyLobby.java | 1 - .../java/online/util/XmlBuilderDesktop.java | 28 -------------- client/src/main/java/screen/MainScreen.java | 2 - core/src/main/java/util/XmlConstants.java | 1 - .../java/server/MessageHandlerRunnable.java | 6 --- .../src/main/java/util/XmlBuilderServer.java | 38 +------------------ 6 files changed, 1 insertion(+), 75 deletions(-) delete mode 100644 client/src/main/java/online/util/XmlBuilderDesktop.java diff --git a/client/src/main/java/online/screen/EntropyLobby.java b/client/src/main/java/online/screen/EntropyLobby.java index 3525a71..5937e6c 100644 --- a/client/src/main/java/online/screen/EntropyLobby.java +++ b/client/src/main/java/online/screen/EntropyLobby.java @@ -7,7 +7,6 @@ import object.RoomTable; import online.util.HeartbeatRunnable; import online.util.XmlBuilderClient; -import online.util.XmlBuilderDesktop; import org.w3c.dom.Document; import screen.MainScreen; import screen.ScreenCache; diff --git a/client/src/main/java/online/util/XmlBuilderDesktop.java b/client/src/main/java/online/util/XmlBuilderDesktop.java deleted file mode 100644 index 625f376..0000000 --- a/client/src/main/java/online/util/XmlBuilderDesktop.java +++ /dev/null @@ -1,28 +0,0 @@ -package online.util; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import util.XmlConstants; -import util.XmlUtil; - -/** - * Methods for building XML messages that are only sent by the desktop application - */ -public class XmlBuilderDesktop implements XmlConstants -{ - public static Document factoryAchievementsUpdate(String username, String achievementName, int achievementCount) - { - Document document = XmlUtil.factoryNewDocument(); - Element rootElement = document.createElement(ROOT_TAG_ACHIEVEMENTS_UPDATE); - rootElement.setAttribute("Username", username); - rootElement.setAttribute("AchievementCount", "" + achievementCount); - if (achievementName != null) - { - rootElement.setAttribute("AchievementName", achievementName); - } - - document.appendChild(rootElement); - return document; - } -} diff --git a/client/src/main/java/screen/MainScreen.java b/client/src/main/java/screen/MainScreen.java index b4c55af..8fdef96 100644 --- a/client/src/main/java/screen/MainScreen.java +++ b/client/src/main/java/screen/MainScreen.java @@ -9,8 +9,6 @@ import object.Player; import online.screen.EntropyLobby; import online.screen.TestHarness; -import online.util.XmlBuilderDesktop; -import org.w3c.dom.Document; import util.*; import utils.Achievement; diff --git a/core/src/main/java/util/XmlConstants.java b/core/src/main/java/util/XmlConstants.java index f90b8f8..074eeca 100644 --- a/core/src/main/java/util/XmlConstants.java +++ b/core/src/main/java/util/XmlConstants.java @@ -8,7 +8,6 @@ public interface XmlConstants //Client public static final String ROOT_TAG_HEARTBEAT = "Heartbeat"; public static final String ROOT_TAG_DISCONNECT_REQUEST = "DisconnectRequest"; - public static final String ROOT_TAG_ACHIEVEMENTS_UPDATE = "AchievementsUpdate"; public static final String ROOT_TAG_NEW_CHAT = "NewChat"; public static final String ROOT_TAG_ROOM_JOIN_REQUEST = "RoomJoinRequest"; public static final String ROOT_TAG_CLOSE_ROOM_REQUEST = "CloseRoomRequest"; diff --git a/server/src/main/java/server/MessageHandlerRunnable.java b/server/src/main/java/server/MessageHandlerRunnable.java index e881160..b446c98 100644 --- a/server/src/main/java/server/MessageHandlerRunnable.java +++ b/server/src/main/java/server/MessageHandlerRunnable.java @@ -230,12 +230,6 @@ private Document getResponseForMessage() throws Throwable server.removeFromUsersOnline(usc); return null; } - else if (name.equals(ROOT_TAG_ACHIEVEMENTS_UPDATE)) - { - int achievementCount = XmlUtil.getAttributeInt(root, "AchievementCount"); - String achievementName = root.getAttribute("AchievementName"); - return XmlBuilderServer.getAchievementUpdateAck(server, username, achievementName, achievementCount); - } else if (name.equals(ROOT_TAG_NEW_CHAT)) { String newMessage = root.getAttribute("MessageText"); diff --git a/server/src/main/java/util/XmlBuilderServer.java b/server/src/main/java/util/XmlBuilderServer.java index 28d5a19..3321c3e 100644 --- a/server/src/main/java/util/XmlBuilderServer.java +++ b/server/src/main/java/util/XmlBuilderServer.java @@ -1,12 +1,10 @@ package util; -import auth.UserConnection; import object.*; import org.w3c.dom.Document; import org.w3c.dom.Element; import server.EntropyServer; -import java.util.ArrayList; import java.util.List; public class XmlBuilderServer implements XmlConstants @@ -39,41 +37,7 @@ public static Document getAcknowledgement() { return ACKNOWLEDGEMENT; } - - public static Document getAchievementUpdateAck(EntropyServer server, String username, String achievementName, int newCount) - { - if (newCount < 0) - { - return getKickOffResponse(username, "Achievement count could not be parsed."); - } - - if (newCount > ACHIEVMENTS_TOTAL) - { - return getKickOffResponse(username, "Nice try."); - } - - //Now loop through rooms where the player is actively playing and add a chat message - if (!achievementName.isEmpty()) - { - String message = username + " just earned " + achievementName + "!"; - - ArrayList rooms = server.getRooms(); - int size = rooms.size(); - for (int i=0; i players = room.getCurrentPlayers(); - if (players.contains(username)) - { - OnlineMessage om = new OnlineMessage("black", message, "Game"); - room.addToChatHistoryAndNotifyUsers(om); - } - } - } - - return ACKNOWLEDGEMENT; - } - + public static Document getLeaderboardResponse(List rooms) throws Throwable { Document response = XmlUtil.factoryNewDocument();