Rewrite MonsterBook, touch up chr loading

Temporarily disabled loading monster cards from db
This commit is contained in:
P0nk
2023-07-25 21:27:10 +02:00
parent b3ec325e95
commit f6aa8ceba6
7 changed files with 165 additions and 259 deletions

View File

@@ -1,12 +1,15 @@
package database.monsterbook;
import constants.id.ItemId;
public record MonsterCard(int cardId, byte level) {
private static final int MAX_LEVEL = 5;
public MonsterCard {
if (cardId / 10_000 != 238) {
if (!ItemId.isMonsterCard(cardId)) {
throw new IllegalArgumentException("Invalid monster card id: %d".formatted(cardId));
}
if (level < 0 || level > 5) {
if (level < 0 || level > MAX_LEVEL) {
throw new IllegalArgumentException("Invalid monster card level: %d".formatted(level));
}
}
@@ -14,4 +17,8 @@ public record MonsterCard(int cardId, byte level) {
public boolean isSpecial() {
return cardId / 1000 == 2388;
}
public boolean isMaxLevel() {
return level == MAX_LEVEL;
}
}