mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-14 14:24:37 +01:00
Set starting health and energy for avatars before starting a challenge
This commit is contained in:
@@ -5,7 +5,6 @@ import emu.lunarcore.data.config.GroupInfo;
|
||||
import emu.lunarcore.data.config.MonsterInfo;
|
||||
import emu.lunarcore.data.excel.ChallengeExcel;
|
||||
import emu.lunarcore.data.excel.NpcMonsterExcel;
|
||||
import emu.lunarcore.game.avatar.GameAvatar;
|
||||
import emu.lunarcore.game.battle.Battle;
|
||||
import emu.lunarcore.game.player.Player;
|
||||
import emu.lunarcore.game.scene.Scene;
|
||||
@@ -124,14 +123,11 @@ public class ChallengeData {
|
||||
public void onBattleFinish(Battle battle, BattleEndStatus result, BattleStatistics stats) {
|
||||
if (result == BattleEndStatus.BATTLE_END_WIN) {
|
||||
// Check if any avatar in the lineup has died
|
||||
for (int avatarId : player.getCurrentLineup().getAvatars()) {
|
||||
GameAvatar avatar = player.getAvatarById(avatarId);
|
||||
if (avatar == null) continue;
|
||||
|
||||
player.getCurrentLineup().forEachAvatar(avatar -> {
|
||||
if (!avatar.isAlive()) {
|
||||
this.hasAvatarDied = true;
|
||||
hasAvatarDied = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Get monster count in stage
|
||||
long monsters = player.getScene().getEntities().values().stream().filter(e -> e instanceof EntityMonster).count();
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.stream.Stream;
|
||||
import emu.lunarcore.LunarRail;
|
||||
import emu.lunarcore.data.GameData;
|
||||
import emu.lunarcore.data.excel.ChallengeExcel;
|
||||
import emu.lunarcore.game.avatar.GameAvatar;
|
||||
import emu.lunarcore.game.player.BasePlayerManager;
|
||||
import emu.lunarcore.game.player.Player;
|
||||
import emu.lunarcore.game.player.PlayerLineup;
|
||||
@@ -34,20 +33,27 @@ public class ChallengeManager extends BasePlayerManager {
|
||||
|
||||
// Sanity check lineups
|
||||
if (excel.getStageNum() >= 1) {
|
||||
// Get lineup
|
||||
PlayerLineup lineup = getPlayer().getLineupManager().getLineupByIndex(0, ExtraLineupType.LINEUP_CHALLENGE_VALUE);
|
||||
// Make sure this lineup has avatars set
|
||||
if (lineup.getAvatars().size() == 0) {
|
||||
return;
|
||||
}
|
||||
if (lineup.getAvatars().size() == 0) return;
|
||||
// Reset hp/sp
|
||||
lineup.forEachAvatar(avatar -> {
|
||||
avatar.setCurrentHp(10000);
|
||||
avatar.setCurrentSp(avatar.getMaxSp() / 2);
|
||||
});
|
||||
// Set technique points
|
||||
lineup.setMp(5);
|
||||
}
|
||||
if (excel.getStageNum() >= 2) {
|
||||
PlayerLineup lineup = getPlayer().getLineupManager().getLineupByIndex(0, ExtraLineupType.LINEUP_CHALLENGE_2_VALUE);
|
||||
// Make sure this lineup has avatars set
|
||||
if (lineup.getAvatars().size() == 0) {
|
||||
return;
|
||||
}
|
||||
if (lineup.getAvatars().size() == 0) return;
|
||||
// Reset hp/sp
|
||||
lineup.forEachAvatar(avatar -> {
|
||||
avatar.setCurrentHp(10000);
|
||||
avatar.setCurrentSp(avatar.getMaxSp() / 2);
|
||||
});
|
||||
// Set technique points
|
||||
lineup.setMp(5);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package emu.lunarcore.game.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import emu.lunarcore.GameConstants;
|
||||
@@ -120,6 +121,15 @@ public class PlayerLineup {
|
||||
getOwner().sendPacket(new PacketSyncLineupNotify(this));
|
||||
}
|
||||
}
|
||||
|
||||
public void forEachAvatar(Consumer<GameAvatar> consumer) {
|
||||
for (int avatarId : this.getAvatars()) {
|
||||
GameAvatar avatar = this.getOwner().getAvatarById(avatarId);
|
||||
if (avatar == null) continue;
|
||||
|
||||
consumer.accept(avatar);
|
||||
}
|
||||
}
|
||||
|
||||
public LineupInfo toProto() {
|
||||
var proto = LineupInfo.newInstance()
|
||||
|
||||
Reference in New Issue
Block a user