mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-14 06:14:45 +01:00
Lineup system rewrite
This commit is contained in:
@@ -16,7 +16,7 @@ import emu.lunarcore.data.excel.AvatarExcel;
|
||||
import emu.lunarcore.game.inventory.GameItem;
|
||||
import emu.lunarcore.game.inventory.ItemMainType;
|
||||
import emu.lunarcore.game.player.Player;
|
||||
import emu.lunarcore.game.player.PlayerLineup;
|
||||
import emu.lunarcore.game.player.lineup.PlayerLineup;
|
||||
import emu.lunarcore.game.scene.Scene;
|
||||
import emu.lunarcore.game.scene.entity.GameEntity;
|
||||
import emu.lunarcore.proto.AvatarOuterClass.Avatar;
|
||||
|
||||
@@ -12,7 +12,7 @@ import emu.lunarcore.game.avatar.GameAvatar;
|
||||
import emu.lunarcore.game.enums.StageType;
|
||||
import emu.lunarcore.game.inventory.GameItem;
|
||||
import emu.lunarcore.game.player.Player;
|
||||
import emu.lunarcore.game.player.PlayerLineup;
|
||||
import emu.lunarcore.game.player.lineup.PlayerLineup;
|
||||
import emu.lunarcore.game.scene.entity.EntityMonster;
|
||||
import emu.lunarcore.proto.SceneBattleInfoOuterClass.SceneBattleInfo;
|
||||
import emu.lunarcore.proto.SceneMonsterOuterClass.SceneMonster;
|
||||
|
||||
@@ -118,6 +118,7 @@ public class BattleService extends BaseGameService {
|
||||
// Add buffs to battle
|
||||
if (isPlayerCaster) {
|
||||
GameAvatar avatar = player.getCurrentLeaderAvatar();
|
||||
|
||||
if (avatar != null) {
|
||||
// Maze skill attack event
|
||||
if (castedSkill) { // Dont need to null check maze skill since we already did it in HandlerSceneCastSkillCsReq
|
||||
@@ -126,9 +127,9 @@ public class BattleService extends BaseGameService {
|
||||
avatar.getExcel().getMazeAttack().onAttack(avatar, battle);
|
||||
}
|
||||
// Add elemental weakness buff to enemies
|
||||
MazeBuff buff = battle.addBuff(avatar.getExcel().getDamageType().getEnterBattleBuff(), player.getLineupManager().getCurrentLeader());
|
||||
MazeBuff buff = battle.addBuff(avatar.getExcel().getDamageType().getEnterBattleBuff(), battle.getLineup().getLeader());
|
||||
if (buff != null) {
|
||||
buff.addTargetIndex(player.getLineupManager().getCurrentLeader());
|
||||
buff.addTargetIndex(battle.getLineup().getLeader());
|
||||
buff.addDynamicValue("SkillIndex", castedSkill ? 2 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class MazeSkillAddBuff extends MazeSkillAction {
|
||||
int waveCount = battle.getMonsterWaveCount();
|
||||
// Add buff for each wave id
|
||||
for (int i = 0; i < waveCount; i++) {
|
||||
battle.addBuff(buffId, caster.getOwner().getLineupManager().getCurrentLeader(), 1 << i);
|
||||
battle.addBuff(buffId, battle.getLineup().getLeader(), 1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import emu.lunarcore.data.GameData;
|
||||
import emu.lunarcore.data.excel.ChallengeExcel;
|
||||
import emu.lunarcore.game.player.BasePlayerManager;
|
||||
import emu.lunarcore.game.player.Player;
|
||||
import emu.lunarcore.game.player.PlayerLineup;
|
||||
import emu.lunarcore.game.player.lineup.PlayerLineup;
|
||||
import emu.lunarcore.proto.ExtraLineupTypeOuterClass.ExtraLineupType;
|
||||
import emu.lunarcore.server.packet.send.PacketStartChallengeScRsp;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
@@ -34,7 +34,7 @@ public class ChallengeManager extends BasePlayerManager {
|
||||
// Sanity check lineups
|
||||
if (excel.getStageNum() >= 1) {
|
||||
// Get lineup
|
||||
PlayerLineup lineup = getPlayer().getLineupManager().getLineupByIndex(0, ExtraLineupType.LINEUP_CHALLENGE_VALUE);
|
||||
PlayerLineup lineup = getPlayer().getLineupManager().getExtraLineupByType(ExtraLineupType.LINEUP_CHALLENGE_VALUE);
|
||||
// Make sure this lineup has avatars set
|
||||
if (lineup.getAvatars().size() == 0) return;
|
||||
// Reset hp/sp
|
||||
@@ -46,7 +46,7 @@ public class ChallengeManager extends BasePlayerManager {
|
||||
lineup.setMp(5);
|
||||
}
|
||||
if (excel.getStageNum() >= 2) {
|
||||
PlayerLineup lineup = getPlayer().getLineupManager().getLineupByIndex(0, ExtraLineupType.LINEUP_CHALLENGE_2_VALUE);
|
||||
PlayerLineup lineup = getPlayer().getLineupManager().getExtraLineupByType(ExtraLineupType.LINEUP_CHALLENGE_2_VALUE);
|
||||
// Make sure this lineup has avatars set
|
||||
if (lineup.getAvatars().size() == 0) return;
|
||||
// Reset hp/sp
|
||||
@@ -59,7 +59,7 @@ public class ChallengeManager extends BasePlayerManager {
|
||||
}
|
||||
|
||||
// Set first lineup before we enter scenes
|
||||
getPlayer().getLineupManager().setCurrentExtraLineup(ExtraLineupType.LINEUP_CHALLENGE_VALUE, false);
|
||||
getPlayer().getLineupManager().setCurrentExtraLineup(ExtraLineupType.LINEUP_CHALLENGE, false);
|
||||
|
||||
// Set challenge data for player
|
||||
ChallengeInstance instance = new ChallengeInstance(getPlayer(), excel);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package emu.lunarcore.game.service;
|
||||
package emu.lunarcore.game.inventory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -9,7 +9,6 @@ import emu.lunarcore.data.common.ItemParam;
|
||||
import emu.lunarcore.data.excel.*;
|
||||
import emu.lunarcore.data.excel.ItemComposeExcel.FormulaType;
|
||||
import emu.lunarcore.game.avatar.GameAvatar;
|
||||
import emu.lunarcore.game.inventory.GameItem;
|
||||
import emu.lunarcore.game.player.Player;
|
||||
import emu.lunarcore.server.game.BaseGameService;
|
||||
import emu.lunarcore.server.game.GameServer;
|
||||
@@ -29,6 +29,8 @@ import emu.lunarcore.game.enums.PropState;
|
||||
import emu.lunarcore.game.gacha.PlayerGachaInfo;
|
||||
import emu.lunarcore.game.inventory.Inventory;
|
||||
import emu.lunarcore.game.mail.Mailbox;
|
||||
import emu.lunarcore.game.player.lineup.LineupManager;
|
||||
import emu.lunarcore.game.player.lineup.PlayerLineup;
|
||||
import emu.lunarcore.game.rogue.RogueInstance;
|
||||
import emu.lunarcore.game.rogue.RogueManager;
|
||||
import emu.lunarcore.game.scene.Scene;
|
||||
@@ -138,9 +140,9 @@ public class Player {
|
||||
// Setup hero paths
|
||||
this.getAvatars().setupHeroPaths();
|
||||
|
||||
// Give us a starter character and add it to our main lineup.
|
||||
// Give us the main character
|
||||
// TODO script tutorial
|
||||
GameAvatar avatar = new GameAvatar(this.getCurHeroPath());
|
||||
GameAvatar avatar = new GameAvatar(GameConstants.TRAILBLAZER_AVATAR_ID);
|
||||
this.addAvatar(avatar);
|
||||
this.getCurrentLineup().getAvatars().add(avatar.getAvatarId());
|
||||
}
|
||||
@@ -264,12 +266,7 @@ public class Player {
|
||||
}
|
||||
|
||||
public GameAvatar getCurrentLeaderAvatar() {
|
||||
try {
|
||||
int avatarId = getCurrentLineup().getAvatars().get(this.getLineupManager().getCurrentLeader());
|
||||
return this.getAvatarById(avatarId);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
return this.getLineupManager().getCurrentLeaderAvatar();
|
||||
}
|
||||
|
||||
private void initUid() {
|
||||
@@ -544,17 +541,17 @@ public class Player {
|
||||
|
||||
public void onLogin() {
|
||||
// Validate
|
||||
if (this.getRot() == null) this.rot = new Position();
|
||||
this.getLineupManager().setPlayer(this);
|
||||
|
||||
// Load avatars and inventory first
|
||||
this.getAvatars().loadFromDatabase();
|
||||
this.getInventory().loadFromDatabase();
|
||||
this.getLineupManager().loadFromDatabase();
|
||||
this.getMailbox().loadFromDatabase();
|
||||
this.getChallengeManager().loadFromDatabase();
|
||||
this.getRogueManager().loadFromDatabase();
|
||||
|
||||
// Load Etc
|
||||
this.getLineupManager().validate(this);
|
||||
// Post database load
|
||||
this.getAvatars().setupHeroPaths();
|
||||
|
||||
// Load into saved scene (should happen after everything else loads)
|
||||
|
||||
@@ -1,38 +1,44 @@
|
||||
package emu.lunarcore.game.player;
|
||||
package emu.lunarcore.game.player.lineup;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import emu.lunarcore.GameConstants;
|
||||
import emu.lunarcore.LunarCore;
|
||||
import emu.lunarcore.game.avatar.GameAvatar;
|
||||
import emu.lunarcore.game.player.Player;
|
||||
import emu.lunarcore.proto.ExtraLineupTypeOuterClass.ExtraLineupType;
|
||||
import emu.lunarcore.server.packet.send.PacketSyncLineupNotify;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Entity(useDiscriminator = false) @Getter
|
||||
public class LineupManager {
|
||||
private transient Player player;
|
||||
|
||||
private PlayerLineup[] lineups;
|
||||
private int currentIndex; // Team index
|
||||
private int currentLeader;
|
||||
private int currentExtraIndex;
|
||||
private int mp;
|
||||
|
||||
// Extra lineups for challenges/simulated universe/etc
|
||||
private transient int currentExtraLineup;
|
||||
private transient Int2ObjectMap<PlayerExtraLineup> extraLineups;
|
||||
private transient PlayerLineup[] lineups;
|
||||
private transient PlayerExtraLineup[] extraLineups;
|
||||
|
||||
@Deprecated // Morphia only!
|
||||
public LineupManager() {
|
||||
this.extraLineups = new Int2ObjectOpenHashMap<>();
|
||||
this.lineups = new PlayerLineup[GameConstants.DEFAULT_TEAMS];
|
||||
this.extraLineups = new PlayerExtraLineup[ExtraLineupType.values().length];
|
||||
}
|
||||
|
||||
public LineupManager(Player player) {
|
||||
this();
|
||||
this.player = player;
|
||||
this.mp = 5;
|
||||
this.validate(player);
|
||||
|
||||
this.validate();
|
||||
}
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
protected void addMp(int i) {
|
||||
@@ -54,8 +60,8 @@ public class LineupManager {
|
||||
* @param sync Whether or not to sync lineup with scene. Not needed when changing scenes.
|
||||
*/
|
||||
public void setCurrentExtraLineup(int type, boolean sync) {
|
||||
this.currentExtraLineup = type;
|
||||
this.currentLeader = 0;
|
||||
this.currentExtraIndex = type;
|
||||
this.getPlayer().save();
|
||||
|
||||
if (sync) {
|
||||
// Sync with scene entities
|
||||
@@ -65,25 +71,36 @@ public class LineupManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the player's current extra lineup type.
|
||||
* @param type Extra lineup type
|
||||
* @param sync Whether or not to sync lineup with scene. Not needed when changing scenes.
|
||||
*/
|
||||
public void setCurrentExtraLineup(ExtraLineupType type, boolean sync) {
|
||||
this.setCurrentExtraLineup(type.getNumber(), sync);
|
||||
}
|
||||
|
||||
public PlayerLineup getLineupByIndex(int index, int extraLineup) {
|
||||
/**
|
||||
* Returns a lineup by the type
|
||||
* @param index Regular lineup index
|
||||
* @param extraLineup
|
||||
* @return
|
||||
*/
|
||||
public PlayerLineup getLineupByIndex(int index, int extraLineupType) {
|
||||
// Sanity
|
||||
if (extraLineup > 0) {
|
||||
return getExtraLineupByType(extraLineup);
|
||||
if (extraLineupType > 0) {
|
||||
return getExtraLineupByType(extraLineupType);
|
||||
} else {
|
||||
return getLineupByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Get player lineup by index. Only normal lineups are returned
|
||||
/**
|
||||
* Gets a regular player lineup by index. Only normal lineups are returned
|
||||
*/
|
||||
public PlayerLineup getLineupByIndex(int index) {
|
||||
// Sanity
|
||||
if (index < 0 || index >= this.getLineups().length) {
|
||||
// Sanity check
|
||||
if (index < 0 || index >= this.lineups.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -91,21 +108,40 @@ public class LineupManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets player lineup by ExtraLineupType. Creates a lineup for the player if it doesnt exist.
|
||||
* @param extraLineupType
|
||||
* @return
|
||||
* Returns a lineup by ExtraLineupType. Creates a lineup for the player if it doesnt exist.
|
||||
* @param type ExtraLineupType
|
||||
*/
|
||||
private PlayerLineup getExtraLineupByType(int extraLineupType) {
|
||||
return getExtraLineups().computeIfAbsent(extraLineupType, type -> new PlayerExtraLineup(getPlayer(), type));
|
||||
public PlayerLineup getExtraLineupByType(int type) {
|
||||
// Sanity check to make sure the extra lineup type actually exists
|
||||
if (type <= 0 || type >= this.extraLineups.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Actually get the lineup
|
||||
PlayerExtraLineup lineup = this.extraLineups[type];
|
||||
|
||||
if (lineup == null) {
|
||||
lineup = new PlayerExtraLineup(this.getPlayer(), type);
|
||||
this.extraLineups[type] = lineup;
|
||||
}
|
||||
|
||||
return lineup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current lineup that the player is using.
|
||||
*/
|
||||
public PlayerLineup getCurrentLineup() {
|
||||
return this.getLineupByIndex(this.currentIndex, this.getCurrentExtraLineup());
|
||||
return this.getLineupByIndex(this.currentIndex, this.currentExtraIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the avatar that the player is playing as from the current lineup.
|
||||
*/
|
||||
public GameAvatar getCurrentLeaderAvatar() {
|
||||
try {
|
||||
int avatarId = this.getCurrentLineup().getAvatars().get(currentLeader);
|
||||
PlayerLineup lineup = this.getCurrentLineup();
|
||||
int avatarId = lineup.getAvatars().get(lineup.getLeader());
|
||||
return this.getPlayer().getAvatarById(avatarId);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
@@ -115,8 +151,10 @@ public class LineupManager {
|
||||
// Lineup functions
|
||||
|
||||
public boolean changeLeader(int slot) {
|
||||
if (slot >= 0 && slot < this.getCurrentLineup().size()) {
|
||||
this.currentLeader = slot;
|
||||
PlayerLineup lineup = this.getCurrentLineup();
|
||||
|
||||
if (slot >= 0 && slot < lineup.size()) {
|
||||
lineup.setLeader(slot);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -147,7 +185,7 @@ public class LineupManager {
|
||||
}
|
||||
|
||||
// Save
|
||||
this.getPlayer().save();
|
||||
lineup.save();
|
||||
|
||||
// Sync lineup with scene
|
||||
if (isCurrentLineup) {
|
||||
@@ -180,13 +218,13 @@ public class LineupManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate leader index
|
||||
if (this.getCurrentLeader() >= lineup.size()) {
|
||||
this.currentLeader = 0;
|
||||
// Validate leader slot
|
||||
if (lineup.getLeader() >= lineup.size()) {
|
||||
lineup.setLeader(0);
|
||||
}
|
||||
|
||||
// Save
|
||||
this.getPlayer().save();
|
||||
lineup.save();
|
||||
|
||||
// Sync lineup with scene
|
||||
if (isCurrentLineup) {
|
||||
@@ -201,7 +239,7 @@ public class LineupManager {
|
||||
|
||||
public boolean switchLineup(int index) {
|
||||
// Sanity + Prevent lineups from being changed when the player is using an extra lineup
|
||||
if (index == this.getCurrentIndex() || this.currentExtraLineup > 0) {
|
||||
if (index == this.getCurrentIndex() || this.currentExtraIndex > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -215,9 +253,8 @@ public class LineupManager {
|
||||
|
||||
// Set index
|
||||
this.currentIndex = index;
|
||||
this.currentLeader = 0;
|
||||
|
||||
// Save
|
||||
// Save player
|
||||
this.getPlayer().save();
|
||||
|
||||
// Sync lineup data
|
||||
@@ -248,13 +285,13 @@ public class LineupManager {
|
||||
}
|
||||
}
|
||||
|
||||
// Validate leader index
|
||||
if (this.getCurrentLeader() >= lineup.size()) {
|
||||
this.currentLeader = 0;
|
||||
// Validate leader slot
|
||||
if (lineup.getLeader() >= lineup.size()) {
|
||||
lineup.setLeader(0);
|
||||
}
|
||||
|
||||
// Save
|
||||
this.getPlayer().save();
|
||||
lineup.save();
|
||||
|
||||
// Sync lineup with scene
|
||||
if (lineup == getCurrentLineup()) {
|
||||
@@ -289,7 +326,7 @@ public class LineupManager {
|
||||
lineup.getAvatars().set(dest, srcId);
|
||||
|
||||
// Save
|
||||
this.getPlayer().save();
|
||||
lineup.save();
|
||||
|
||||
// Sync lineup data
|
||||
player.sendPacket(new PacketSyncLineupNotify(lineup));
|
||||
@@ -302,38 +339,78 @@ public class LineupManager {
|
||||
PlayerLineup lineup = this.getLineupByIndex(index);
|
||||
if (lineup == null) return false;
|
||||
|
||||
// Change name
|
||||
// Change name and save lineup
|
||||
lineup.setName(name);
|
||||
lineup.save();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Max sure all lineups exist in the array
|
||||
public void validate(Player player) {
|
||||
// Set player
|
||||
this.player = player;
|
||||
public void loadFromDatabase() {
|
||||
// Load lineups from database
|
||||
var list = LunarCore.getGameDatabase()
|
||||
.getObjects(PlayerLineup.class, "ownerUid", getPlayer().getUid())
|
||||
.toList();
|
||||
|
||||
// Make sure lineups exist
|
||||
if (this.getLineups() == null) {
|
||||
this.lineups = new PlayerLineup[GameConstants.DEFAULT_TEAMS];
|
||||
} else if (this.getLineups().length != GameConstants.DEFAULT_TEAMS) {
|
||||
// TODO move lineups from old array to this new one
|
||||
this.lineups = new PlayerLineup[GameConstants.DEFAULT_TEAMS];
|
||||
}
|
||||
for (var lineup : list) {
|
||||
// Set owner
|
||||
lineup.setOwner(this.getPlayer());
|
||||
|
||||
// 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);
|
||||
} else {
|
||||
this.lineups[i].setOwnerAndIndex(getPlayer(), i);
|
||||
// Add to lineups
|
||||
try {
|
||||
this.lineups[lineup.getIndex()] = lineup;
|
||||
} catch (Exception e) {
|
||||
lineup.delete();
|
||||
}
|
||||
}
|
||||
|
||||
// Set current index if out of bounds
|
||||
if (this.currentIndex < 0) {
|
||||
// Load extra lineups from database
|
||||
var extraList = LunarCore.getGameDatabase()
|
||||
.getObjects(PlayerExtraLineup.class, "ownerUid", getPlayer().getUid())
|
||||
.toList();
|
||||
|
||||
for (var lineup : extraList) {
|
||||
// Set owner
|
||||
lineup.setOwner(this.getPlayer());
|
||||
|
||||
// Add to lineups
|
||||
try {
|
||||
this.extraLineups[lineup.getExtraLineupType()] = lineup;
|
||||
} catch (Exception e) {
|
||||
lineup.delete();
|
||||
}
|
||||
}
|
||||
|
||||
// Validate lineups
|
||||
this.validate();
|
||||
}
|
||||
|
||||
private void validate() {
|
||||
// Populate all lineups
|
||||
for (int i = 0; i < GameConstants.DEFAULT_TEAMS; i++) {
|
||||
PlayerLineup lineup = this.lineups[i];
|
||||
|
||||
if (lineup == null) {
|
||||
lineup = new PlayerLineup(this.getPlayer(), i);
|
||||
this.lineups[i] = lineup;
|
||||
} else {
|
||||
lineup.setOwner(this.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure current lineup has at least one avatar
|
||||
PlayerLineup lineup = this.getCurrentLineup();
|
||||
if (lineup == null) {
|
||||
this.currentIndex = 0;
|
||||
} else if (this.currentIndex >= this.lineups.length) {
|
||||
this.currentIndex = this.lineups.length - 1;
|
||||
this.currentExtraIndex = 0;
|
||||
lineup = this.getCurrentLineup();
|
||||
}
|
||||
|
||||
if (lineup.getAvatars().size() == 0) {
|
||||
GameAvatar avatar = this.getPlayer().getAvatarById(GameConstants.TRAILBLAZER_AVATAR_ID);
|
||||
if (avatar != null) {
|
||||
lineup.getAvatars().add(avatar.getAvatarId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,19 @@
|
||||
package emu.lunarcore.game.player;
|
||||
package emu.lunarcore.game.player.lineup;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import emu.lunarcore.GameConstants;
|
||||
import emu.lunarcore.game.player.Player;
|
||||
import emu.lunarcore.server.packet.send.PacketSyncLineupNotify;
|
||||
|
||||
@Entity(value = "lineupsExtra", useDiscriminator = false)
|
||||
public class PlayerExtraLineup extends PlayerLineup {
|
||||
private int extraLineupType;
|
||||
private int mp;
|
||||
|
||||
@Deprecated // Morphia only!
|
||||
public PlayerExtraLineup() {
|
||||
|
||||
}
|
||||
public PlayerExtraLineup() {}
|
||||
|
||||
public PlayerExtraLineup(Player player, int extraLineupType) {
|
||||
super(player, 0);
|
||||
this.extraLineupType = extraLineupType;
|
||||
super(player, extraLineupType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -22,9 +21,14 @@ public class PlayerExtraLineup extends PlayerLineup {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIndex() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getExtraLineupType() {
|
||||
return extraLineupType;
|
||||
return this.index;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,57 +1,65 @@
|
||||
package emu.lunarcore.game.player;
|
||||
package emu.lunarcore.game.player.lineup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.bson.types.ObjectId;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import dev.morphia.annotations.Id;
|
||||
import dev.morphia.annotations.Indexed;
|
||||
import emu.lunarcore.GameConstants;
|
||||
import emu.lunarcore.LunarCore;
|
||||
import emu.lunarcore.game.avatar.GameAvatar;
|
||||
import emu.lunarcore.game.player.Player;
|
||||
import emu.lunarcore.proto.LineupInfoOuterClass.LineupInfo;
|
||||
import emu.lunarcore.server.packet.send.PacketSyncLineupNotify;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity(useDiscriminator = false) @Getter
|
||||
@Entity(value = "lineups", useDiscriminator = false) @Getter
|
||||
public class PlayerLineup {
|
||||
private transient Player owner;
|
||||
private transient int index;
|
||||
@Id private ObjectId id;
|
||||
|
||||
private String name;
|
||||
private List<Integer> avatars;
|
||||
@Indexed private int ownerUid;
|
||||
private transient Player owner;
|
||||
|
||||
protected int index;
|
||||
protected List<Integer> avatars;
|
||||
|
||||
@Setter private int leader;
|
||||
@Setter private String name;
|
||||
|
||||
@Deprecated // Morphia only!
|
||||
public PlayerLineup() {
|
||||
|
||||
}
|
||||
public PlayerLineup() {}
|
||||
|
||||
public PlayerLineup(Player player, int index) {
|
||||
this.owner = player;
|
||||
this.ownerUid = player.getUid();
|
||||
this.index = index;
|
||||
this.avatars = new ArrayList<>(GameConstants.MAX_AVATARS_IN_TEAM);
|
||||
|
||||
// Set team name if not an extra lineup
|
||||
if (!this.isExtraLineup()) {
|
||||
this.name = "Team " + (index + 1);
|
||||
} else {
|
||||
this.name = "";
|
||||
}
|
||||
}
|
||||
|
||||
protected void setOwnerAndIndex(Player player, int index) {
|
||||
protected void setOwner(Player player) {
|
||||
this.owner = player;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public boolean isExtraLineup() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getExtraLineupType() {
|
||||
return 0;
|
||||
public int getIndex() {
|
||||
return this.index;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
public int getExtraLineupType() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public synchronized List<Integer> getAvatars() {
|
||||
@@ -115,15 +123,30 @@ public class PlayerLineup {
|
||||
}
|
||||
}
|
||||
|
||||
// Database
|
||||
|
||||
public void save() {
|
||||
LunarCore.getGameDatabase().save(this);
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
LunarCore.getGameDatabase().delete(this);
|
||||
}
|
||||
|
||||
// Serialization
|
||||
|
||||
public LineupInfo toProto() {
|
||||
var proto = LineupInfo.newInstance()
|
||||
.setIndex(index)
|
||||
.setName(this.getName())
|
||||
.setLeaderSlot(this.getOwner().getLineupManager().getCurrentLeader())
|
||||
.setIndex(this.getIndex())
|
||||
.setLeaderSlot(this.getLeader())
|
||||
.setMp(this.getMp())
|
||||
.setMaxMp(GameConstants.MAX_MP)
|
||||
.setExtraLineupTypeValue(this.getExtraLineupType());
|
||||
|
||||
if (this.getName() != null) {
|
||||
proto.setName(this.getName());
|
||||
}
|
||||
|
||||
for (int slot = 0; slot < this.getAvatars().size(); slot++) {
|
||||
GameAvatar avatar = owner.getAvatars().getAvatarById(getAvatars().get(slot));
|
||||
if (avatar == null) continue;
|
||||
@@ -10,7 +10,7 @@ import emu.lunarcore.data.GameDepot;
|
||||
import emu.lunarcore.data.excel.RogueTalentExcel;
|
||||
import emu.lunarcore.game.player.BasePlayerManager;
|
||||
import emu.lunarcore.game.player.Player;
|
||||
import emu.lunarcore.game.player.PlayerLineup;
|
||||
import emu.lunarcore.game.player.lineup.PlayerLineup;
|
||||
import emu.lunarcore.proto.ExtraLineupTypeOuterClass.ExtraLineupType;
|
||||
import emu.lunarcore.proto.RogueAeonInfoOuterClass.RogueAeonInfo;
|
||||
import emu.lunarcore.proto.RogueAreaOuterClass.RogueArea;
|
||||
|
||||
@@ -9,11 +9,11 @@ import emu.lunarcore.data.config.GroupInfo.GroupLoadSide;
|
||||
import emu.lunarcore.data.excel.MazePlaneExcel;
|
||||
import emu.lunarcore.game.avatar.GameAvatar;
|
||||
import emu.lunarcore.game.enums.PlaneType;
|
||||
import emu.lunarcore.game.player.PlayerLineup;
|
||||
import emu.lunarcore.game.scene.entity.*;
|
||||
import emu.lunarcore.game.scene.triggers.PropTrigger;
|
||||
import emu.lunarcore.game.scene.triggers.PropTriggerType;
|
||||
import emu.lunarcore.game.player.Player;
|
||||
import emu.lunarcore.game.player.lineup.PlayerLineup;
|
||||
import emu.lunarcore.proto.SceneEntityGroupInfoOuterClass.SceneEntityGroupInfo;
|
||||
import emu.lunarcore.proto.SceneGroupStateOuterClass.SceneGroupState;
|
||||
import emu.lunarcore.proto.SceneInfoOuterClass.SceneInfo;
|
||||
@@ -316,7 +316,7 @@ public class Scene {
|
||||
|
||||
// Get current lineup
|
||||
PlayerLineup lineup = getPlayer().getCurrentLineup();
|
||||
int leaderAvatarId = lineup.getAvatars().get(getPlayer().getLineupManager().getCurrentLeader());
|
||||
int leaderAvatarId = lineup.getAvatars().get(lineup.getLeader());
|
||||
|
||||
// Sort entities into groups
|
||||
var groups = new Int2ObjectOpenHashMap<SceneEntityGroupInfo>();
|
||||
|
||||
@@ -8,8 +8,8 @@ import emu.lunarcore.Config.GameServerConfig;
|
||||
import emu.lunarcore.LunarCore;
|
||||
import emu.lunarcore.game.battle.BattleService;
|
||||
import emu.lunarcore.game.gacha.GachaService;
|
||||
import emu.lunarcore.game.inventory.InventoryService;
|
||||
import emu.lunarcore.game.player.Player;
|
||||
import emu.lunarcore.game.service.InventoryService;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import kcp.highway.ChannelConfig;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package emu.lunarcore.server.packet.send;
|
||||
|
||||
import emu.lunarcore.game.player.PlayerLineup;
|
||||
import emu.lunarcore.game.player.LineupManager;
|
||||
import emu.lunarcore.game.player.lineup.LineupManager;
|
||||
import emu.lunarcore.game.player.lineup.PlayerLineup;
|
||||
import emu.lunarcore.proto.GetAllLineupDataScRspOuterClass.GetAllLineupDataScRsp;
|
||||
import emu.lunarcore.server.game.GameSession;
|
||||
import emu.lunarcore.server.packet.BasePacket;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package emu.lunarcore.server.packet.send;
|
||||
|
||||
import emu.lunarcore.game.player.PlayerLineup;
|
||||
import emu.lunarcore.game.player.lineup.PlayerLineup;
|
||||
import emu.lunarcore.proto.SwitchLineupIndexScRspOuterClass.SwitchLineupIndexScRsp;
|
||||
import emu.lunarcore.server.packet.BasePacket;
|
||||
import emu.lunarcore.server.packet.CmdId;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package emu.lunarcore.server.packet.send;
|
||||
|
||||
import emu.lunarcore.game.player.PlayerLineup;
|
||||
import emu.lunarcore.game.player.lineup.PlayerLineup;
|
||||
import emu.lunarcore.proto.SyncLineupNotifyOuterClass.SyncLineupNotify;
|
||||
import emu.lunarcore.server.packet.BasePacket;
|
||||
import emu.lunarcore.server.packet.CmdId;
|
||||
|
||||
Reference in New Issue
Block a user