Arcturus-Community/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameGate.java

56 lines
1.8 KiB
Java
Raw Normal View History

2018-07-06 15:30:00 +02:00
package com.eu.habbo.habbohotel.items.interactions.games;
2019-05-05 04:51:27 +02:00
import com.eu.habbo.habbohotel.games.Game;
2018-07-06 15:30:00 +02:00
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
2019-05-26 20:14:53 +02:00
public abstract class InteractionGameGate extends InteractionGameTeamItem {
public InteractionGameGate(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException {
2018-07-06 15:30:00 +02:00
super(set, baseItem, teamColor);
2019-05-05 04:51:27 +02:00
this.setExtradata("0");
2018-07-06 15:30:00 +02:00
}
2019-05-26 20:14:53 +02:00
public InteractionGameGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) {
2018-07-06 15:30:00 +02:00
super(id, userId, item, extradata, limitedStack, limitedSells, teamColor);
2019-05-05 04:51:27 +02:00
this.setExtradata("0");
2018-07-06 15:30:00 +02:00
}
@Override
2019-05-26 20:14:53 +02:00
public void onPickUp(Room room) {
2018-07-06 15:30:00 +02:00
this.setExtradata("0");
}
@Override
2019-05-26 20:14:53 +02:00
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
2018-07-06 15:30:00 +02:00
super.onWalkOn(roomUnit, room, objects);
}
@Override
2019-05-26 20:14:53 +02:00
public void serializeExtradata(ServerMessage serverMessage) {
2018-07-06 15:30:00 +02:00
serverMessage.appendInt((this.isLimited() ? 256 : 0));
serverMessage.appendString(this.getExtradata());
super.serializeExtradata(serverMessage);
}
2019-05-05 04:51:27 +02:00
public void updateState(Game game, int maxPlayers) {
int memberCount = 0;
2019-05-26 20:14:53 +02:00
if (game.getTeam(this.teamColor) != null) {
memberCount = game.getTeam(this.teamColor).getMembers().size();
}
2019-05-26 20:14:53 +02:00
if (memberCount > maxPlayers) {
2019-05-05 04:51:27 +02:00
memberCount = maxPlayers;
}
this.setExtradata(memberCount + "");
game.getRoom().updateItem(this);
}
2018-07-06 15:30:00 +02:00
}