mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-26 16:30:52 +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.habbohotel.achievements.AchievementManager;
|
||||
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.triggers.WiredTriggerTeamLoses;
|
||||
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 final Class<? extends GameTeam> gameTeamClazz;
|
||||
|
||||
|
||||
public final Class<? extends GamePlayer> gamePlayerClazz;
|
||||
private final Class<? extends GameTeam> gameTeamClazz;
|
||||
|
||||
private final Class<? extends GamePlayer> gamePlayerClazz;
|
||||
|
||||
protected final THashMap<GameTeamColors, GameTeam> teams = new THashMap<>();
|
||||
|
||||
|
||||
protected final Room room;
|
||||
|
||||
private final boolean countsAchievements;
|
||||
|
||||
protected final boolean countsAchievements;
|
||||
private int startTime;
|
||||
|
||||
|
||||
protected int startTime;
|
||||
|
||||
|
||||
protected int pauseTime;
|
||||
|
||||
|
||||
protected int endTime;
|
||||
private int endTime;
|
||||
|
||||
public boolean isRunning;
|
||||
|
||||
@ -132,6 +124,7 @@ public abstract class Game implements Runnable
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
boolean deleteGame = true;
|
||||
for (GameTeam team : this.teams.values())
|
||||
{
|
||||
@ -146,6 +139,7 @@ public abstract class Game implements Runnable
|
||||
{
|
||||
this.room.deleteGame(this);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@ -170,30 +164,7 @@ public abstract class Game implements Runnable
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
public void onEnd() {
|
||||
this.endTime = Emulator.getIntUnixTimestamp();
|
||||
|
||||
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))
|
||||
{
|
||||
Event gameStoppedEvent = new GameStoppedEvent(this);
|
||||
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()
|
||||
{
|
||||
return this.room;
|
||||
}
|
||||
|
||||
|
||||
public int getStartTime()
|
||||
{
|
||||
return this.startTime;
|
||||
}
|
||||
|
||||
|
||||
public int getEndTime()
|
||||
{
|
||||
return this.endTime;
|
||||
public Class<? extends GameTeam> getGameTeamClass() {
|
||||
return gameTeamClazz;
|
||||
}
|
||||
|
||||
public Class<? extends GamePlayer> getGamePlayerClass() {
|
||||
return gamePlayerClazz;
|
||||
}
|
||||
|
||||
public void addTime(int time)
|
||||
{
|
||||
this.endTime += time;
|
||||
public THashMap<GameTeamColors, GameTeam> getTeams() {
|
||||
return teams;
|
||||
}
|
||||
|
||||
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.habbohotel.achievements.AchievementManager;
|
||||
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.InteractionBattleBanzaiTile;
|
||||
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.users.Habbo;
|
||||
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.threading.runnables.BattleBanzaiTilesFlicker;
|
||||
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");
|
||||
|
||||
private int timeLeft;
|
||||
|
||||
private int tileCount;
|
||||
|
||||
private int countDown;
|
||||
@ -62,22 +63,10 @@ public class BattleBanzaiGame extends Game
|
||||
if(!this.state.equals(GameState.IDLE))
|
||||
return;
|
||||
|
||||
int highestTime = 0;
|
||||
this.countDown = 3;
|
||||
|
||||
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)
|
||||
{
|
||||
for (GameTeam t : this.teams.values())
|
||||
@ -92,13 +81,6 @@ public class BattleBanzaiGame extends Game
|
||||
this.room.updateItemState(item);
|
||||
}
|
||||
|
||||
this.timeLeft = highestTime;
|
||||
|
||||
if (this.timeLeft == 0)
|
||||
{
|
||||
this.timeLeft = 30;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (this.state.equals(GameState.PAUSED)) return;
|
||||
|
||||
this.timeLeft--;
|
||||
|
||||
for (Map.Entry<Integer, InteractionBattleBanzaiTimer> set : this.room.getRoomSpecialTypes().getBattleBanzaiTimers().entrySet())
|
||||
for (Map.Entry<GameTeamColors, THashSet<HabboItem>> set : this.lockedTiles.entrySet())
|
||||
{
|
||||
set.getValue().setExtradata(this.timeLeft + "");
|
||||
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;
|
||||
total += set.getValue().size();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
GameTeam highestScore = null;
|
||||
|
||||
synchronized (this.teams)
|
||||
{
|
||||
|
||||
GameTeam winningTeam = null;
|
||||
|
||||
for (GameTeam team : this.teams.values())
|
||||
for (Map.Entry<GameTeamColors, GameTeam> set : this.teams.entrySet())
|
||||
{
|
||||
for(GamePlayer player : team.getMembers())
|
||||
if (highestScore == null || highestScore.getTotalScore() < set.getValue().getTotalScore())
|
||||
{
|
||||
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;
|
||||
highestScore = set.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (winningTeam != null)
|
||||
if(highestScore != null)
|
||||
{
|
||||
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class))
|
||||
{
|
||||
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));
|
||||
item.setExtradata((highestScore.teamColor.type + 3) + "");
|
||||
this.room.updateItemState(item);
|
||||
}
|
||||
|
||||
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)
|
||||
@ -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
|
||||
public void stop()
|
||||
{
|
||||
super.stop();
|
||||
|
||||
this.timeLeft = 0;
|
||||
|
||||
this.refreshGates();
|
||||
|
||||
for (HabboItem tile : this.gameTiles.values())
|
||||
@ -265,7 +240,7 @@ public class BattleBanzaiGame extends Game
|
||||
if (tile.getExtradata().equals("1"))
|
||||
{
|
||||
tile.setExtradata("0");
|
||||
this.room.updateItemState(tile);
|
||||
this.room.updateItem(tile);
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
|
@ -4,6 +4,8 @@ import com.eu.habbo.habbohotel.games.Game;
|
||||
import com.eu.habbo.habbohotel.games.GamePlayer;
|
||||
import com.eu.habbo.habbohotel.games.GameTeam;
|
||||
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
|
||||
{
|
||||
@ -24,14 +26,17 @@ public class BattleBanzaiGameTeam extends GameTeam
|
||||
public void removeMember(GamePlayer gamePlayer)
|
||||
{
|
||||
Game game = gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().getGame(gamePlayer.getHabbo().getHabboInfo().getCurrentGame());
|
||||
if(game instanceof BattleBanzaiGame)
|
||||
{
|
||||
((BattleBanzaiGame) game).addPositionToGate(gamePlayer.getTeamColor());
|
||||
}
|
||||
Room room = gamePlayer.getHabbo().getRoomUnit().getRoom();
|
||||
|
||||
gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), 0, -1);
|
||||
gamePlayer.getHabbo().getRoomUnit().setCanWalk(true);
|
||||
|
||||
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.gates.InteractionFreezeGate;
|
||||
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.RoomLayout;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
@ -45,8 +46,6 @@ public class FreezeGame extends Game
|
||||
public static int FREEZE_LOOSE_POINTS;
|
||||
public static boolean POWERUP_STACK;
|
||||
|
||||
private int timeLeft;
|
||||
|
||||
public FreezeGame(Room room)
|
||||
{
|
||||
super(FreezeGameTeam.class, FreezeGamePlayer.class, room, true);
|
||||
@ -59,49 +58,13 @@ public class FreezeGame extends Game
|
||||
if(this.state == GameState.RUNNING)
|
||||
return;
|
||||
|
||||
int highestTime = 0;
|
||||
|
||||
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())
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
@ -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)
|
||||
{
|
||||
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();
|
||||
|
||||
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();
|
||||
|
||||
WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, this.room, null);
|
||||
this.setFreezeTileState("1");
|
||||
this.run();
|
||||
}
|
||||
@ -295,50 +259,36 @@ public class FreezeGame extends Game
|
||||
if (this.state.equals(GameState.IDLE))
|
||||
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);
|
||||
|
||||
if (this.state.equals(GameState.PAUSED)) return;
|
||||
|
||||
this.timeLeft--;
|
||||
|
||||
for (GameTeam team : this.teams.values())
|
||||
for (GamePlayer player : team.getMembers())
|
||||
{
|
||||
for (GamePlayer player : team.getMembers())
|
||||
{
|
||||
((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);
|
||||
}
|
||||
((FreezeGamePlayer)player).cycle();
|
||||
}
|
||||
|
||||
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 + "");
|
||||
this.room.updateItemState(set.getValue());
|
||||
if(scoreboard.getExtradata().isEmpty())
|
||||
{
|
||||
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)
|
||||
@ -352,8 +302,6 @@ public class FreezeGame extends Game
|
||||
{
|
||||
super.stop();
|
||||
|
||||
this.timeLeft = 0;
|
||||
|
||||
GameTeam winningTeam = null;
|
||||
|
||||
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.GameTeam;
|
||||
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
|
||||
{
|
||||
@ -16,15 +18,18 @@ public class FreezeGameTeam extends GameTeam
|
||||
public void removeMember(GamePlayer gamePlayer)
|
||||
{
|
||||
Game game = gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().getGame(FreezeGame.class);
|
||||
if(game instanceof FreezeGame)
|
||||
{
|
||||
((FreezeGame) game).placebackHelmet(gamePlayer.getTeamColor());
|
||||
}
|
||||
Room room = gamePlayer.getHabbo().getRoomUnit().getRoom();
|
||||
|
||||
gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), 0, -1);
|
||||
gamePlayer.getHabbo().getRoomUnit().setCanWalk(true);
|
||||
|
||||
super.removeMember(gamePlayer);
|
||||
|
||||
if(room != null && room.getRoomSpecialTypes() != null) {
|
||||
for (InteractionGameGate gate : room.getRoomSpecialTypes().getFreezeGates().values()) {
|
||||
gate.updateState(game, 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,51 +14,19 @@ import java.util.Map;
|
||||
|
||||
public class WiredGame extends Game
|
||||
{
|
||||
private int timeLeft = 30;
|
||||
public WiredGame(Room room)
|
||||
{
|
||||
super(GameTeam.class, GamePlayer.class, room , false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialise()
|
||||
{
|
||||
for (Map.Entry<Integer, InteractionGameTimer> set : this.room.getRoomSpecialTypes().getGameTimers().entrySet())
|
||||
{
|
||||
if(set.getValue().getExtradata().isEmpty())
|
||||
continue;
|
||||
public void initialise() {
|
||||
|
||||
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
|
||||
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();
|
||||
}
|
||||
public void run() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,6 @@
|
||||
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.items.Item;
|
||||
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
|
||||
{
|
||||
super(set, baseItem, teamColor);
|
||||
this.setExtradata("0");
|
||||
}
|
||||
|
||||
public InteractionGameGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor)
|
||||
{
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells, teamColor);
|
||||
this.setExtradata("0");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -41,4 +44,13 @@ public abstract class InteractionGameGate extends InteractionGameTeamItem
|
||||
|
||||
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.games.Game;
|
||||
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.items.Item;
|
||||
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.users.HabboItem;
|
||||
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 java.lang.reflect.InvocationTargetException;
|
||||
import java.sql.ResultSet;
|
||||
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 lastToggle = 0;
|
||||
private int timeNow = 0;
|
||||
private boolean isRunning = false;
|
||||
private boolean isPaused = false;
|
||||
|
||||
public InteractionGameTimer(ResultSet set, Item baseItem) throws SQLException
|
||||
{
|
||||
@ -30,6 +39,7 @@ public abstract class InteractionGameTimer extends HabboItem
|
||||
if (data.length >= 2)
|
||||
{
|
||||
this.baseTime = Integer.valueOf(data[1]);
|
||||
this.timeNow = this.baseTime;
|
||||
}
|
||||
|
||||
if (data.length >= 1)
|
||||
@ -43,6 +53,67 @@ public abstract class InteractionGameTimer extends HabboItem
|
||||
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
|
||||
public void onPickUp(Room room)
|
||||
{
|
||||
@ -52,8 +123,12 @@ public abstract class InteractionGameTimer extends HabboItem
|
||||
@Override
|
||||
public void onPlace(Room room)
|
||||
{
|
||||
this.baseTime = 30;
|
||||
this.setExtradata("30");
|
||||
if(this.baseTime == 0) {
|
||||
this.baseTime = 30;
|
||||
this.timeNow = this.baseTime;
|
||||
}
|
||||
|
||||
this.setExtradata(this.timeNow + "\t" + this.baseTime);
|
||||
room.updateItem(this);
|
||||
}
|
||||
|
||||
@ -61,7 +136,7 @@ public abstract class InteractionGameTimer extends HabboItem
|
||||
public void serializeExtradata(ServerMessage serverMessage)
|
||||
{
|
||||
serverMessage.appendInt((this.isLimited() ? 256 : 0));
|
||||
serverMessage.appendString(this.getExtradata());
|
||||
serverMessage.appendString("" + timeNow);
|
||||
|
||||
super.serializeExtradata(serverMessage);
|
||||
}
|
||||
@ -81,65 +156,123 @@ public abstract class InteractionGameTimer extends HabboItem
|
||||
@Override
|
||||
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())
|
||||
{
|
||||
this.setExtradata("0");
|
||||
}
|
||||
|
||||
Game game = this.getOrCreateGame(room);
|
||||
|
||||
if ((objects.length >= 2 && objects[1] instanceof WiredEffectType))
|
||||
// if wired triggered it
|
||||
if (objects.length >= 2 && objects[1] instanceof WiredEffectType && !this.isRunning)
|
||||
{
|
||||
if (game == null || !game.isRunning)
|
||||
startGame(room);
|
||||
else if (game.isRunning)
|
||||
stopGame(room);
|
||||
endGamesIfLastTimer(room);
|
||||
|
||||
for(Class<? extends Game> gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) {
|
||||
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);
|
||||
}
|
||||
|
||||
if(objects.length >= 1 && objects[0] instanceof Integer && client != null)
|
||||
else if(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)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
this.startGame(room);
|
||||
if(this.isRunning) {
|
||||
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;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
this.increaseTimer(room);
|
||||
}
|
||||
break;
|
||||
if(!this.isRunning) {
|
||||
this.increaseTimer(room);
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.isPaused) {
|
||||
this.isPaused = false;
|
||||
this.isRunning = false;
|
||||
|
||||
timeNow = this.baseTime;
|
||||
room.updateItem(this);
|
||||
|
||||
endGamesIfLastTimer(room);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 3:
|
||||
{
|
||||
this.stopGame(room);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (game != null && game.state.equals(GameState.IDLE))
|
||||
{
|
||||
this.startGame(room);
|
||||
this.isPaused = false;
|
||||
this.isRunning = false;
|
||||
|
||||
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)
|
||||
{
|
||||
try
|
||||
{
|
||||
game = this.getGameType().getDeclaredConstructor(Room.class).newInstance(room);
|
||||
if (game == null) {
|
||||
try {
|
||||
System.out.println(gameClass.getName());
|
||||
game = gameClass.getDeclaredConstructor(Room.class).newInstance(room);
|
||||
room.addGame(game);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
} catch (Exception e) {
|
||||
Emulator.getLogging().logErrorLine(e);
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
Game game = this.getOrCreateGame(room);
|
||||
|
||||
if (game == null) return;
|
||||
if (game.state.equals(GameState.PAUSED))
|
||||
{
|
||||
stopGame(room);
|
||||
if(this.isRunning)
|
||||
return;
|
||||
}
|
||||
if (game.state.equals(GameState.RUNNING)) return;
|
||||
|
||||
this.needsUpdate(true);
|
||||
|
||||
switch(this.baseTime)
|
||||
{
|
||||
case 0: this.baseTime = 30; break;
|
||||
@ -247,9 +323,9 @@ public abstract class InteractionGameTimer extends HabboItem
|
||||
this.baseTime = 30;
|
||||
}
|
||||
|
||||
this.setExtradata(this.baseTime + "");
|
||||
|
||||
this.timeNow = this.baseTime;
|
||||
room.updateItem(this);
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -265,4 +341,20 @@ public abstract class InteractionGameTimer extends HabboItem
|
||||
{
|
||||
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;
|
||||
|
||||
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.GameTeam;
|
||||
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.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@ -67,18 +69,11 @@ public class InteractionBattleBanzaiGate extends InteractionGameGate
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
updateState(game, 5);
|
||||
|
||||
super.onWalkOn(roomUnit, room, objects);
|
||||
}
|
||||
}
|
||||
|
@ -66,18 +66,11 @@ public class InteractionFreezeGate extends InteractionGameGate
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
updateState(game, 5);
|
||||
|
||||
super.onWalkOn(roomUnit, room, objects);
|
||||
}
|
||||
}
|
||||
|
@ -94,11 +94,8 @@ public class WiredEffectBotTalk extends InteractionWiredEffect
|
||||
}
|
||||
List<Bot> bots = room.getBots(this.botName);
|
||||
|
||||
int now = Emulator.getIntUnixTimestamp();
|
||||
for(Bot bot : bots)
|
||||
{
|
||||
if (now - bot.getChatTimestamp() < bot.getChatDelay()) continue;
|
||||
|
||||
if(this.mode == 1)
|
||||
bot.shout(message);
|
||||
else
|
||||
|
@ -119,6 +119,50 @@ public class WiredEffectTeleport extends InteractionWiredEffect
|
||||
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
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff)
|
||||
{
|
||||
@ -146,52 +190,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect
|
||||
tryCount++;
|
||||
HabboItem item = this.items.get((tryCount - 1 + i) % this.items.size());
|
||||
|
||||
int currentEffect = roomUnit.getEffectId();
|
||||
|
||||
// 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);
|
||||
teleportUnitToTile(roomUnit, room.getLayout().getTile(item.getX(), item.getY()));
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -1013,6 +1013,10 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
|
||||
this.mutedHabbos.clear();
|
||||
}
|
||||
|
||||
for(InteractionGameTimer timer : this.getRoomSpecialTypes().getGameTimers().values()) {
|
||||
timer.setRunning(false);
|
||||
}
|
||||
|
||||
for (Game game : this.games)
|
||||
{
|
||||
game.stop();
|
||||
|
@ -4,6 +4,15 @@ import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.core.RoomUserPetComposer;
|
||||
import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
||||
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.items.interactions.InteractionWired;
|
||||
import com.eu.habbo.habbohotel.messenger.MessengerBuddy;
|
||||
@ -57,6 +66,7 @@ public class RoomManager
|
||||
private final THashMap<Integer, RoomCategory> roomCategories;
|
||||
private final List<String> mapNames;
|
||||
private final ConcurrentHashMap<Integer, Room> activeRooms;
|
||||
private final ArrayList<Class<? extends Game>> gameTypes;
|
||||
|
||||
public RoomManager()
|
||||
{
|
||||
@ -67,6 +77,16 @@ public class RoomManager
|
||||
this.loadRoomCategories();
|
||||
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)");
|
||||
}
|
||||
|
||||
@ -1760,4 +1780,16 @@ public class RoomManager
|
||||
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;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
for(InteractionFreezeExitTile t : this.freezeExitTile.values())
|
||||
|
@ -221,6 +221,10 @@ public abstract class HabboItem implements Runnable, IEventTriggers
|
||||
return this.needsUpdate;
|
||||
}
|
||||
|
||||
public boolean needsDelete() {
|
||||
return needsDelete;
|
||||
}
|
||||
|
||||
public void needsUpdate(boolean value)
|
||||
{
|
||||
this.needsUpdate = value;
|
||||
|
Loading…
Reference in New Issue
Block a user