diff --git a/src/main/java/com/eu/habbo/habbohotel/games/Game.java b/src/main/java/com/eu/habbo/habbohotel/games/Game.java index 0219d770..b4286562 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/Game.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/Game.java @@ -47,6 +47,8 @@ public abstract class Game implements Runnable protected int endTime; + public boolean isRunning; + public GameState state = GameState.IDLE; @@ -149,6 +151,7 @@ public abstract class Game implements Runnable public void start() { + this.isRunning = false; this.state = GameState.RUNNING; this.startTime = Emulator.getIntUnixTimestamp(); diff --git a/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java b/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java index 6ce94dd4..b1e65111 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java @@ -31,11 +31,13 @@ public class GamePlayer public synchronized void addScore(int amount) { - this.score += amount; - WiredHandler.handle(WiredTriggerType.SCORE_ACHIEVED, null, this.habbo.getHabboInfo().getCurrentRoom(), new Object[]{this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo).getTotalScore(), amount}); + if (habbo.getHabboInfo().getGamePlayer() != null || this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo) != null){ + if (habbo.getHabboInfo().getGamePlayer() != null && this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo) != null) { + this.score += amount; + WiredHandler.handle(WiredTriggerType.SCORE_ACHIEVED, this.habbo.getRoomUnit(), this.habbo.getHabboInfo().getCurrentRoom(), new Object[]{this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo).getTotalScore(), amount});} + } } - public Habbo getHabbo() { return this.habbo; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java index 68cb43ea..e6dfd61e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java @@ -16,7 +16,7 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionGameTimer extends HabboItem +public abstract class InteractionGameTimer extends HabboItem { private int baseTime = 0; private int lastToggle = 0; @@ -103,8 +103,10 @@ public class InteractionGameTimer extends HabboItem if ((objects.length >= 2 && objects[1] instanceof WiredEffectType)) { - if (game.state.equals(GameState.RUNNING)) - return; + if (game == null || !game.isRunning) + startGame(room); + else if (game.isRunning) + stopGame(room); } if(objects.length >= 1 && objects[0] instanceof Integer && client != null) @@ -210,7 +212,9 @@ public class InteractionGameTimer extends HabboItem if(game != null && game.state != GameState.IDLE) { + this.setExtradata(this.baseTime + ""); game.stop(); + stopGame(room); } room.updateItem(this); @@ -254,10 +258,7 @@ public class InteractionGameTimer extends HabboItem return this.getExtradata() + "\t" + this.baseTime; } - public Class getGameType() - { - return WiredGame.class; - } + public abstract Class getGameType(); @Override public boolean allowWiredResetState() diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java index 257202a5..695f95e9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java @@ -4,6 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTile; +import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeTile; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; @@ -159,14 +161,21 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect } } + boolean validMove = true; RoomTile newTile = room.getLayout().getTile((short) (item.getX() + x), (short) (item.getY() + y)); - - if (newTile != null && ((newTile.state == RoomTileState.OPEN && newTile.isWalkable()) || newTile.state == RoomTileState.BLOCKED && room.getTopItemAt(newTile.x, newTile.y) == item) && room.furnitureFitsAt(newTile, item, item.getRotation()) == FurnitureMovementError.NONE) - { - if (room.getLayout().tileExists(newTile.x, newTile.y)) - { - room.slideFurniTo(item, newTile, item.getRotation()); + if(room.getLayout().getTilesAt(newTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()) == null) { + validMove = false; + } + for(RoomTile t : room.getLayout().getTilesAt(newTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())) { + if ((item instanceof InteractionFreezeTile || item instanceof InteractionBattleBanzaiTile) && room.hasItemsAt(t.x, t.y)) { + validMove = false; } + if (t == null || (t.state == RoomTileState.OPEN && !t.isWalkable()) || t.state == RoomTileState.BLOCKED || t.state == RoomTileState.INVALID || !room.furnitureFitsAt(t, item, item.getRotation()).equals(FurnitureMovementError.NONE) || !room.getLayout().tileExists(t.x, t.y)) { + validMove = false; + } + } + if(validMove) { + room.slideFurniTo(item, newTile, item.getRotation()); } } @@ -283,4 +292,4 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { return 495; } -} +} \ No newline at end of file