mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-15 05:44:36 +01:00
Fix basic trials not rewarding materials
This commit is contained in:
@@ -15,6 +15,14 @@ public interface InstanceData {
|
||||
|
||||
public ItemParamMap getRewards();
|
||||
|
||||
public default ItemParamMap getFirstRewards(int rewardType) {
|
||||
return this.getFirstRewards();
|
||||
}
|
||||
|
||||
public default ItemParamMap getRewards(int rewardType) {
|
||||
return this.getRewards();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the player has enough energy to complete this instance
|
||||
* @return true if the player has enough energy
|
||||
|
||||
@@ -19,7 +19,6 @@ import emu.nebula.proto.Public.WeekBossLevel;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Entity(value = "instances", useDiscriminator = false)
|
||||
@@ -33,8 +32,8 @@ public class InstanceManager extends PlayerManager implements GameDatabaseObject
|
||||
private Int2IntMap charGemLog;
|
||||
private Int2IntMap weekBossLog;
|
||||
|
||||
@Setter
|
||||
private transient int curInstanceId;
|
||||
private transient int rewardType;
|
||||
|
||||
@Deprecated // Morphia
|
||||
public InstanceManager() {
|
||||
@@ -54,6 +53,15 @@ public class InstanceManager extends PlayerManager implements GameDatabaseObject
|
||||
this.save();
|
||||
}
|
||||
|
||||
public void setCurInstanceId(int id) {
|
||||
this.setCurInstanceId(id, 0);
|
||||
}
|
||||
|
||||
public void setCurInstanceId(int id, int rewardType) {
|
||||
this.curInstanceId = id;
|
||||
this.rewardType = rewardType;
|
||||
}
|
||||
|
||||
public void saveInstanceLog(Int2IntMap log, String logName, int id, int newStar) {
|
||||
// Get current star
|
||||
int star = log.get(id);
|
||||
|
||||
@@ -197,6 +197,12 @@ public class Inventory extends PlayerManager {
|
||||
changes = new PlayerChangeInfo();
|
||||
}
|
||||
|
||||
// Sanity
|
||||
if (params == null || params.isEmpty()) {
|
||||
return changes;
|
||||
}
|
||||
|
||||
// Add items
|
||||
for (var param : params.getEntrySet()) {
|
||||
this.addItem(param.getIntKey(), param.getIntValue(), changes);
|
||||
}
|
||||
@@ -222,6 +228,12 @@ public class Inventory extends PlayerManager {
|
||||
changes = new PlayerChangeInfo();
|
||||
}
|
||||
|
||||
// Sanity
|
||||
if (params == null || params.isEmpty()) {
|
||||
return changes;
|
||||
}
|
||||
|
||||
// Remove items
|
||||
for (var param : params.getEntrySet()) {
|
||||
this.removeItem(param.getIntKey(), param.getIntValue(), changes);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import emu.nebula.proto.Public.Item;
|
||||
import emu.nebula.proto.Public.ItemInfo;
|
||||
import emu.nebula.proto.Public.ItemTpl;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
@@ -60,6 +61,8 @@ public class ItemParamMap extends Int2IntOpenHashMap {
|
||||
return this.int2IntEntrySet();
|
||||
}
|
||||
|
||||
// Converters (lists/streams)
|
||||
|
||||
public List<ItemParam> toList() {
|
||||
List<ItemParam> list = new ArrayList<>();
|
||||
|
||||
@@ -76,6 +79,12 @@ public class ItemParamMap extends Int2IntOpenHashMap {
|
||||
.map(e -> ItemTpl.newInstance().setTid(e.getIntKey()).setQty(e.getIntValue()));
|
||||
}
|
||||
|
||||
public Stream<Item> toItemProtoStream() {
|
||||
return getEntrySet()
|
||||
.stream()
|
||||
.map(e -> Item.newInstance().setTid(e.getIntKey()).setQty(e.getIntValue()));
|
||||
}
|
||||
|
||||
// Helpers
|
||||
|
||||
public static ItemParamMap fromTemplates(RepeatedMessage<ItemTpl> items) {
|
||||
|
||||
Reference in New Issue
Block a user