Arcturus-Community/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java

86 lines
2.4 KiB
Java
Raw Normal View History

2020-02-06 13:01:21 +01:00
package com.eu.habbo.habbohotel.items.interactions.pets;
2018-07-06 15:30:00 +02:00
2019-03-18 02:22:00 +01:00
import com.eu.habbo.Emulator;
2018-07-06 15:30:00 +02:00
import com.eu.habbo.habbohotel.gameclients.GameClient;
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.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
2019-05-26 20:14:53 +02:00
public class InteractionMonsterPlantSeed extends HabboItem {
public InteractionMonsterPlantSeed(ResultSet set, Item baseItem) throws SQLException {
2018-07-06 15:30:00 +02:00
super(set, baseItem);
2019-03-18 02:22:00 +01:00
2019-05-26 20:14:53 +02:00
if (this.getExtradata().isEmpty()) {
2019-03-18 02:22:00 +01:00
this.setExtradata("" + randomRarityLevel());
this.needsUpdate(true);
}
2018-07-06 15:30:00 +02:00
}
2019-05-26 20:14:53 +02:00
public InteractionMonsterPlantSeed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
2018-07-06 15:30:00 +02:00
super(id, userId, item, extradata, limitedStack, limitedSells);
2019-03-18 02:22:00 +01:00
2019-05-26 20:14:53 +02:00
if (this.getExtradata().isEmpty()) {
2019-03-18 02:22:00 +01:00
this.setExtradata("" + randomRarityLevel());
this.needsUpdate(true);
}
2018-07-06 15:30:00 +02:00
}
public static int randomGoldenRarityLevel() {
int number = Emulator.getRandom().nextInt(66);
int count = 0;
for (int i = 8; i < 11; i++) {
count += 11 - i;
if (number <= count) {
return i;
}
}
return 10;
}
2019-05-26 20:14:53 +02:00
public static int randomRarityLevel() {
int number = Emulator.getRandom().nextInt(66);
int count = 0;
for (int i = 1; i < 11; i++) {
2019-05-26 20:14:53 +02:00
count += 11 - i;
if (number <= count) {
return i;
}
}
return 10;
}
2018-07-06 15:30:00 +02:00
@Override
2019-05-26 20:14:53 +02:00
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
2018-07-06 15:30:00 +02:00
}
@Override
2019-05-26 20:14:53 +02:00
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
2018-07-06 15:30:00 +02:00
return false;
}
@Override
2019-05-26 20:14:53 +02:00
public boolean isWalkable() {
2018-07-06 15:30:00 +02:00
return false;
}
@Override
2019-05-26 20:14:53 +02:00
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
2018-07-06 15:30:00 +02:00
}
@Override
2019-05-26 20:14:53 +02:00
public void serializeExtradata(ServerMessage serverMessage) {
2019-03-18 02:22:00 +01:00
serverMessage.appendInt(1 + (this.isLimited() ? 256 : 0));
serverMessage.appendInt(1);
serverMessage.appendString("rarity");
2018-07-06 15:30:00 +02:00
serverMessage.appendString(this.getExtradata());
super.serializeExtradata(serverMessage);
}
}