mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-24 01:21:30 +00:00
AvatarFetterLevel
This commit is contained in:
parent
b507d2c2c9
commit
9edb70d6cf
@ -31,6 +31,7 @@ public class GenshinData {
|
||||
private static final Int2ObjectMap<AvatarSkillDepotData> avatarSkillDepotDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarSkillData> avatarSkillDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarCurveData> avatarCurveDataMap = new Int2ObjectLinkedOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarFetterLevelData> avatarFetterLevelDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarPromoteData> avatarPromoteDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarTalentData> avatarTalentDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<ProudSkillData> proudSkillDataMap = new Int2ObjectOpenHashMap<>();
|
||||
@ -114,6 +115,10 @@ public class GenshinData {
|
||||
return playerLevelDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<AvatarFetterLevelData> getAvatarFetterLevelDataMap() {
|
||||
return avatarFetterLevelDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<AvatarLevelData> getAvatarLevelDataMap() {
|
||||
return avatarLevelDataMap;
|
||||
}
|
||||
@ -176,6 +181,11 @@ public class GenshinData {
|
||||
return levelData != null ? levelData.getExp() : 0;
|
||||
}
|
||||
|
||||
public static int getAvatarFetterLevelExpRequired(int level) {
|
||||
AvatarFetterLevelData levelData = avatarFetterLevelDataMap.get(level);
|
||||
return levelData != null ? levelData.getExp() : 0;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<ProudSkillData> getProudSkillDataMap() {
|
||||
return proudSkillDataMap;
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package emu.grasscutter.data.def;
|
||||
|
||||
import emu.grasscutter.data.GenshinResource;
|
||||
import emu.grasscutter.data.ResourceType;
|
||||
|
||||
@ResourceType(name = "AvatarFettersLevelExcelConfigData.json")
|
||||
public class AvatarFetterLevelData extends GenshinResource {
|
||||
private int FetterLevel;
|
||||
private int NeedExp;
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return this.FetterLevel;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return FetterLevel;
|
||||
}
|
||||
|
||||
public int getExp() {
|
||||
return NeedExp;
|
||||
}
|
||||
}
|
@ -90,6 +90,9 @@ public class GenshinAvatar {
|
||||
private int costume;
|
||||
private int bornTime;
|
||||
|
||||
private int fetterLevel = 1;
|
||||
private int fetterExp;
|
||||
|
||||
public GenshinAvatar() {
|
||||
// Morhpia only!
|
||||
this.equips = new Int2ObjectOpenHashMap<>();
|
||||
@ -281,6 +284,22 @@ public class GenshinAvatar {
|
||||
return fetters;
|
||||
}
|
||||
|
||||
public int getFetterLevel() {
|
||||
return fetterLevel;
|
||||
}
|
||||
|
||||
public void setFetterLevel(int fetterLevel) {
|
||||
this.fetterLevel = fetterLevel;
|
||||
}
|
||||
|
||||
public int getFetterExp() {
|
||||
return fetterExp;
|
||||
}
|
||||
|
||||
public void setFetterExp(int fetterExp) {
|
||||
this.fetterExp = fetterExp;
|
||||
}
|
||||
|
||||
public float getCurrentHp() {
|
||||
return currentHp;
|
||||
}
|
||||
@ -702,8 +721,8 @@ public class GenshinAvatar {
|
||||
|
||||
public AvatarInfo toProto() {
|
||||
AvatarFetterInfo.Builder avatarFetter = AvatarFetterInfo.newBuilder()
|
||||
.setExpLevel(10)
|
||||
.setExpNumber(6325); // Highest Level
|
||||
.setExpLevel(this.getFetterLevel())
|
||||
.setExpNumber(this.getFetterExp());
|
||||
|
||||
if (this.getFetterList() != null) {
|
||||
for (int i = 0; i < this.getFetterList().size(); i++) {
|
||||
|
@ -711,6 +711,31 @@ public class InventoryManager {
|
||||
player.sendPacket(new PacketAvatarUpgradeRsp(avatar, oldLevel, oldPropMap));
|
||||
}
|
||||
|
||||
public void upgradeAvatarFetterLevel(GenshinPlayer player, GenshinAvatar avatar, int expGain) {
|
||||
// May work. Not test.
|
||||
int maxLevel = GenshinData.getAvatarFetterLevelDataMap().get(GenshinData.getAvatarFetterLevelDataMap().size() - 1).getLevel();
|
||||
int level = avatar.getFetterLevel();
|
||||
int exp = avatar.getFetterExp();
|
||||
int reqExp = GenshinData.getAvatarFetterLevelExpRequired(level);
|
||||
|
||||
while (expGain > 0 && reqExp > 0 && level < maxLevel) {
|
||||
int toGain = Math.min(expGain, reqExp - exp);
|
||||
exp += toGain;
|
||||
expGain -= toGain;
|
||||
if (exp >= reqExp) {
|
||||
exp = 0;
|
||||
level += 1;
|
||||
reqExp = GenshinData.getAvatarFetterLevelExpRequired(level);
|
||||
}
|
||||
}
|
||||
|
||||
avatar.setFetterLevel(level);
|
||||
avatar.setFetterExp(exp);
|
||||
avatar.save();
|
||||
|
||||
player.sendPacket(new PacketAvatarPropNotify(avatar));
|
||||
}
|
||||
|
||||
public void upgradeAvatarSkill(GenshinPlayer player, long guid, int skillId) {
|
||||
// Sanity checks
|
||||
GenshinAvatar avatar = player.getAvatars().getAvatarByGuid(guid);
|
||||
|
Loading…
Reference in New Issue
Block a user