From 27619f484f1bce411fcd27e2fecd07f1f4c7d4a1 Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Sat, 3 Dec 2022 15:46:40 -0300 Subject: [PATCH] Fix WiredGame --- .../habbohotel/games/wired/WiredGame.java | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java b/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java index 80fe874d..f17de53a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java @@ -3,7 +3,10 @@ package com.eu.habbo.habbohotel.games.wired; import com.eu.habbo.habbohotel.games.*; import com.eu.habbo.habbohotel.games.freeze.FreezeGame; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboGender; +import com.eu.habbo.habbohotel.users.HabboItem; public class WiredGame extends Game { public GameState state = GameState.RUNNING; @@ -28,14 +31,42 @@ public class WiredGame extends Game { @Override public boolean addHabbo(Habbo habbo, GameTeamColors teamColor) { - this.room.giveEffect(habbo, FreezeGame.effectId + teamColor.type, -1); + RoomUnit roomUnit = habbo.getRoomUnit(); + if (roomUnit.getEffectId() > 0) + roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp()); + this.room.giveEffect(habbo, FreezeGame.effectId + teamColor.type, -1, true); return super.addHabbo(habbo, teamColor); } @Override public void removeHabbo(Habbo habbo) { super.removeHabbo(habbo); - this.room.giveEffect(habbo, 0, -1); + RoomUnit roomUnit = habbo.getRoomUnit(); + Room room = this.room; + if (room == null) return; + + HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().x, roomUnit.getCurrentLocation().y); + int nextEffectM = 0; + int nextEffectF = 0; + int nextEffectDuration = -1; + + if (topItem != null) { + nextEffectM = topItem.getBaseItem().getEffectM(); + nextEffectF = topItem.getBaseItem().getEffectF(); + } else if (roomUnit.getPreviousEffectId() > 0) { + nextEffectF = roomUnit.getPreviousEffectId(); + nextEffectM = roomUnit.getPreviousEffectId(); + nextEffectDuration = roomUnit.getPreviousEffectEndTimestamp(); + } + + if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) { + room.giveEffect(habbo, nextEffectM, nextEffectDuration, true); + return; + } + + if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) { + room.giveEffect(habbo, nextEffectF, nextEffectDuration, true); + } } @Override