Fix some techniques not applying debuffs to monsters in battle

This commit is contained in:
Melledy
2024-07-31 20:42:48 -07:00
parent a7df1e78ba
commit b2718432cb
2 changed files with 11 additions and 11 deletions

View File

@@ -128,7 +128,10 @@ public class Battle {
var wave = new BattleMonsterWave(stage);
wave.getMonsters().addAll(stageMonsterWave);
// Handle npc monster
// Add wave to battle
this.getWaves().add(wave);
// Add buffs from npc monsters
if (npcMonster != null) {
// Set wave custom level
wave.setCustomLevel(npcMonster.getCustomLevel());
@@ -136,9 +139,6 @@ public class Battle {
// Handle monster buffs
npcMonster.applyBuffs(this, this.getWaves().size());
}
// Finally add wave to battle
this.getWaves().add(wave);
}
}
@@ -247,8 +247,8 @@ public class Battle {
}
// Buffs
for (var entry : this.getBuffs().int2ObjectEntrySet()) {
proto.addBuffList(entry.getValue().toProto());
for (var buff : this.getBuffs().values()) {
proto.addBuffList(buff.toProto());
}
// Client turn snapshots

View File

@@ -99,7 +99,7 @@ public class EntityMonster implements GameEntity, Tickable {
this.tempBuffs.add(tempBuff);
}
public synchronized void applyBuffs(Battle battle, int waveIndex) {
public synchronized void applyBuffs(Battle battle, int waveNum) {
if (this.buffs != null) {
for (var entry : this.buffs.int2ObjectEntrySet()) {
// Check expiry for buff
@@ -108,26 +108,26 @@ public class EntityMonster implements GameEntity, Tickable {
}
// Add buff to battle
this.applyBuff(battle, entry.getValue(), waveIndex);
this.applyBuff(battle, entry.getValue(), waveNum);
}
}
if (this.getTempBuffs() != null) {
for (var tempBuff : this.getTempBuffs()) {
this.applyBuff(battle, tempBuff, waveIndex);
this.applyBuff(battle, tempBuff, waveNum);
}
this.tempBuffs = null;
}
}
private boolean applyBuff(Battle battle, SceneBuff buff, int waveIndex) {
private boolean applyBuff(Battle battle, SceneBuff buff, int waveNum) {
// Get index of owner in lineup
int ownerIndex = battle.getLineup().indexOf(buff.getCasterAvatarId());
// Add buff to battle if owner exists
if (ownerIndex != -1) {
battle.addBuff(buff.getBuffId(), ownerIndex, 1 << waveIndex);
battle.addBuff(buff.getBuffId(), ownerIndex, (1 << waveNum) - 1);
return true;
}