mirror of
https://github.com/Melledy/Nebula.git
synced 2026-11-04 21:36:51 +01:00
Fix dorm furniture set reward not working if the furniture was placed
This commit is contained in:
1 parent
787bb6a286
commit
d62ec2f2a9
2 files changed
+45
-11
No files matched your search
@@ -26,6 +26,7 @@ public class GameConstants {
|
||||
public static final int EXP_ITEM_ID = 21;
|
||||
public static final int WEEKLY_ENTRY_ITEM_ID = 28;
|
||||
public static final int JOINT_DRILL_TICKET_ID = 36;
|
||||
public static final int DORM_FURNITURE_COIN_ID = 701;
|
||||
|
||||
// Energy
|
||||
public static final int MAX_ENERGY = 240;
|
||||
@@ -87,8 +88,6 @@ public class GameConstants {
|
||||
public static final int DORM_LIKE_LIMIT = 3;
|
||||
public static final int DORM_BLOCKS_CONVERT_PROP = 1;
|
||||
public static final int DORM_DEFAULT_ROOM_ID = 701001;
|
||||
public static final int DORM_JADE_ITEM_ID = 2;
|
||||
public static final int DORM_FURNITURE_COIN_ITEM_ID = 701;
|
||||
public static final int DORM_MAX_NAME_LENGTH = 20;
|
||||
|
||||
// Etc
|
||||
|
||||
@@ -685,18 +685,18 @@ public class DormManager extends PlayerManager implements GameDatabaseObject {
|
||||
|
||||
var inventory = this.getPlayer().getInventory();
|
||||
|
||||
if (inventory.getItemCount(GameConstants.DORM_JADE_ITEM_ID) < count) {
|
||||
if (inventory.getItemCount(GameConstants.STELLANITE_DUST_ITEM_ID) < count) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var change = new PlayerChangeInfo();
|
||||
|
||||
// Remove jade and add furniture coins
|
||||
inventory.removeItem(GameConstants.DORM_JADE_ITEM_ID, count, change);
|
||||
// Remove stellanite dust and add furniture coins
|
||||
inventory.removeItem(GameConstants.STELLANITE_DUST_ITEM_ID, count, change);
|
||||
inventory.addItem(
|
||||
GameConstants.DORM_FURNITURE_COIN_ITEM_ID,
|
||||
count * GameConstants.DORM_BLOCKS_CONVERT_PROP,
|
||||
change
|
||||
GameConstants.DORM_FURNITURE_COIN_ID,
|
||||
count * GameConstants.DORM_BLOCKS_CONVERT_PROP,
|
||||
change
|
||||
);
|
||||
|
||||
return change;
|
||||
@@ -721,7 +721,7 @@ public class DormManager extends PlayerManager implements GameDatabaseObject {
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean isLayoutRewardClaimable(int layoutId) {
|
||||
public boolean isLayoutRewardClaimable(ItemParamMap totalFurniture, int layoutId) {
|
||||
var data = GameData.getDormLayoutRewardDataTable().get(layoutId);
|
||||
if (data == null || data.getRewardId1() <= 0 || data.getQty1() <= 0) {
|
||||
return false;
|
||||
@@ -741,7 +741,8 @@ public class DormManager extends PlayerManager implements GameDatabaseObject {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.getFurnitureCount(layout.getFurnitureId()) < required) {
|
||||
int owned = totalFurniture.get(layout.getFurnitureId());
|
||||
if (owned < required) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -750,18 +751,48 @@ public class DormManager extends PlayerManager implements GameDatabaseObject {
|
||||
}
|
||||
|
||||
public synchronized PlayerChangeInfo receiveLayoutRewards(int[] layoutIds) {
|
||||
// Init variables
|
||||
var change = new PlayerChangeInfo();
|
||||
var rewards = new ItemParamMap();
|
||||
boolean received = false;
|
||||
|
||||
// Get total furniture, including the ones in rooms
|
||||
var totalFurniture = new ItemParamMap();
|
||||
|
||||
// Adds furniture from our collection
|
||||
totalFurniture.putAll(this.getFurnitureCollection());
|
||||
|
||||
// Adds the furniture currently placed in rooms
|
||||
for (var room : this.getRooms().values()) {
|
||||
if (room.getFurnitureList() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (var furniture : room.getFurnitureList()) {
|
||||
totalFurniture.add(furniture.getFurnitureId(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we can recieve layouts
|
||||
for (int layoutId : layoutIds) {
|
||||
if (this.receivedLayoutRewardIds.contains(layoutId) || !this.isLayoutRewardClaimable(layoutId)) {
|
||||
if (this.receivedLayoutRewardIds.contains(layoutId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!this.isLayoutRewardClaimable(totalFurniture, layoutId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var data = GameData.getDormLayoutRewardDataTable().get(layoutId);
|
||||
if (data == null) continue;
|
||||
|
||||
// Add rewards
|
||||
rewards.add(data.getRewardId1(), data.getQty1());
|
||||
|
||||
// Add to received layout ids
|
||||
this.receivedLayoutRewardIds.add(layoutId);
|
||||
|
||||
// Set recieved flag
|
||||
received = true;
|
||||
}
|
||||
|
||||
@@ -769,10 +800,14 @@ public class DormManager extends PlayerManager implements GameDatabaseObject {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Add rewards and trigger quest
|
||||
this.getPlayer().getInventory().addItems(rewards, change);
|
||||
this.getPlayer().trigger(QuestCondition.DormRewardReceive, 1);
|
||||
|
||||
// Queue a save call for the dorm
|
||||
this.queueSave = true;
|
||||
|
||||
// Success
|
||||
return change;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user