Skip to content

Commit

Permalink
remove old achievement update code
Browse files Browse the repository at this point in the history
  • Loading branch information
alyssaruth committed Oct 30, 2024
1 parent 69671ca commit 8239063
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 75 deletions.
1 change: 0 additions & 1 deletion client/src/main/java/online/screen/EntropyLobby.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
28 changes: 0 additions & 28 deletions client/src/main/java/online/util/XmlBuilderDesktop.java

This file was deleted.

2 changes: 0 additions & 2 deletions client/src/main/java/screen/MainScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion core/src/main/java/util/XmlConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
6 changes: 0 additions & 6 deletions server/src/main/java/server/MessageHandlerRunnable.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
38 changes: 1 addition & 37 deletions server/src/main/java/util/XmlBuilderServer.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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<Room> rooms = server.getRooms();
int size = rooms.size();
for (int i=0; i<size; i++)
{
Room room = rooms.get(i);
List<String> players = room.getCurrentPlayers();
if (players.contains(username))
{
OnlineMessage om = new OnlineMessage("black", message, "Game");
room.addToChatHistoryAndNotifyUsers(om);
}
}
}

return ACKNOWLEDGEMENT;
}


public static Document getLeaderboardResponse(List<Room> rooms) throws Throwable
{
Document response = XmlUtil.factoryNewDocument();
Expand Down

0 comments on commit 8239063

Please sign in to comment.