Fix avatars having 0 hp after retreating from a battle

This commit is contained in:
Melledy
2023-10-02 05:51:53 -07:00
parent 30e6aec86c
commit d4d6fc9311

View File

@@ -186,6 +186,8 @@ public class BattleService extends BaseGameService {
// Get battle object and setup variables
Battle battle = player.getBattle();
int minimumHp = 0;
boolean updateStatus = true;
boolean teleportToAnchor = false;
// Handle result
@@ -203,12 +205,15 @@ public class BattleService extends BaseGameService {
}
case BATTLE_END_QUIT -> {
teleportToAnchor = true;
updateStatus = false;
}
default -> {
updateStatus = false;
}
}
// Check if avatar hp/sp should be updated after a battle
if (updateStatus) {
// Set health/energy for player avatars
for (var battleAvatar : battleAvatars) {
GameAvatar avatar = player.getAvatarById(battleAvatar.getId());
@@ -225,6 +230,7 @@ public class BattleService extends BaseGameService {
// Sync with player
player.sendPacket(new PacketSyncLineupNotify(battle.getLineup()));
}
// Teleport to anchor if player has lost/retreated. On official servers, the player party is teleported to the nearest anchor.
if (teleportToAnchor) {