mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-14 14:24:37 +01:00
Split PlayerLineup into normal and extra types
This commit is contained in:
@@ -22,7 +22,7 @@ public class LineupManager {
|
||||
|
||||
// Extra lineups for challenges/simulated universe/etc
|
||||
private transient int currentExtraLineup;
|
||||
private transient Int2ObjectMap<PlayerLineup> extraLineups;
|
||||
private transient Int2ObjectMap<PlayerExtraLineup> extraLineups;
|
||||
|
||||
@Deprecated // Morphia only!
|
||||
public LineupManager() {
|
||||
@@ -95,7 +95,7 @@ public class LineupManager {
|
||||
* @return
|
||||
*/
|
||||
private PlayerLineup getExtraLineupByType(int extraLineupType) {
|
||||
return getExtraLineups().computeIfAbsent(extraLineupType, type -> new PlayerLineup(getPlayer(), 0, type));
|
||||
return getExtraLineups().computeIfAbsent(extraLineupType, type -> new PlayerExtraLineup(getPlayer(), type));
|
||||
}
|
||||
|
||||
public PlayerLineup getCurrentLineup() {
|
||||
@@ -322,7 +322,7 @@ public class LineupManager {
|
||||
// Create new lineups for any missing ones
|
||||
for (int i = 0; i < this.lineups.length; i++) {
|
||||
if (this.lineups[i] == null) {
|
||||
this.lineups[i] = new PlayerLineup(getPlayer(), i, 0);
|
||||
this.lineups[i] = new PlayerLineup(getPlayer(), i);
|
||||
} else {
|
||||
this.lineups[i].setOwnerAndIndex(getPlayer(), i);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package emu.lunarcore.game.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import emu.lunarcore.GameConstants;
|
||||
import emu.lunarcore.server.packet.send.PacketSyncLineupNotify;
|
||||
import lombok.Getter;
|
||||
|
||||
public class PlayerExtraLineup extends PlayerLineup {
|
||||
private int extraLineupType;
|
||||
private int mp;
|
||||
|
||||
@Deprecated // Morphia only!
|
||||
public PlayerExtraLineup() {
|
||||
|
||||
}
|
||||
|
||||
public PlayerExtraLineup(Player player, int extraLineupType) {
|
||||
super(player, 0);
|
||||
this.extraLineupType = extraLineupType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExtraLineup() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getExtraLineupType() {
|
||||
return extraLineupType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMp(int i) {
|
||||
this.mp = Math.min(this.mp + i, GameConstants.MAX_MP);
|
||||
this.getOwner().sendPacket(new PacketSyncLineupNotify(this.getOwner().getCurrentLineup()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMp(int i) {
|
||||
this.mp = i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMp(int i) {
|
||||
this.mp = Math.max(this.mp - i, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMp() {
|
||||
return this.mp;
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,6 @@ import lombok.Getter;
|
||||
public class PlayerLineup {
|
||||
private transient Player owner;
|
||||
private transient int index;
|
||||
private transient int extraLineupType;
|
||||
private transient int mp;
|
||||
|
||||
private String name;
|
||||
private List<Integer> avatars;
|
||||
@@ -26,10 +24,9 @@ public class PlayerLineup {
|
||||
|
||||
}
|
||||
|
||||
public PlayerLineup(Player player, int index, int extraLineupType) {
|
||||
public PlayerLineup(Player player, int index) {
|
||||
this.owner = player;
|
||||
this.index = index;
|
||||
this.extraLineupType = extraLineupType;
|
||||
this.avatars = new ArrayList<>(GameConstants.MAX_AVATARS_IN_TEAM);
|
||||
|
||||
// Set team name if not an extra lineup
|
||||
@@ -46,7 +43,11 @@ public class PlayerLineup {
|
||||
}
|
||||
|
||||
public boolean isExtraLineup() {
|
||||
return this.extraLineupType != 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getExtraLineupType() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
@@ -62,36 +63,19 @@ public class PlayerLineup {
|
||||
}
|
||||
|
||||
public void addMp(int i) {
|
||||
if (this.getExtraLineupType() > 0) {
|
||||
this.mp = Math.min(this.mp + i, GameConstants.MAX_MP);
|
||||
this.getOwner().sendPacket(new PacketSyncLineupNotify(this.getOwner().getCurrentLineup()));
|
||||
} else {
|
||||
this.getOwner().getLineupManager().addMp(i);
|
||||
}
|
||||
this.getOwner().getLineupManager().addMp(i);
|
||||
}
|
||||
|
||||
public void setMp(int i) {
|
||||
if (this.getExtraLineupType() > 0) {
|
||||
this.mp = i;
|
||||
} else {
|
||||
this.getOwner().getLineupManager().setMp(i);
|
||||
}
|
||||
this.getOwner().getLineupManager().setMp(i);
|
||||
}
|
||||
|
||||
public void removeMp(int i) {
|
||||
if (this.getExtraLineupType() > 0) {
|
||||
this.mp = Math.max(this.mp - i, 0);
|
||||
} else {
|
||||
this.getOwner().getLineupManager().removeMp(i);
|
||||
}
|
||||
this.getOwner().getLineupManager().removeMp(i);
|
||||
}
|
||||
|
||||
public int getMp() {
|
||||
if (this.getExtraLineupType() > 0) {
|
||||
return this.mp;
|
||||
} else {
|
||||
return this.getOwner().getLineupManager().getMp();
|
||||
}
|
||||
return this.getOwner().getLineupManager().getMp();
|
||||
}
|
||||
|
||||
public void heal(int heal, boolean allowRevive) {
|
||||
|
||||
Reference in New Issue
Block a user