Fix cataclysm survivor score calculation

This commit is contained in:
Melledy
2025-11-21 20:36:35 -08:00
parent e8a3576d8b
commit 3059c549d5
6 changed files with 155 additions and 19 deletions
@@ -0,0 +1,82 @@
package emu.nebula.game.vampire;
import java.util.stream.IntStream;
import emu.nebula.GameConstants;
import emu.nebula.data.resources.VampireSurvivorDef;
import emu.nebula.proto.VampireSurvivorSettle.VampireSurvivorAreaInfo;
import lombok.Getter;
@Getter
public class VampireSurvivorArea {
private final VampireSurvivorGame game;
private int time;
private int score;
private int[] killCount;
private int[] killScore;
public VampireSurvivorArea(VampireSurvivorGame game, int time, int[] killCount) {
this.game = game;
this.time = time;
this.calcScore(killCount);
}
private VampireSurvivorDef getData() {
return this.getGame().getData();
}
private void calcScore(int[] killCount) {
// Set kill count/score
this.killCount = killCount;
this.killScore = new int[killCount.length];
// Check size for kill counter array
int maxSize = 4 + (GameConstants.VAMPIRE_SURVIVOR_BONUS_POWER.length * 2);
if (killCount.length < maxSize) {
return;
}
// Calculate
killScore[0] = killCount[0] * this.getData().getNormalScore1(); // Monster
killScore[1] = killCount[1] * this.getData().getEliteScore1(); // Elite monster
killScore[2] = killCount[2] * this.getData().getEliteScore1(); // Lord
killScore[3] = this.getData().getBossScore1(); // Boss
int offset = 4;
for (int i = 0; i < GameConstants.VAMPIRE_SURVIVOR_BONUS_POWER.length; i++, offset++) {
int bonusKill = killCount[offset];
int bonusPower = GameConstants.VAMPIRE_SURVIVOR_BONUS_POWER[i][1];
double mod = (bonusPower - 100) / 100D;
killScore[offset] = (int) (bonusKill * mod * this.getData().getNormalScore1());
}
for (int i = 0; i < GameConstants.VAMPIRE_SURVIVOR_BONUS_POWER.length; i++, offset++) {
int bonusKill = killCount[offset];
int bonusPower = GameConstants.VAMPIRE_SURVIVOR_BONUS_POWER[i][1];
double mod = (bonusPower - 100) / 100D;
killScore[offset] = (int) (bonusKill * mod * this.getData().getEliteScore1());
}
// Get final score
this.score = IntStream.of(killScore).sum();
}
// Proto
public VampireSurvivorAreaInfo toProto() {
var proto = VampireSurvivorAreaInfo.newInstance()
.setBossTime(this.getTime())
.setScore(this.getScore())
.addAllKillCount(this.getKillCount())
.addAllKillScore(this.getKillScore());
return proto;
}
}
@@ -1,5 +1,6 @@
package emu.nebula.game.vampire;
import java.util.List;
import java.util.Set;
import emu.nebula.data.GameData;
@@ -8,10 +9,12 @@ import emu.nebula.data.resources.VampireSurvivorDef;
import emu.nebula.proto.Public.CardInfo;
import emu.nebula.proto.Public.VampireSurvivorLevelReward;
import emu.nebula.util.WeightedList;
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.ObjectArrayList;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import lombok.Getter;
@@ -27,6 +30,9 @@ public class VampireSurvivorGame {
private int rewardLevel;
private IntList rewards;
// Areas
private List<VampireSurvivorArea> areas;
// Cache
private Set<FateCardDef> randomCards;
@@ -37,6 +43,7 @@ public class VampireSurvivorGame {
this.cards = new IntOpenHashSet();
this.rewards = new IntArrayList();
this.areas = new ObjectArrayList<>();
// Cache fate cards from bundles
this.cacheRandomCards();
@@ -48,6 +55,16 @@ public class VampireSurvivorGame {
public int getId() {
return this.getData().getId();
}
public int getTotalScore() {
int score = 0;
for (var area : this.getAreas()) {
score += area.getScore();
}
return score;
}
public boolean isNewCard(int id) {
return !this.getManager().getProgress().getFateCards().contains(id);
@@ -147,6 +164,17 @@ public class VampireSurvivorGame {
return chest;
}
public VampireSurvivorArea settleArea(int time, int[] killCount) {
// Create area
var area = new VampireSurvivorArea(this, time, killCount);
// Add to areas list
this.getAreas().add(area);
// Success
return area;
}
// Proto
public VampireSurvivorLevelReward getRewardProto() {