mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-12 20:34:36 +01:00
Vampire survivor now rewards the correct fate cards
This commit is contained in:
@@ -93,12 +93,15 @@ public class GameData {
|
||||
@Getter private static DataTable<PotentialDef> PotentialDataTable = new DataTable<>();
|
||||
@Getter private static DataTable<SubNoteSkillPromoteGroupDef> SubNoteSkillPromoteGroupDataTable = new DataTable<>();
|
||||
|
||||
@Getter private static DataTable<StarTowerBookFateCardBundleDef> StarTowerBookFateCardBundleDataTable = new DataTable<>();
|
||||
@Getter private static DataTable<StarTowerBookFateCardDef> StarTowerBookFateCardDataTable = new DataTable<>();
|
||||
@Getter private static DataTable<FateCardDef> FateCardDataTable = new DataTable<>();
|
||||
|
||||
// Infinity Tower
|
||||
@Getter private static DataTable<InfinityTowerLevelDef> InfinityTowerLevelDataTable = new DataTable<>();
|
||||
|
||||
// Vampire survivor
|
||||
@Getter private static DataTable<VampireSurvivorDef> VampireSurvivorDataTable = new DataTable<>();
|
||||
@Getter private static DataTable<FateCardDef> FateCardDataTable = new DataTable<>();
|
||||
|
||||
// Score boss
|
||||
@Getter private static DataTable<ScoreBossControlDef> ScoreBossControlDataTable = new DataTable<>();
|
||||
|
||||
@@ -2,7 +2,9 @@ package emu.nebula.data.resources;
|
||||
|
||||
import emu.nebula.data.BaseDef;
|
||||
import emu.nebula.data.ResourceType;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@ResourceType(name = "FateCard.json")
|
||||
@@ -14,6 +16,9 @@ public class FateCardDef extends BaseDef {
|
||||
private boolean IsVampireSpecial;
|
||||
private boolean Removable;
|
||||
|
||||
@Setter(AccessLevel.PROTECTED)
|
||||
private transient int bundleId;
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return Id;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package emu.nebula.data.resources;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import emu.nebula.data.BaseDef;
|
||||
import emu.nebula.data.ResourceType;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@ResourceType(name = "StarTowerBookFateCardBundle.json")
|
||||
public class StarTowerBookFateCardBundleDef extends BaseDef {
|
||||
private int Id;
|
||||
private int BundleId;
|
||||
|
||||
private transient List<FateCardDef> cards;
|
||||
|
||||
public StarTowerBookFateCardBundleDef() {
|
||||
this.cards = new ObjectArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return Id;
|
||||
}
|
||||
|
||||
protected void addCard(FateCardDef card) {
|
||||
this.getCards().add(card);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package emu.nebula.data.resources;
|
||||
|
||||
import emu.nebula.data.BaseDef;
|
||||
import emu.nebula.data.GameData;
|
||||
import emu.nebula.data.ResourceType;
|
||||
import emu.nebula.data.ResourceType.LoadPriority;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@ResourceType(name = "StarTowerBookFateCard.json", loadPriority = LoadPriority.LOW)
|
||||
public class StarTowerBookFateCardDef extends BaseDef {
|
||||
private int Id;
|
||||
private int BundleId;
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return Id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
// Set card bundle id
|
||||
var card = GameData.getFateCardDataTable().get(this.getId());
|
||||
if (card == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
card.setBundleId(this.BundleId);
|
||||
|
||||
// Add to bundle
|
||||
var bundle = GameData.getStarTowerBookFateCardBundleDataTable().get(this.getBundleId());
|
||||
if (bundle == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
bundle.addCard(card);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ public class VampireSurvivorDef extends BaseDef {
|
||||
private int Id;
|
||||
private int Mode;
|
||||
private int NeedWorldClass;
|
||||
private int[] FateCardBundle;
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package emu.nebula.game.vampire;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import emu.nebula.data.GameData;
|
||||
import emu.nebula.data.resources.FateCardDef;
|
||||
import emu.nebula.data.resources.VampireSurvivorDef;
|
||||
import emu.nebula.proto.Public.CardInfo;
|
||||
import emu.nebula.proto.Public.VampireSurvivorLevelReward;
|
||||
@@ -9,6 +12,7 @@ import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@@ -23,6 +27,9 @@ public class VampireSurvivorGame {
|
||||
private int rewardLevel;
|
||||
private IntList rewards;
|
||||
|
||||
// Cache
|
||||
private Set<FateCardDef> randomCards;
|
||||
|
||||
public VampireSurvivorGame(VampireSurvivorManager manager, VampireSurvivorDef data, long[] builds) {
|
||||
this.manager = manager;
|
||||
this.data = data;
|
||||
@@ -31,6 +38,10 @@ public class VampireSurvivorGame {
|
||||
this.cards = new IntOpenHashSet();
|
||||
this.rewards = new IntArrayList();
|
||||
|
||||
// Cache fate cards from bundles
|
||||
this.cacheRandomCards();
|
||||
|
||||
// Calculate next rewards
|
||||
this.calcRewards();
|
||||
}
|
||||
|
||||
@@ -38,15 +49,23 @@ public class VampireSurvivorGame {
|
||||
return this.getData().getId();
|
||||
}
|
||||
|
||||
private WeightedList<Integer> getRandom() {
|
||||
var random = new WeightedList<Integer>();
|
||||
private void cacheRandomCards() {
|
||||
this.randomCards = new ObjectOpenHashSet<>();
|
||||
|
||||
for (var card : GameData.getFateCardDataTable()) {
|
||||
// Filter only vampire surv cards
|
||||
if (!card.isIsVampire()) {
|
||||
for (int id : this.getData().getFateCardBundle()) {
|
||||
var bundle = GameData.getStarTowerBookFateCardBundleDataTable().get(id);
|
||||
if (bundle == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
this.getRandomCards().addAll(bundle.getCards());
|
||||
}
|
||||
}
|
||||
|
||||
private WeightedList<Integer> getRandom() {
|
||||
var random = new WeightedList<Integer>();
|
||||
|
||||
for (var card : this.getRandomCards()) {
|
||||
// Skip cards we already have
|
||||
if (this.getCards().contains(card.getId())) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user