mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-30 01:50:50 +01:00
Merge branch '27-games' into 'dev'
Resolve "Games" See merge request morningstar/Arcturus-Community!7
This commit is contained in:
commit
7e6a63bc38
@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.games;
|
|||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredHighscore;
|
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredHighscore;
|
||||||
|
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob;
|
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerTeamLoses;
|
import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerTeamLoses;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerTeamWins;
|
import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerTeamWins;
|
||||||
@ -24,28 +25,19 @@ import java.util.Map;
|
|||||||
public abstract class Game implements Runnable
|
public abstract class Game implements Runnable
|
||||||
{
|
{
|
||||||
|
|
||||||
public final Class<? extends GameTeam> gameTeamClazz;
|
private final Class<? extends GameTeam> gameTeamClazz;
|
||||||
|
|
||||||
|
|
||||||
public final Class<? extends GamePlayer> gamePlayerClazz;
|
|
||||||
|
|
||||||
|
private final Class<? extends GamePlayer> gamePlayerClazz;
|
||||||
|
|
||||||
protected final THashMap<GameTeamColors, GameTeam> teams = new THashMap<>();
|
protected final THashMap<GameTeamColors, GameTeam> teams = new THashMap<>();
|
||||||
|
|
||||||
|
|
||||||
protected final Room room;
|
protected final Room room;
|
||||||
|
|
||||||
|
private final boolean countsAchievements;
|
||||||
|
|
||||||
protected final boolean countsAchievements;
|
private int startTime;
|
||||||
|
|
||||||
|
private int endTime;
|
||||||
protected int startTime;
|
|
||||||
|
|
||||||
|
|
||||||
protected int pauseTime;
|
|
||||||
|
|
||||||
|
|
||||||
protected int endTime;
|
|
||||||
|
|
||||||
public boolean isRunning;
|
public boolean isRunning;
|
||||||
|
|
||||||
@ -132,6 +124,7 @@ public abstract class Game implements Runnable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
boolean deleteGame = true;
|
boolean deleteGame = true;
|
||||||
for (GameTeam team : this.teams.values())
|
for (GameTeam team : this.teams.values())
|
||||||
{
|
{
|
||||||
@ -146,6 +139,7 @@ public abstract class Game implements Runnable
|
|||||||
{
|
{
|
||||||
this.room.deleteGame(this);
|
this.room.deleteGame(this);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -170,30 +164,7 @@ public abstract class Game implements Runnable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onEnd() {
|
||||||
public abstract void run();
|
|
||||||
|
|
||||||
public void pause()
|
|
||||||
{
|
|
||||||
if (this.state.equals(GameState.RUNNING))
|
|
||||||
{
|
|
||||||
this.state = GameState.PAUSED;
|
|
||||||
this.pauseTime = Emulator.getIntUnixTimestamp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void unpause()
|
|
||||||
{
|
|
||||||
if (this.state.equals(GameState.PAUSED))
|
|
||||||
{
|
|
||||||
this.state = GameState.RUNNING;
|
|
||||||
this.endTime = Emulator.getIntUnixTimestamp() + (this.endTime - this.pauseTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stop()
|
|
||||||
{
|
|
||||||
this.state = GameState.IDLE;
|
|
||||||
this.endTime = Emulator.getIntUnixTimestamp();
|
this.endTime = Emulator.getIntUnixTimestamp();
|
||||||
|
|
||||||
this.saveScores();
|
this.saveScores();
|
||||||
@ -225,18 +196,52 @@ public abstract class Game implements Runnable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class))
|
||||||
|
{
|
||||||
|
this.room.updateItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void run();
|
||||||
|
|
||||||
|
public void pause()
|
||||||
|
{
|
||||||
|
if (this.state.equals(GameState.RUNNING))
|
||||||
|
{
|
||||||
|
this.state = GameState.PAUSED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unpause()
|
||||||
|
{
|
||||||
|
if (this.state.equals(GameState.PAUSED))
|
||||||
|
{
|
||||||
|
this.state = GameState.RUNNING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stop()
|
||||||
|
{
|
||||||
|
this.state = GameState.IDLE;
|
||||||
|
|
||||||
|
boolean gamesActive = false;
|
||||||
|
for(HabboItem timer : room.getFloorItems())
|
||||||
|
{
|
||||||
|
if(timer instanceof InteractionGameTimer) {
|
||||||
|
if(((InteractionGameTimer) timer).isRunning())
|
||||||
|
gamesActive = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(gamesActive) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(Emulator.getPluginManager().isRegistered(GameStoppedEvent.class, true))
|
if(Emulator.getPluginManager().isRegistered(GameStoppedEvent.class, true))
|
||||||
{
|
{
|
||||||
Event gameStoppedEvent = new GameStoppedEvent(this);
|
Event gameStoppedEvent = new GameStoppedEvent(this);
|
||||||
Emulator.getPluginManager().fireEvent(gameStoppedEvent);
|
Emulator.getPluginManager().fireEvent(gameStoppedEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, this.room, new Object[]{this});
|
|
||||||
|
|
||||||
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class))
|
|
||||||
{
|
|
||||||
this.room.updateItem(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -289,27 +294,33 @@ public abstract class Game implements Runnable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Room getRoom()
|
public Room getRoom()
|
||||||
{
|
{
|
||||||
return this.room;
|
return this.room;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getStartTime()
|
public int getStartTime()
|
||||||
{
|
{
|
||||||
return this.startTime;
|
return this.startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Class<? extends GameTeam> getGameTeamClass() {
|
||||||
public int getEndTime()
|
return gameTeamClazz;
|
||||||
{
|
|
||||||
return this.endTime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Class<? extends GamePlayer> getGamePlayerClass() {
|
||||||
|
return gamePlayerClazz;
|
||||||
|
}
|
||||||
|
|
||||||
public void addTime(int time)
|
public THashMap<GameTeamColors, GameTeam> getTeams() {
|
||||||
{
|
return teams;
|
||||||
this.endTime += time;
|
}
|
||||||
|
|
||||||
|
public boolean isCountsAchievements() {
|
||||||
|
return countsAchievements;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameState getState() {
|
||||||
|
return state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.games.battlebanzai;
|
|||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
||||||
import com.eu.habbo.habbohotel.games.*;
|
import com.eu.habbo.habbohotel.games.*;
|
||||||
|
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiSphere;
|
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiSphere;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTile;
|
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTile;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTimer;
|
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTimer;
|
||||||
@ -13,6 +14,8 @@ import com.eu.habbo.habbohotel.rooms.RoomTile;
|
|||||||
import com.eu.habbo.habbohotel.rooms.RoomUserAction;
|
import com.eu.habbo.habbohotel.rooms.RoomUserAction;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserActionComposer;
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserActionComposer;
|
||||||
import com.eu.habbo.threading.runnables.BattleBanzaiTilesFlicker;
|
import com.eu.habbo.threading.runnables.BattleBanzaiTilesFlicker;
|
||||||
import gnu.trove.map.hash.THashMap;
|
import gnu.trove.map.hash.THashMap;
|
||||||
@ -35,8 +38,6 @@ public class BattleBanzaiGame extends Game
|
|||||||
|
|
||||||
public static final int POINTS_LOCK_TILE = Emulator.getConfig().getInt("hotel.banzai.points.tile.lock");
|
public static final int POINTS_LOCK_TILE = Emulator.getConfig().getInt("hotel.banzai.points.tile.lock");
|
||||||
|
|
||||||
private int timeLeft;
|
|
||||||
|
|
||||||
private int tileCount;
|
private int tileCount;
|
||||||
|
|
||||||
private int countDown;
|
private int countDown;
|
||||||
@ -62,22 +63,10 @@ public class BattleBanzaiGame extends Game
|
|||||||
if(!this.state.equals(GameState.IDLE))
|
if(!this.state.equals(GameState.IDLE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int highestTime = 0;
|
|
||||||
this.countDown = 3;
|
this.countDown = 3;
|
||||||
|
|
||||||
this.resetMap();
|
this.resetMap();
|
||||||
|
|
||||||
for (Map.Entry<Integer, InteractionBattleBanzaiTimer> set : this.room.getRoomSpecialTypes().getBattleBanzaiTimers().entrySet())
|
|
||||||
{
|
|
||||||
if(set.getValue().getExtradata().isEmpty())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if(highestTime < Integer.valueOf(set.getValue().getExtradata()))
|
|
||||||
{
|
|
||||||
highestTime = Integer.valueOf(set.getValue().getExtradata());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized (this.teams)
|
synchronized (this.teams)
|
||||||
{
|
{
|
||||||
for (GameTeam t : this.teams.values())
|
for (GameTeam t : this.teams.values())
|
||||||
@ -92,13 +81,6 @@ public class BattleBanzaiGame extends Game
|
|||||||
this.room.updateItemState(item);
|
this.room.updateItemState(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.timeLeft = highestTime;
|
|
||||||
|
|
||||||
if (this.timeLeft == 0)
|
|
||||||
{
|
|
||||||
this.timeLeft = 30;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.start();
|
this.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,99 +132,50 @@ public class BattleBanzaiGame extends Game
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.timeLeft > 0)
|
Emulator.getThreading().run(this, 1000);
|
||||||
|
|
||||||
|
if (this.state.equals(GameState.PAUSED)) return;
|
||||||
|
|
||||||
|
int total = 0;
|
||||||
|
synchronized (this.lockedTiles)
|
||||||
{
|
{
|
||||||
Emulator.getThreading().run(this, 1000);
|
for (Map.Entry<GameTeamColors, THashSet<HabboItem>> set : this.lockedTiles.entrySet())
|
||||||
|
|
||||||
if (this.state.equals(GameState.PAUSED)) return;
|
|
||||||
|
|
||||||
this.timeLeft--;
|
|
||||||
|
|
||||||
for (Map.Entry<Integer, InteractionBattleBanzaiTimer> set : this.room.getRoomSpecialTypes().getBattleBanzaiTimers().entrySet())
|
|
||||||
{
|
{
|
||||||
set.getValue().setExtradata(this.timeLeft + "");
|
total += set.getValue().size();
|
||||||
this.room.updateItemState(set.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
int total = 0;
|
|
||||||
synchronized (this.lockedTiles)
|
|
||||||
{
|
|
||||||
for (Map.Entry<GameTeamColors, THashSet<HabboItem>> set : this.lockedTiles.entrySet())
|
|
||||||
{
|
|
||||||
total += set.getValue().size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GameTeam highestScore = null;
|
|
||||||
|
|
||||||
synchronized (this.teams)
|
|
||||||
{
|
|
||||||
for (Map.Entry<GameTeamColors, GameTeam> set : this.teams.entrySet())
|
|
||||||
{
|
|
||||||
if (highestScore == null || highestScore.getTotalScore() < set.getValue().getTotalScore())
|
|
||||||
{
|
|
||||||
highestScore = set.getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(highestScore != null)
|
|
||||||
{
|
|
||||||
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class))
|
|
||||||
{
|
|
||||||
item.setExtradata((highestScore.teamColor.type + 3) + "");
|
|
||||||
this.room.updateItemState(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(total >= this.tileCount && this.tileCount != 0)
|
|
||||||
{
|
|
||||||
this.timeLeft = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
GameTeam highestScore = null;
|
||||||
|
|
||||||
|
synchronized (this.teams)
|
||||||
{
|
{
|
||||||
|
for (Map.Entry<GameTeamColors, GameTeam> set : this.teams.entrySet())
|
||||||
GameTeam winningTeam = null;
|
|
||||||
|
|
||||||
for (GameTeam team : this.teams.values())
|
|
||||||
{
|
{
|
||||||
for(GamePlayer player : team.getMembers())
|
if (highestScore == null || highestScore.getTotalScore() < set.getValue().getTotalScore())
|
||||||
{
|
{
|
||||||
if (player.getScore() > 0)
|
highestScore = set.getValue();
|
||||||
{
|
|
||||||
AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallPlayer"));
|
|
||||||
AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallQuestCompleted"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (winningTeam == null || team.getTotalScore() > winningTeam.getTotalScore())
|
|
||||||
{
|
|
||||||
winningTeam = team;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (winningTeam != null)
|
if(highestScore != null)
|
||||||
|
{
|
||||||
|
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class))
|
||||||
{
|
{
|
||||||
for (GamePlayer player : winningTeam.getMembers())
|
item.setExtradata((highestScore.teamColor.type + 3) + "");
|
||||||
{
|
this.room.updateItemState(item);
|
||||||
if (player.getScore() > 0)
|
|
||||||
{
|
|
||||||
this.room.sendComposer(new RoomUserActionComposer(player.getHabbo().getRoomUnit(), RoomUserAction.WAVE).compose());
|
|
||||||
AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallWinner"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class))
|
|
||||||
{
|
|
||||||
item.setExtradata((7 + winningTeam.teamColor.type) + "");
|
|
||||||
this.room.updateItemState(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
Emulator.getThreading().run(new BattleBanzaiTilesFlicker(this.lockedTiles.get(winningTeam.teamColor), winningTeam.teamColor, this.room));
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.stop();
|
|
||||||
|
if(total >= this.tileCount && this.tileCount != 0)
|
||||||
|
{
|
||||||
|
for(InteractionGameTimer timer : room.getRoomSpecialTypes().getGameTimers().values())
|
||||||
|
{
|
||||||
|
if(timer.isRunning())
|
||||||
|
timer.setRunning(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
InteractionGameTimer.endGames(room, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@ -251,13 +184,55 @@ public class BattleBanzaiGame extends Game
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnd() {
|
||||||
|
GameTeam winningTeam = null;
|
||||||
|
|
||||||
|
for (GameTeam team : this.teams.values())
|
||||||
|
{
|
||||||
|
for(GamePlayer player : team.getMembers())
|
||||||
|
{
|
||||||
|
if (player.getScore() > 0)
|
||||||
|
{
|
||||||
|
AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallPlayer"));
|
||||||
|
AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallQuestCompleted"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (winningTeam == null || team.getTotalScore() > winningTeam.getTotalScore())
|
||||||
|
{
|
||||||
|
winningTeam = team;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (winningTeam != null)
|
||||||
|
{
|
||||||
|
for (GamePlayer player : winningTeam.getMembers())
|
||||||
|
{
|
||||||
|
if (player.getScore() > 0)
|
||||||
|
{
|
||||||
|
this.room.sendComposer(new RoomUserActionComposer(player.getHabbo().getRoomUnit(), RoomUserAction.WAVE).compose());
|
||||||
|
AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallWinner"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class))
|
||||||
|
{
|
||||||
|
item.setExtradata((7 + winningTeam.teamColor.type) + "");
|
||||||
|
this.room.updateItemState(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
Emulator.getThreading().run(new BattleBanzaiTilesFlicker(this.lockedTiles.get(winningTeam.teamColor), winningTeam.teamColor, this.room));
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onEnd();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop()
|
public void stop()
|
||||||
{
|
{
|
||||||
super.stop();
|
super.stop();
|
||||||
|
|
||||||
this.timeLeft = 0;
|
|
||||||
|
|
||||||
this.refreshGates();
|
this.refreshGates();
|
||||||
|
|
||||||
for (HabboItem tile : this.gameTiles.values())
|
for (HabboItem tile : this.gameTiles.values())
|
||||||
@ -265,7 +240,7 @@ public class BattleBanzaiGame extends Game
|
|||||||
if (tile.getExtradata().equals("1"))
|
if (tile.getExtradata().equals("1"))
|
||||||
{
|
{
|
||||||
tile.setExtradata("0");
|
tile.setExtradata("0");
|
||||||
this.room.updateItemState(tile);
|
this.room.updateItem(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.lockedTiles.clear();
|
this.lockedTiles.clear();
|
||||||
@ -292,22 +267,6 @@ public class BattleBanzaiGame extends Game
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPositionToGate(GameTeamColors teamColor)
|
|
||||||
{
|
|
||||||
for (InteractionBattleBanzaiGate gate : this.room.getRoomSpecialTypes().getBattleBanzaiGates().values())
|
|
||||||
{
|
|
||||||
if (gate.teamColor != teamColor)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (gate.getExtradata().isEmpty() || gate.getExtradata().equals("0"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
gate.setExtradata(Integer.valueOf(gate.getExtradata()) - 1 + "");
|
|
||||||
this.room.updateItemState(gate);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void tileLocked(GameTeamColors teamColor, HabboItem item, Habbo habbo)
|
public void tileLocked(GameTeamColors teamColor, HabboItem item, Habbo habbo)
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,8 @@ import com.eu.habbo.habbohotel.games.Game;
|
|||||||
import com.eu.habbo.habbohotel.games.GamePlayer;
|
import com.eu.habbo.habbohotel.games.GamePlayer;
|
||||||
import com.eu.habbo.habbohotel.games.GameTeam;
|
import com.eu.habbo.habbohotel.games.GameTeam;
|
||||||
import com.eu.habbo.habbohotel.games.GameTeamColors;
|
import com.eu.habbo.habbohotel.games.GameTeamColors;
|
||||||
|
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
|
|
||||||
public class BattleBanzaiGameTeam extends GameTeam
|
public class BattleBanzaiGameTeam extends GameTeam
|
||||||
{
|
{
|
||||||
@ -24,14 +26,17 @@ public class BattleBanzaiGameTeam extends GameTeam
|
|||||||
public void removeMember(GamePlayer gamePlayer)
|
public void removeMember(GamePlayer gamePlayer)
|
||||||
{
|
{
|
||||||
Game game = gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().getGame(gamePlayer.getHabbo().getHabboInfo().getCurrentGame());
|
Game game = gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().getGame(gamePlayer.getHabbo().getHabboInfo().getCurrentGame());
|
||||||
if(game instanceof BattleBanzaiGame)
|
Room room = gamePlayer.getHabbo().getRoomUnit().getRoom();
|
||||||
{
|
|
||||||
((BattleBanzaiGame) game).addPositionToGate(gamePlayer.getTeamColor());
|
|
||||||
}
|
|
||||||
|
|
||||||
gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), 0, -1);
|
gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), 0, -1);
|
||||||
gamePlayer.getHabbo().getRoomUnit().setCanWalk(true);
|
gamePlayer.getHabbo().getRoomUnit().setCanWalk(true);
|
||||||
|
|
||||||
super.removeMember(gamePlayer);
|
super.removeMember(gamePlayer);
|
||||||
|
|
||||||
|
if(room != null && room.getRoomSpecialTypes() != null) {
|
||||||
|
for (InteractionGameGate gate : room.getRoomSpecialTypes().getBattleBanzaiGates().values()) {
|
||||||
|
gate.updateState(game, 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreeze
|
|||||||
import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeTimer;
|
import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeTimer;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.games.freeze.gates.InteractionFreezeGate;
|
import com.eu.habbo.habbohotel.items.interactions.games.freeze.gates.InteractionFreezeGate;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.games.freeze.scoreboards.InteractionFreezeScoreboard;
|
import com.eu.habbo.habbohotel.items.interactions.games.freeze.scoreboards.InteractionFreezeScoreboard;
|
||||||
|
import com.eu.habbo.habbohotel.items.interactions.wired.effects.WiredEffectTeleport;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomLayout;
|
import com.eu.habbo.habbohotel.rooms.RoomLayout;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||||
@ -45,8 +46,6 @@ public class FreezeGame extends Game
|
|||||||
public static int FREEZE_LOOSE_POINTS;
|
public static int FREEZE_LOOSE_POINTS;
|
||||||
public static boolean POWERUP_STACK;
|
public static boolean POWERUP_STACK;
|
||||||
|
|
||||||
private int timeLeft;
|
|
||||||
|
|
||||||
public FreezeGame(Room room)
|
public FreezeGame(Room room)
|
||||||
{
|
{
|
||||||
super(FreezeGameTeam.class, FreezeGamePlayer.class, room, true);
|
super(FreezeGameTeam.class, FreezeGamePlayer.class, room, true);
|
||||||
@ -59,49 +58,13 @@ public class FreezeGame extends Game
|
|||||||
if(this.state == GameState.RUNNING)
|
if(this.state == GameState.RUNNING)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int highestTime = 0;
|
|
||||||
|
|
||||||
this.resetMap();
|
this.resetMap();
|
||||||
|
|
||||||
for (Map.Entry<Integer, InteractionFreezeTimer> set : this.room.getRoomSpecialTypes().getFreezeTimers().entrySet())
|
|
||||||
{
|
|
||||||
if(set.getValue().getExtradata().isEmpty())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if(highestTime < Integer.valueOf(set.getValue().getExtradata()))
|
|
||||||
{
|
|
||||||
highestTime = Integer.valueOf(set.getValue().getExtradata());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (GameTeam t : this.teams.values())
|
for (GameTeam t : this.teams.values())
|
||||||
{
|
{
|
||||||
t.initialise();
|
t.initialise();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.room.getRoomSpecialTypes().hasFreezeExitTile())
|
|
||||||
{
|
|
||||||
for (Habbo habbo : this.room.getHabbos())
|
|
||||||
{
|
|
||||||
if (this.getTeamForHabbo(habbo) == null)
|
|
||||||
{
|
|
||||||
for (HabboItem item : this.room.getItemsAt(habbo.getRoomUnit().getCurrentLocation()))
|
|
||||||
{
|
|
||||||
if (item instanceof InteractionFreezeTile)
|
|
||||||
{
|
|
||||||
this.room.teleportHabboToItem(habbo, this.room.getRoomSpecialTypes().getRandomFreezeExitTile());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.timeLeft = highestTime;
|
|
||||||
|
|
||||||
if (this.timeLeft == 0)
|
|
||||||
{
|
|
||||||
this.timeLeft = 30;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.start();
|
this.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,22 +80,6 @@ public class FreezeGame extends Game
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void placebackHelmet(GameTeamColors teamColor)
|
|
||||||
{
|
|
||||||
for (InteractionFreezeGate gate : this.room.getRoomSpecialTypes().getFreezeGates().values())
|
|
||||||
{
|
|
||||||
if (gate.teamColor != teamColor)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (gate.getExtradata().isEmpty() || gate.getExtradata().equals("0"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
gate.setExtradata(Integer.valueOf(gate.getExtradata()) - 1 + "");
|
|
||||||
this.room.updateItemState(gate);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void throwBall(Habbo habbo, InteractionFreezeTile item)
|
public void throwBall(Habbo habbo, InteractionFreezeTile item)
|
||||||
{
|
{
|
||||||
if (!this.state.equals(GameState.RUNNING) || !habbo.getHabboInfo().isInGame() || habbo.getHabboInfo().getCurrentGame() != this.getClass())
|
if (!this.state.equals(GameState.RUNNING) || !habbo.getHabboInfo().isInGame() || habbo.getHabboInfo().getCurrentGame() != this.getClass())
|
||||||
@ -280,9 +227,26 @@ public class FreezeGame extends Game
|
|||||||
|
|
||||||
super.start();
|
super.start();
|
||||||
|
|
||||||
|
if (this.room.getRoomSpecialTypes().hasFreezeExitTile())
|
||||||
|
{
|
||||||
|
for (Habbo habbo : this.room.getHabbos())
|
||||||
|
{
|
||||||
|
if (this.getTeamForHabbo(habbo) == null)
|
||||||
|
{
|
||||||
|
for (HabboItem item : this.room.getItemsAt(habbo.getRoomUnit().getCurrentLocation()))
|
||||||
|
{
|
||||||
|
if (item instanceof InteractionFreezeTile)
|
||||||
|
{
|
||||||
|
HabboItem exitTile = this.room.getRoomSpecialTypes().getRandomFreezeExitTile();
|
||||||
|
WiredEffectTeleport.teleportUnitToTile(habbo.getRoomUnit(), this.room.getLayout().getTile(exitTile.getX(), exitTile.getY()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.refreshGates();
|
this.refreshGates();
|
||||||
|
|
||||||
WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, this.room, null);
|
|
||||||
this.setFreezeTileState("1");
|
this.setFreezeTileState("1");
|
||||||
this.run();
|
this.run();
|
||||||
}
|
}
|
||||||
@ -295,50 +259,36 @@ public class FreezeGame extends Game
|
|||||||
if (this.state.equals(GameState.IDLE))
|
if (this.state.equals(GameState.IDLE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this.timeLeft > 0)
|
Emulator.getThreading().run(this, 1000);
|
||||||
|
|
||||||
|
if (this.state.equals(GameState.PAUSED)) return;
|
||||||
|
|
||||||
|
for (GameTeam team : this.teams.values())
|
||||||
{
|
{
|
||||||
Emulator.getThreading().run(this, 1000);
|
for (GamePlayer player : team.getMembers())
|
||||||
|
|
||||||
if (this.state.equals(GameState.PAUSED)) return;
|
|
||||||
|
|
||||||
this.timeLeft--;
|
|
||||||
|
|
||||||
for (GameTeam team : this.teams.values())
|
|
||||||
{
|
{
|
||||||
for (GamePlayer player : team.getMembers())
|
((FreezeGamePlayer)player).cycle();
|
||||||
{
|
|
||||||
((FreezeGamePlayer)player).cycle();
|
|
||||||
}
|
|
||||||
|
|
||||||
int totalScore = team.getTotalScore();
|
|
||||||
|
|
||||||
THashMap<Integer, InteractionFreezeScoreboard> scoreBoards = this.room.getRoomSpecialTypes().getFreezeScoreboards(team.teamColor);
|
|
||||||
|
|
||||||
for (InteractionFreezeScoreboard scoreboard : scoreBoards.values())
|
|
||||||
{
|
|
||||||
if(scoreboard.getExtradata().isEmpty())
|
|
||||||
{
|
|
||||||
scoreboard.setExtradata("0");
|
|
||||||
}
|
|
||||||
|
|
||||||
int oldScore = Integer.valueOf(scoreboard.getExtradata());
|
|
||||||
|
|
||||||
if(oldScore == totalScore)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
scoreboard.setExtradata(totalScore + "");
|
|
||||||
this.room.updateItemState(scoreboard);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Map.Entry<Integer, InteractionFreezeTimer> set : this.room.getRoomSpecialTypes().getFreezeTimers().entrySet())
|
int totalScore = team.getTotalScore();
|
||||||
|
|
||||||
|
THashMap<Integer, InteractionFreezeScoreboard> scoreBoards = this.room.getRoomSpecialTypes().getFreezeScoreboards(team.teamColor);
|
||||||
|
|
||||||
|
for (InteractionFreezeScoreboard scoreboard : scoreBoards.values())
|
||||||
{
|
{
|
||||||
set.getValue().setExtradata(this.timeLeft + "");
|
if(scoreboard.getExtradata().isEmpty())
|
||||||
this.room.updateItemState(set.getValue());
|
{
|
||||||
|
scoreboard.setExtradata("0");
|
||||||
|
}
|
||||||
|
|
||||||
|
int oldScore = Integer.valueOf(scoreboard.getExtradata());
|
||||||
|
|
||||||
|
if(oldScore == totalScore)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
scoreboard.setExtradata(totalScore + "");
|
||||||
|
this.room.updateItemState(scoreboard);
|
||||||
}
|
}
|
||||||
} else
|
|
||||||
{
|
|
||||||
this.stop();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@ -352,8 +302,6 @@ public class FreezeGame extends Game
|
|||||||
{
|
{
|
||||||
super.stop();
|
super.stop();
|
||||||
|
|
||||||
this.timeLeft = 0;
|
|
||||||
|
|
||||||
GameTeam winningTeam = null;
|
GameTeam winningTeam = null;
|
||||||
|
|
||||||
for(GameTeam team : this.teams.values())
|
for(GameTeam team : this.teams.values())
|
||||||
|
@ -4,6 +4,8 @@ import com.eu.habbo.habbohotel.games.Game;
|
|||||||
import com.eu.habbo.habbohotel.games.GamePlayer;
|
import com.eu.habbo.habbohotel.games.GamePlayer;
|
||||||
import com.eu.habbo.habbohotel.games.GameTeam;
|
import com.eu.habbo.habbohotel.games.GameTeam;
|
||||||
import com.eu.habbo.habbohotel.games.GameTeamColors;
|
import com.eu.habbo.habbohotel.games.GameTeamColors;
|
||||||
|
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
|
|
||||||
public class FreezeGameTeam extends GameTeam
|
public class FreezeGameTeam extends GameTeam
|
||||||
{
|
{
|
||||||
@ -16,15 +18,18 @@ public class FreezeGameTeam extends GameTeam
|
|||||||
public void removeMember(GamePlayer gamePlayer)
|
public void removeMember(GamePlayer gamePlayer)
|
||||||
{
|
{
|
||||||
Game game = gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().getGame(FreezeGame.class);
|
Game game = gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().getGame(FreezeGame.class);
|
||||||
if(game instanceof FreezeGame)
|
Room room = gamePlayer.getHabbo().getRoomUnit().getRoom();
|
||||||
{
|
|
||||||
((FreezeGame) game).placebackHelmet(gamePlayer.getTeamColor());
|
|
||||||
}
|
|
||||||
|
|
||||||
gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), 0, -1);
|
gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), 0, -1);
|
||||||
gamePlayer.getHabbo().getRoomUnit().setCanWalk(true);
|
gamePlayer.getHabbo().getRoomUnit().setCanWalk(true);
|
||||||
|
|
||||||
super.removeMember(gamePlayer);
|
super.removeMember(gamePlayer);
|
||||||
|
|
||||||
|
if(room != null && room.getRoomSpecialTypes() != null) {
|
||||||
|
for (InteractionGameGate gate : room.getRoomSpecialTypes().getFreezeGates().values()) {
|
||||||
|
gate.updateState(game, 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,51 +14,19 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class WiredGame extends Game
|
public class WiredGame extends Game
|
||||||
{
|
{
|
||||||
private int timeLeft = 30;
|
|
||||||
public WiredGame(Room room)
|
public WiredGame(Room room)
|
||||||
{
|
{
|
||||||
super(GameTeam.class, GamePlayer.class, room , false);
|
super(GameTeam.class, GamePlayer.class, room , false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialise()
|
public void initialise() {
|
||||||
{
|
|
||||||
for (Map.Entry<Integer, InteractionGameTimer> set : this.room.getRoomSpecialTypes().getGameTimers().entrySet())
|
|
||||||
{
|
|
||||||
if(set.getValue().getExtradata().isEmpty())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if(this.timeLeft < Integer.valueOf(set.getValue().getExtradata()))
|
|
||||||
{
|
|
||||||
this.timeLeft = Integer.valueOf(set.getValue().getExtradata());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.timeLeft <= 30)
|
|
||||||
{
|
|
||||||
this.timeLeft = 30;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run() {
|
||||||
{
|
|
||||||
if (this.timeLeft > 0)
|
|
||||||
{
|
|
||||||
Emulator.getThreading().run(this, 1000);
|
|
||||||
this.timeLeft--;
|
|
||||||
for (Map.Entry<Integer, InteractionGameTimer> set : this.room.getRoomSpecialTypes().getGameTimers().entrySet())
|
|
||||||
{
|
|
||||||
set.getValue().setExtradata(this.timeLeft + "");
|
|
||||||
this.room.updateItemState(set.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.stop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.eu.habbo.habbohotel.items.interactions.games;
|
package com.eu.habbo.habbohotel.items.interactions.games;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.games.Game;
|
||||||
import com.eu.habbo.habbohotel.games.GameTeamColors;
|
import com.eu.habbo.habbohotel.games.GameTeamColors;
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
@ -14,11 +15,13 @@ public abstract class InteractionGameGate extends InteractionGameTeamItem
|
|||||||
public InteractionGameGate(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException
|
public InteractionGameGate(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException
|
||||||
{
|
{
|
||||||
super(set, baseItem, teamColor);
|
super(set, baseItem, teamColor);
|
||||||
|
this.setExtradata("0");
|
||||||
}
|
}
|
||||||
|
|
||||||
public InteractionGameGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor)
|
public InteractionGameGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor)
|
||||||
{
|
{
|
||||||
super(id, userId, item, extradata, limitedStack, limitedSells, teamColor);
|
super(id, userId, item, extradata, limitedStack, limitedSells, teamColor);
|
||||||
|
this.setExtradata("0");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -41,4 +44,13 @@ public abstract class InteractionGameGate extends InteractionGameTeamItem
|
|||||||
|
|
||||||
super.serializeExtradata(serverMessage);
|
super.serializeExtradata(serverMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateState(Game game, int maxPlayers) {
|
||||||
|
int memberCount = game.getTeam(this.teamColor).getMembers().size();
|
||||||
|
if(memberCount > maxPlayers) {
|
||||||
|
memberCount = maxPlayers;
|
||||||
|
}
|
||||||
|
this.setExtradata(memberCount + "");
|
||||||
|
game.getRoom().updateItem(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import com.eu.habbo.Emulator;
|
|||||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||||
import com.eu.habbo.habbohotel.games.Game;
|
import com.eu.habbo.habbohotel.games.Game;
|
||||||
import com.eu.habbo.habbohotel.games.GameState;
|
import com.eu.habbo.habbohotel.games.GameState;
|
||||||
|
import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame;
|
||||||
|
import com.eu.habbo.habbohotel.games.freeze.FreezeGame;
|
||||||
import com.eu.habbo.habbohotel.games.wired.WiredGame;
|
import com.eu.habbo.habbohotel.games.wired.WiredGame;
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||||
@ -11,15 +13,22 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
|||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public abstract class InteractionGameTimer extends HabboItem
|
public abstract class InteractionGameTimer extends HabboItem implements Runnable
|
||||||
{
|
{
|
||||||
private int baseTime = 0;
|
private int baseTime = 0;
|
||||||
private int lastToggle = 0;
|
private int timeNow = 0;
|
||||||
|
private boolean isRunning = false;
|
||||||
|
private boolean isPaused = false;
|
||||||
|
|
||||||
public InteractionGameTimer(ResultSet set, Item baseItem) throws SQLException
|
public InteractionGameTimer(ResultSet set, Item baseItem) throws SQLException
|
||||||
{
|
{
|
||||||
@ -30,6 +39,7 @@ public abstract class InteractionGameTimer extends HabboItem
|
|||||||
if (data.length >= 2)
|
if (data.length >= 2)
|
||||||
{
|
{
|
||||||
this.baseTime = Integer.valueOf(data[1]);
|
this.baseTime = Integer.valueOf(data[1]);
|
||||||
|
this.timeNow = this.baseTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.length >= 1)
|
if (data.length >= 1)
|
||||||
@ -43,6 +53,67 @@ public abstract class InteractionGameTimer extends HabboItem
|
|||||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if(this.needsUpdate() || this.needsDelete()) {
|
||||||
|
super.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.getRoomId() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||||
|
|
||||||
|
if(room == null || !this.isRunning || this.isPaused)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(this.timeNow > 0) {
|
||||||
|
Emulator.getThreading().run(this, 1000);
|
||||||
|
this.timeNow--;
|
||||||
|
room.updateItem(this);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.isRunning = false;
|
||||||
|
this.isPaused = false;
|
||||||
|
endGamesIfLastTimer(room);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void endGamesIfLastTimer(Room room) {
|
||||||
|
boolean gamesActive = false;
|
||||||
|
for (InteractionGameTimer timer : room.getRoomSpecialTypes().getGameTimers().values()) {
|
||||||
|
if (timer.isRunning())
|
||||||
|
gamesActive = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gamesActive) {
|
||||||
|
endGames(room);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void endGames(Room room) {
|
||||||
|
endGames(room, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void endGames(Room room, boolean overrideTriggerWired) {
|
||||||
|
|
||||||
|
boolean triggerWired = false;
|
||||||
|
|
||||||
|
//end existing games
|
||||||
|
for (Class<? extends Game> gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) {
|
||||||
|
Game game = InteractionGameTimer.getOrCreateGame(room, gameClass);
|
||||||
|
if (!game.state.equals(GameState.IDLE)) {
|
||||||
|
triggerWired = true;
|
||||||
|
game.onEnd();
|
||||||
|
game.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(triggerWired) {
|
||||||
|
WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, room, new Object[]{});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp(Room room)
|
public void onPickUp(Room room)
|
||||||
{
|
{
|
||||||
@ -52,8 +123,12 @@ public abstract class InteractionGameTimer extends HabboItem
|
|||||||
@Override
|
@Override
|
||||||
public void onPlace(Room room)
|
public void onPlace(Room room)
|
||||||
{
|
{
|
||||||
this.baseTime = 30;
|
if(this.baseTime == 0) {
|
||||||
this.setExtradata("30");
|
this.baseTime = 30;
|
||||||
|
this.timeNow = this.baseTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setExtradata(this.timeNow + "\t" + this.baseTime);
|
||||||
room.updateItem(this);
|
room.updateItem(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +136,7 @@ public abstract class InteractionGameTimer extends HabboItem
|
|||||||
public void serializeExtradata(ServerMessage serverMessage)
|
public void serializeExtradata(ServerMessage serverMessage)
|
||||||
{
|
{
|
||||||
serverMessage.appendInt((this.isLimited() ? 256 : 0));
|
serverMessage.appendInt((this.isLimited() ? 256 : 0));
|
||||||
serverMessage.appendString(this.getExtradata());
|
serverMessage.appendString("" + timeNow);
|
||||||
|
|
||||||
super.serializeExtradata(serverMessage);
|
super.serializeExtradata(serverMessage);
|
||||||
}
|
}
|
||||||
@ -81,65 +156,123 @@ public abstract class InteractionGameTimer extends HabboItem
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception
|
public void onClick(GameClient client, Room room, Object[] objects) throws Exception
|
||||||
{
|
{
|
||||||
if (client != null)
|
|
||||||
{
|
|
||||||
if (!(room.hasRights(client.getHabbo()) || client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (client == null)
|
|
||||||
{
|
|
||||||
int now = Emulator.getIntUnixTimestamp();
|
|
||||||
if (now - this.lastToggle < 3) return;
|
|
||||||
this.lastToggle = now;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.getExtradata().isEmpty())
|
if(this.getExtradata().isEmpty())
|
||||||
{
|
{
|
||||||
this.setExtradata("0");
|
this.setExtradata("0");
|
||||||
}
|
}
|
||||||
|
|
||||||
Game game = this.getOrCreateGame(room);
|
// if wired triggered it
|
||||||
|
if (objects.length >= 2 && objects[1] instanceof WiredEffectType && !this.isRunning)
|
||||||
if ((objects.length >= 2 && objects[1] instanceof WiredEffectType))
|
|
||||||
{
|
{
|
||||||
if (game == null || !game.isRunning)
|
endGamesIfLastTimer(room);
|
||||||
startGame(room);
|
|
||||||
else if (game.isRunning)
|
for(Class<? extends Game> gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) {
|
||||||
stopGame(room);
|
Game game = getOrCreateGame(room, gameClass);
|
||||||
|
if(!game.isRunning) {
|
||||||
|
game.initialise();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
timeNow = this.baseTime;
|
||||||
|
this.isRunning = true;
|
||||||
|
room.updateItem(this);
|
||||||
|
WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, room, new Object[] { });
|
||||||
|
|
||||||
|
Emulator.getThreading().run(this);
|
||||||
}
|
}
|
||||||
|
else if(client != null)
|
||||||
if(objects.length >= 1 && objects[0] instanceof Integer && client != null)
|
|
||||||
{
|
{
|
||||||
int state = (Integer)objects[0];
|
if (!(room.hasRights(client.getHabbo()) || client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
int state = 1;
|
||||||
|
|
||||||
|
if(objects.length >= 1 && objects[0] instanceof Integer) {
|
||||||
|
state = (Integer) objects[0];
|
||||||
|
}
|
||||||
|
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
{
|
if(this.isRunning) {
|
||||||
this.startGame(room);
|
this.isPaused = !this.isPaused;
|
||||||
|
|
||||||
|
boolean allPaused = this.isPaused;
|
||||||
|
for(InteractionGameTimer timer : room.getRoomSpecialTypes().getGameTimers().values()) {
|
||||||
|
if(!timer.isPaused)
|
||||||
|
allPaused = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(Class<? extends Game> gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) {
|
||||||
|
Game game = getOrCreateGame(room, gameClass);
|
||||||
|
if(allPaused) {
|
||||||
|
game.pause();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
game.unpause();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!this.isPaused) {
|
||||||
|
this.isRunning = true;
|
||||||
|
timeNow = this.baseTime;
|
||||||
|
room.updateItem(this);
|
||||||
|
Emulator.getThreading().run(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!this.isRunning) {
|
||||||
|
endGamesIfLastTimer(room);
|
||||||
|
|
||||||
|
for(Class<? extends Game> gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) {
|
||||||
|
Game game = getOrCreateGame(room, gameClass);
|
||||||
|
game.initialise();
|
||||||
|
}
|
||||||
|
|
||||||
|
WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, room, new Object[] { });
|
||||||
|
this.isRunning = true;
|
||||||
|
timeNow = this.baseTime;
|
||||||
|
room.updateItem(this);
|
||||||
|
Emulator.getThreading().run(this);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
{
|
if(!this.isRunning) {
|
||||||
this.increaseTimer(room);
|
this.increaseTimer(room);
|
||||||
}
|
return;
|
||||||
break;
|
}
|
||||||
|
|
||||||
|
if(this.isPaused) {
|
||||||
|
this.isPaused = false;
|
||||||
|
this.isRunning = false;
|
||||||
|
|
||||||
|
timeNow = this.baseTime;
|
||||||
|
room.updateItem(this);
|
||||||
|
|
||||||
|
endGamesIfLastTimer(room);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
{
|
|
||||||
this.stopGame(room);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
if (game != null && game.state.equals(GameState.IDLE))
|
this.isPaused = false;
|
||||||
{
|
this.isRunning = false;
|
||||||
this.startGame(room);
|
|
||||||
|
timeNow = this.baseTime;
|
||||||
|
room.updateItem(this);
|
||||||
|
|
||||||
|
boolean gamesActive = false;
|
||||||
|
for (InteractionGameTimer timer : room.getRoomSpecialTypes().getGameTimers().values()) {
|
||||||
|
if (timer.isRunning())
|
||||||
|
gamesActive = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gamesActive) {
|
||||||
|
endGames(room);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,87 +285,30 @@ public abstract class InteractionGameTimer extends HabboItem
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Game getOrCreateGame(Room room)
|
public static Game getOrCreateGame(Room room, Class<? extends Game> gameClass)
|
||||||
{
|
{
|
||||||
Game game = (this.getGameType().cast(room.getGame(this.getGameType())));
|
Game game = (gameClass.cast(room.getGame(gameClass)));
|
||||||
|
|
||||||
if (game == null)
|
if (game == null) {
|
||||||
{
|
try {
|
||||||
try
|
System.out.println(gameClass.getName());
|
||||||
{
|
game = gameClass.getDeclaredConstructor(Room.class).newInstance(room);
|
||||||
game = this.getGameType().getDeclaredConstructor(Room.class).newInstance(room);
|
|
||||||
room.addGame(game);
|
room.addGame(game);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
Emulator.getLogging().logErrorLine(e);
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return game;
|
return game;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startGame(Room room)
|
|
||||||
{
|
|
||||||
this.needsUpdate(true);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
room.updateItem(this);
|
|
||||||
|
|
||||||
Game game = this.getOrCreateGame(room);
|
|
||||||
|
|
||||||
if (game.state.equals(GameState.IDLE))
|
|
||||||
{
|
|
||||||
this.setExtradata(this.baseTime + "");
|
|
||||||
game.initialise();
|
|
||||||
}
|
|
||||||
else if (game.state.equals(GameState.PAUSED))
|
|
||||||
{
|
|
||||||
game.unpause();
|
|
||||||
}
|
|
||||||
else if (game.state.equals(GameState.RUNNING))
|
|
||||||
{
|
|
||||||
game.pause();
|
|
||||||
}
|
|
||||||
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Emulator.getLogging().logErrorLine(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void stopGame(Room room)
|
|
||||||
{
|
|
||||||
this.setExtradata(this.baseTime + "");
|
|
||||||
this.needsUpdate(true);
|
|
||||||
Game game = this.getOrCreateGame(room);
|
|
||||||
|
|
||||||
if(game != null && game.state != GameState.IDLE)
|
|
||||||
{
|
|
||||||
this.setExtradata(this.baseTime + "");
|
|
||||||
game.stop();
|
|
||||||
stopGame(room);
|
|
||||||
}
|
|
||||||
|
|
||||||
room.updateItem(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void increaseTimer(Room room)
|
private void increaseTimer(Room room)
|
||||||
{
|
{
|
||||||
Game game = this.getOrCreateGame(room);
|
if(this.isRunning)
|
||||||
|
|
||||||
if (game == null) return;
|
|
||||||
if (game.state.equals(GameState.PAUSED))
|
|
||||||
{
|
|
||||||
stopGame(room);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
if (game.state.equals(GameState.RUNNING)) return;
|
|
||||||
|
|
||||||
this.needsUpdate(true);
|
this.needsUpdate(true);
|
||||||
|
|
||||||
switch(this.baseTime)
|
switch(this.baseTime)
|
||||||
{
|
{
|
||||||
case 0: this.baseTime = 30; break;
|
case 0: this.baseTime = 30; break;
|
||||||
@ -247,9 +323,9 @@ public abstract class InteractionGameTimer extends HabboItem
|
|||||||
this.baseTime = 30;
|
this.baseTime = 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setExtradata(this.baseTime + "");
|
this.timeNow = this.baseTime;
|
||||||
|
|
||||||
room.updateItem(this);
|
room.updateItem(this);
|
||||||
|
this.needsUpdate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -265,4 +341,20 @@ public abstract class InteractionGameTimer extends HabboItem
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isRunning() {
|
||||||
|
return isRunning;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRunning(boolean running) {
|
||||||
|
isRunning = running;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTimeNow() {
|
||||||
|
return timeNow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeNow(int timeNow) {
|
||||||
|
this.timeNow = timeNow;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates;
|
package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates;
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.habbohotel.games.GamePlayer;
|
||||||
import com.eu.habbo.habbohotel.games.GameState;
|
import com.eu.habbo.habbohotel.games.GameState;
|
||||||
import com.eu.habbo.habbohotel.games.GameTeam;
|
import com.eu.habbo.habbohotel.games.GameTeam;
|
||||||
import com.eu.habbo.habbohotel.games.GameTeamColors;
|
import com.eu.habbo.habbohotel.games.GameTeamColors;
|
||||||
@ -9,6 +10,7 @@ import com.eu.habbo.habbohotel.items.Item;
|
|||||||
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate;
|
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
|
import gnu.trove.set.hash.THashSet;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@ -67,18 +69,11 @@ public class InteractionBattleBanzaiGate extends InteractionGameGate
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(this.getExtradata().isEmpty())
|
|
||||||
{
|
|
||||||
this.setExtradata("0");
|
|
||||||
}
|
|
||||||
|
|
||||||
int value = Integer.valueOf(this.getExtradata()) + 1;
|
|
||||||
|
|
||||||
this.setExtradata(value + "");
|
|
||||||
room.updateItem(this);
|
|
||||||
game.addHabbo(room.getHabbo(roomUnit), this.teamColor);
|
game.addHabbo(room.getHabbo(roomUnit), this.teamColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateState(game, 5);
|
||||||
|
|
||||||
super.onWalkOn(roomUnit, room, objects);
|
super.onWalkOn(roomUnit, room, objects);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,18 +66,11 @@ public class InteractionFreezeGate extends InteractionGameGate
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(this.getExtradata().isEmpty())
|
|
||||||
{
|
|
||||||
this.setExtradata("0");
|
|
||||||
}
|
|
||||||
|
|
||||||
int value = Integer.valueOf(this.getExtradata()) + 1;
|
|
||||||
|
|
||||||
this.setExtradata(value + "");
|
|
||||||
room.updateItem(this);
|
|
||||||
game.addHabbo(room.getHabbo(roomUnit), this.teamColor);
|
game.addHabbo(room.getHabbo(roomUnit), this.teamColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateState(game, 5);
|
||||||
|
|
||||||
super.onWalkOn(roomUnit, room, objects);
|
super.onWalkOn(roomUnit, room, objects);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,11 +94,8 @@ public class WiredEffectBotTalk extends InteractionWiredEffect
|
|||||||
}
|
}
|
||||||
List<Bot> bots = room.getBots(this.botName);
|
List<Bot> bots = room.getBots(this.botName);
|
||||||
|
|
||||||
int now = Emulator.getIntUnixTimestamp();
|
|
||||||
for(Bot bot : bots)
|
for(Bot bot : bots)
|
||||||
{
|
{
|
||||||
if (now - bot.getChatTimestamp() < bot.getChatDelay()) continue;
|
|
||||||
|
|
||||||
if(this.mode == 1)
|
if(this.mode == 1)
|
||||||
bot.shout(message);
|
bot.shout(message);
|
||||||
else
|
else
|
||||||
|
@ -119,6 +119,50 @@ public class WiredEffectTeleport extends InteractionWiredEffect
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void teleportUnitToTile(RoomUnit roomUnit, RoomTile tile) {
|
||||||
|
Room room = roomUnit.getRoom();
|
||||||
|
|
||||||
|
// makes a temporary effect
|
||||||
|
room.sendComposer(new RoomUserEffectComposer(roomUnit, 4).compose());
|
||||||
|
Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), WiredHandler.TELEPORT_DELAY);
|
||||||
|
|
||||||
|
if (tile.state == RoomTileState.INVALID || tile.state == RoomTileState.BLOCKED)
|
||||||
|
{
|
||||||
|
RoomTile alternativeTile = null;
|
||||||
|
List<RoomTile> optionalTiles = room.getLayout().getTilesAround(tile);
|
||||||
|
|
||||||
|
Collections.reverse(optionalTiles);
|
||||||
|
for (RoomTile optionalTile : optionalTiles)
|
||||||
|
{
|
||||||
|
if (optionalTile.state != RoomTileState.INVALID && optionalTile.state != RoomTileState.BLOCKED)
|
||||||
|
{
|
||||||
|
alternativeTile = optionalTile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(alternativeTile != null) {
|
||||||
|
tile = alternativeTile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, tile.x, tile.y, tile.getStackHeight() + (tile.state == RoomTileState.SIT ? -0.5 : 0) , roomUnit.getEffectId()), WiredHandler.TELEPORT_DELAY);
|
||||||
|
|
||||||
|
HabboItem topItem = room.getTopItemAt(tile.x, tile.y);
|
||||||
|
|
||||||
|
if(topItem != null) {
|
||||||
|
Emulator.getThreading().run(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
topItem.onWalkOn(roomUnit, room, new Object[] { });
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, WiredHandler.TELEPORT_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff)
|
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff)
|
||||||
{
|
{
|
||||||
@ -146,52 +190,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect
|
|||||||
tryCount++;
|
tryCount++;
|
||||||
HabboItem item = this.items.get((tryCount - 1 + i) % this.items.size());
|
HabboItem item = this.items.get((tryCount - 1 + i) % this.items.size());
|
||||||
|
|
||||||
int currentEffect = roomUnit.getEffectId();
|
teleportUnitToTile(roomUnit, room.getLayout().getTile(item.getX(), item.getY()));
|
||||||
|
|
||||||
// makes a temporary effect
|
|
||||||
room.sendComposer(new RoomUserEffectComposer(roomUnit, 4).compose());
|
|
||||||
Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), 2000);
|
|
||||||
|
|
||||||
final WiredEffectTeleport teleportWired = this;
|
|
||||||
RoomTile targetTile = room.getLayout().getTile(item.getX(), item.getY());
|
|
||||||
boolean foundTile = false;
|
|
||||||
if (targetTile.state == RoomTileState.INVALID || targetTile.state == RoomTileState.BLOCKED)
|
|
||||||
{
|
|
||||||
List<RoomTile> optionalTiles = room.getLayout().getTilesAround(targetTile, item.getRotation() + 3);
|
|
||||||
|
|
||||||
Collections.reverse(optionalTiles);
|
|
||||||
for (RoomTile tile : optionalTiles)
|
|
||||||
{
|
|
||||||
if (tile.state != RoomTileState.INVALID && tile.state != RoomTileState.BLOCKED)
|
|
||||||
{
|
|
||||||
targetTile = tile;
|
|
||||||
foundTile = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
foundTile = true;
|
|
||||||
}
|
|
||||||
if (!foundTile)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, targetTile.x, targetTile.y, targetTile.getStackHeight() + (targetTile.state == RoomTileState.SIT ? -0.5 : 0) , currentEffect), WiredHandler.TELEPORT_DELAY);
|
|
||||||
Emulator.getThreading().run(new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
item.onWalkOn(roomUnit, room, new Object[]{teleportWired});
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{}
|
|
||||||
}
|
|
||||||
}, WiredHandler.TELEPORT_DELAY);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1013,6 +1013,10 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
|
|||||||
this.mutedHabbos.clear();
|
this.mutedHabbos.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(InteractionGameTimer timer : this.getRoomSpecialTypes().getGameTimers().values()) {
|
||||||
|
timer.setRunning(false);
|
||||||
|
}
|
||||||
|
|
||||||
for (Game game : this.games)
|
for (Game game : this.games)
|
||||||
{
|
{
|
||||||
game.stop();
|
game.stop();
|
||||||
|
@ -4,6 +4,15 @@ import com.eu.habbo.Emulator;
|
|||||||
import com.eu.habbo.core.RoomUserPetComposer;
|
import com.eu.habbo.core.RoomUserPetComposer;
|
||||||
import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
||||||
import com.eu.habbo.habbohotel.bots.Bot;
|
import com.eu.habbo.habbohotel.bots.Bot;
|
||||||
|
import com.eu.habbo.habbohotel.games.Game;
|
||||||
|
import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame;
|
||||||
|
import com.eu.habbo.habbohotel.games.football.FootballGame;
|
||||||
|
import com.eu.habbo.habbohotel.games.freeze.FreezeGame;
|
||||||
|
import com.eu.habbo.habbohotel.games.tag.BunnyrunGame;
|
||||||
|
import com.eu.habbo.habbohotel.games.tag.IceTagGame;
|
||||||
|
import com.eu.habbo.habbohotel.games.tag.RollerskateGame;
|
||||||
|
import com.eu.habbo.habbohotel.games.tag.TagGame;
|
||||||
|
import com.eu.habbo.habbohotel.games.wired.WiredGame;
|
||||||
import com.eu.habbo.habbohotel.guilds.Guild;
|
import com.eu.habbo.habbohotel.guilds.Guild;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWired;
|
import com.eu.habbo.habbohotel.items.interactions.InteractionWired;
|
||||||
import com.eu.habbo.habbohotel.messenger.MessengerBuddy;
|
import com.eu.habbo.habbohotel.messenger.MessengerBuddy;
|
||||||
@ -57,6 +66,7 @@ public class RoomManager
|
|||||||
private final THashMap<Integer, RoomCategory> roomCategories;
|
private final THashMap<Integer, RoomCategory> roomCategories;
|
||||||
private final List<String> mapNames;
|
private final List<String> mapNames;
|
||||||
private final ConcurrentHashMap<Integer, Room> activeRooms;
|
private final ConcurrentHashMap<Integer, Room> activeRooms;
|
||||||
|
private final ArrayList<Class<? extends Game>> gameTypes;
|
||||||
|
|
||||||
public RoomManager()
|
public RoomManager()
|
||||||
{
|
{
|
||||||
@ -67,6 +77,16 @@ public class RoomManager
|
|||||||
this.loadRoomCategories();
|
this.loadRoomCategories();
|
||||||
this.loadRoomModels();
|
this.loadRoomModels();
|
||||||
|
|
||||||
|
this.gameTypes = new ArrayList<>();
|
||||||
|
|
||||||
|
registerGameType(BattleBanzaiGame.class);
|
||||||
|
registerGameType(FreezeGame.class);
|
||||||
|
registerGameType(WiredGame.class);
|
||||||
|
registerGameType(FootballGame.class);
|
||||||
|
registerGameType(BunnyrunGame.class);
|
||||||
|
registerGameType(IceTagGame.class);
|
||||||
|
registerGameType(RollerskateGame.class);
|
||||||
|
|
||||||
Emulator.getLogging().logStart("Room Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
|
Emulator.getLogging().logStart("Room Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1760,4 +1780,16 @@ public class RoomManager
|
|||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void registerGameType(Class<? extends Game> gameClass) {
|
||||||
|
gameTypes.add(gameClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unregisterGameType(Class<? extends Game> gameClass) {
|
||||||
|
gameTypes.remove(gameClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Class<? extends Game>> getGameTypes() {
|
||||||
|
return gameTypes;
|
||||||
|
}
|
||||||
}
|
}
|
@ -774,43 +774,6 @@ public class RoomSpecialTypes
|
|||||||
return this.gameTimers;
|
return this.gameTimers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public THashMap<Integer, InteractionFreezeTimer> getFreezeTimers()
|
|
||||||
{
|
|
||||||
synchronized (this.gameTimers)
|
|
||||||
{
|
|
||||||
THashMap<Integer, InteractionFreezeTimer> timers = new THashMap<>();
|
|
||||||
|
|
||||||
for (Map.Entry<Integer, InteractionGameTimer> set : this.gameTimers.entrySet())
|
|
||||||
{
|
|
||||||
if (set.getValue() instanceof InteractionFreezeTimer)
|
|
||||||
{
|
|
||||||
timers.put(set.getValue().getId(), (InteractionFreezeTimer) set.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return timers;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public THashMap<Integer, InteractionBattleBanzaiTimer> getBattleBanzaiTimers()
|
|
||||||
{
|
|
||||||
synchronized (this.gameTimers)
|
|
||||||
{
|
|
||||||
THashMap<Integer, InteractionBattleBanzaiTimer> timers = new THashMap<>();
|
|
||||||
|
|
||||||
for (Map.Entry<Integer, InteractionGameTimer> set : this.gameTimers.entrySet())
|
|
||||||
{
|
|
||||||
if (set.getValue() instanceof InteractionBattleBanzaiTimer)
|
|
||||||
{
|
|
||||||
timers.put(set.getValue().getId(), (InteractionBattleBanzaiTimer) set.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return timers;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public InteractionFreezeExitTile getFreezeExitTile()
|
public InteractionFreezeExitTile getFreezeExitTile()
|
||||||
{
|
{
|
||||||
for(InteractionFreezeExitTile t : this.freezeExitTile.values())
|
for(InteractionFreezeExitTile t : this.freezeExitTile.values())
|
||||||
|
@ -221,6 +221,10 @@ public abstract class HabboItem implements Runnable, IEventTriggers
|
|||||||
return this.needsUpdate;
|
return this.needsUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean needsDelete() {
|
||||||
|
return needsDelete;
|
||||||
|
}
|
||||||
|
|
||||||
public void needsUpdate(boolean value)
|
public void needsUpdate(boolean value)
|
||||||
{
|
{
|
||||||
this.needsUpdate = value;
|
this.needsUpdate = value;
|
||||||
|
Loading…
Reference in New Issue
Block a user