Skip to content

Commit

Permalink
Server: Create all players as registered
Browse files Browse the repository at this point in the history
Registered players have a ranking icon next to their names in lobbies.

This also adjusts the default ranking to be 0, instead of 10000 to
display the basic ranking icon.
  • Loading branch information
StenAL committed Aug 22, 2024
1 parent 85e8fff commit a194841
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions server/src/main/java/org/moparforia/server/game/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Player {
private String avatarUrl;
private String clan;
private int accessLevel;
private int points;
private int ranking;
private boolean emailVerified;// todo or something like that maybe, find out
private boolean registered;
private boolean vip;
Expand All @@ -36,7 +36,7 @@ public class Player {
public Player(Channel channel, int id) {
this.channel = channel;
this.id = id;
points = 0;
ranking = 0;
resetVals();
}

Expand All @@ -52,7 +52,7 @@ public void resetVals() {
avatarUrl = "-";
clan = "-";
accessLevel = ACCESSLEVEL_NORMAL;
points = 10000;
ranking = 0;
emailVerified = false;
registered = false;
vip = false;
Expand Down Expand Up @@ -132,12 +132,12 @@ public void setAccessLevel(int whatsyourgame) {
this.accessLevel = whatsyourgame;
}

public int getPoints() {
return points;
public int getRanking() {
return ranking;
}

public void setPoints(int points) {
this.points = points;
public void setRanking(int ranking) {
this.ranking = ranking;
}

public boolean isEmailVerified() {
Expand Down Expand Up @@ -216,15 +216,15 @@ public boolean equals(Object o) {
if (o == null || !(o instanceof Player))
return false;
Player p = (Player) o;
return nick.equals(p.nick) && points == p.points && locale.equals(p.locale);
return nick.equals(p.nick) && ranking == p.ranking && locale.equals(p.locale);
}

public String toString() {
String tmp = (registered ? "r" : "") + (vip ? "v" : "") + (sheriff ? "s" : "") + (notAcceptingChallenges ? "n" : "");
return Tools.triangelize(
"3:" + (nick != null ? nick : ""),
tmp.equals("") ? "w" : tmp,
points,
ranking,
locale != null ? locale : "",
profileUrl != null ? profileUrl : "",
avatarUrl != null ? avatarUrl : ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public boolean handle(Server server, Packet packet, Matcher message) {
Player player = packet.getChannel().attr(Player.PLAYER_ATTRIBUTE_KEY).get();
player.setNick(username);
player.setEmailVerified(true);
player.setRegistered(!anonym);
player.setRegistered(true);
packet.getChannel().writeAndFlush(new Packet(PacketType.DATA, Tools.tabularize("basicinfo", player.isEmailVerified(), player.getAccessLevel(), "t", "f")));
packet.getChannel().writeAndFlush(new Packet(PacketType.DATA, Tools.tabularize("status", "lobbyselect", 300)));
return true;
Expand Down
4 changes: 2 additions & 2 deletions server/src/test/java/org/moparforia/server/ServerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void testSinglePlayerFlow() throws IOException, InterruptedException {
String lobbyOwnjoin = reader.readLine();
assertEquals("d 4 status\tlobby\t1", statusLobby);
assertEquals("d 5 lobby\tusers", lobbyUsers);
assertEquals("d 6 lobby\townjoin\t3:" + nickname + "^w^10000^-^-^-", lobbyOwnjoin);
assertEquals("d 6 lobby\townjoin\t3:" + nickname + "^r^0^-^-^-", lobbyOwnjoin);
this.sendMessage(writer, "d 4 lobby\ttracksetlist");
String tracksetlist = reader.readLine();
assertEquals(tracksetlist, "d 7 lobby\ttracksetlist\tBirchwood\t1\t9\tNo one\t1\tNo one\t1\tNo one\t1\tNo one\t1\tOak Park\t1\t18\tNo one\t1\tNo one\t1\tNo one\t1\tNo one\t1\tOne by One\t2\t18\tNo one\t1\tNo one\t1\tNo one\t1\tNo one\t1\tScary Set\t3\t9\tNo one\t1\tNo one\t1\tNo one\t1\tNo one\t1\tSpruce Corpse\t2\t9\tNo one\t1\tNo one\t1\tNo one\t1\tNo one\t1\tThe First\t2\t18\tNo one\t1\tNo one\t1\tNo one\t1\tNo one\t1\tTorment Fields\t3\t18\tNo one\t1\tNo one\t1\tNo one\t1\tNo one\t1");
Expand Down Expand Up @@ -108,7 +108,7 @@ void testSinglePlayerFlow() throws IOException, InterruptedException {
lobbyOwnjoin = reader.readLine();
assertEquals("d 16 status\tlobby\t1", statusLobby);
assertEquals("d 17 lobby\tusers", lobbyUsers);
assertEquals("d 18 lobby\townjoin\t3:" + nickname + "^w^10000^-^-^-", lobbyOwnjoin);
assertEquals("d 18 lobby\townjoin\t3:" + nickname + "^r^0^-^-^-", lobbyOwnjoin);

// quit game
this.sendMessage(writer, "d 7 lobby\tquit");
Expand Down

0 comments on commit a194841

Please sign in to comment.