AvatarData.java 7.48 KB
Newer Older
Melledy's avatar
Melledy committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package emu.grasscutter.data.def;

import java.util.List;

import emu.grasscutter.data.GenshinData;
import emu.grasscutter.data.GenshinResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.ResourceType.LoadPriority;
import emu.grasscutter.data.common.PropGrowCurve;
import emu.grasscutter.data.custom.AbilityEmbryoEntry;
import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.utils.Utils;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;

@ResourceType(name = "AvatarExcelConfigData.json", loadPriority = LoadPriority.LOW)
public class AvatarData extends GenshinResource {
	
	private String name;
	private String IconName;
    private String BodyType;
    private String QualityType;
    private int ChargeEfficiency;
    private int InitialWeapon;
    private String WeaponType;
    private String ImageName;
    private int AvatarPromoteId;
    private String CutsceneShow;
    private int SkillDepotId;
    private int StaminaRecoverSpeed;
    private List<String> CandSkillDepotIds;
    private long DescTextMapHash;
    private String AvatarIdentityType;
    private List<Integer> AvatarPromoteRewardLevelList;
    private List<Integer> AvatarPromoteRewardIdList;
    private int FeatureTagGroupID;
    
    private long NameTextMapHash;
    private long GachaImageNameHashSuffix;
    private long InfoDescTextMapHash;
    
    private float HpBase;
    private float AttackBase;
    private float DefenseBase;
    private float Critical;
    private float CriticalHurt;

    private List<PropGrowCurve> PropGrowCurves;
    private int Id;
    
    private Int2ObjectMap<String> growthCurveMap;
    private float[] hpGrowthCurve;
    private float[] attackGrowthCurve;
    private float[] defenseGrowthCurve;
    private AvatarSkillDepotData skillDepot;
    private IntList abilities;
Yazawazi's avatar
Yazawazi committed
58
59

    private List<Integer> fetters;
Yazawazi's avatar
Yazawazi committed
60
    private int nameCardRewardId;
Yazawazi's avatar
Yazawazi committed
61
     private int nameCardId;
Melledy's avatar
Melledy committed
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
    
	@Override
	public int getId(){
        return this.Id;
    }
    
    public String getName() {
		return name;
	}
    
    public String getBodyType(){
        return this.BodyType;
    }
    
    public String getQualityType(){
        return this.QualityType;
    }
    
    public int getChargeEfficiency(){
        return this.ChargeEfficiency;
    }

    public int getInitialWeapon(){
        return this.InitialWeapon;
    }

    public String getWeaponType(){
        return this.WeaponType;
    }

    public String getImageName(){
        return this.ImageName;
    }

    public int getAvatarPromoteId(){
        return this.AvatarPromoteId;
    }

    public long getGachaImageNameHashSuffix(){
        return this.GachaImageNameHashSuffix;
    }

    public String getCutsceneShow(){
        return this.CutsceneShow;
    }

    public int getSkillDepotId(){
        return this.SkillDepotId;
    }

    public int getStaminaRecoverSpeed(){
        return this.StaminaRecoverSpeed;
    }

    public List<String> getCandSkillDepotIds(){
        return this.CandSkillDepotIds;
    }

    public long getDescTextMapHash(){
        return this.DescTextMapHash;
    }

    public String getAvatarIdentityType(){
        return this.AvatarIdentityType;
    }

    public List<Integer> getAvatarPromoteRewardLevelList(){
        return this.AvatarPromoteRewardLevelList;
    }

    public List<Integer> getAvatarPromoteRewardIdList(){
        return this.AvatarPromoteRewardIdList;
    }

    public int getFeatureTagGroupID(){
        return this.FeatureTagGroupID;
    }
    
    public long getInfoDescTextMapHash(){
        return this.InfoDescTextMapHash;
    }
    
    public float getBaseHp(int level){
    	try {
    		return this.HpBase * this.hpGrowthCurve[level - 1];
    	} catch (Exception e) {
    		return this.HpBase;
    	}
    }
    
    public float getBaseAttack(int level){
        try {
    		return this.AttackBase * this.attackGrowthCurve[level - 1];
    	} catch (Exception e) {
    		return this.AttackBase;
    	}
    }
    
    public float getBaseDefense(int level){
        try {
    		return this.DefenseBase * this.defenseGrowthCurve[level - 1];
    	} catch (Exception e) {
    		return this.DefenseBase;
    	}
    }
    
    public float getBaseCritical(){
        return this.Critical;
    }
    
    public float getBaseCriticalHurt(){
        return this.CriticalHurt;
    }
    
    public float getGrowthCurveById(int level, FightProperty prop) {
    	String growCurve = this.growthCurveMap.get(prop.getId());
    	if (growCurve == null) {
    		return 1f;
    	}
    	AvatarCurveData curveData = GenshinData.getAvatarCurveDataMap().get(level);
    	if (curveData == null) {
    		return 1f;
    	}
		return curveData.getCurveInfos().getOrDefault(growCurve, 1f);
	}

    public long getNameTextMapHash(){
        return this.NameTextMapHash;
    }
    
    public AvatarSkillDepotData getSkillDepot() {
		return skillDepot;
	}
    
	public IntList getAbilities() {
		return abilities;
	}

Yazawazi's avatar
Yazawazi committed
200
201
202
203
    public List<Integer> getFetters() {
        return fetters;
    }

Yazawazi's avatar
Yazawazi committed
204
205
206
207
    public int getNameCardRewardId() {
        return nameCardRewardId;
    }

Yazawazi's avatar
Yazawazi committed
208
209
210
211
    public int getNameCardId() {
        return nameCardId;
    }

Melledy's avatar
Melledy committed
212
213
214
	@Override
	public void onLoad() {
    	this.skillDepot = GenshinData.getAvatarSkillDepotDataMap().get(this.SkillDepotId);
Yazawazi's avatar
Yazawazi committed
215
216
217

        // Get fetters from GenshinData
        this.fetters = GenshinData.getFetterDataEntries().get(this.Id);
Yazawazi's avatar
Yazawazi committed
218
219
220
221
        
        if (GenshinData.getFetterCharacterCardDataMap().get(this.Id) != null) {
            this.nameCardRewardId = GenshinData.getFetterCharacterCardDataMap().get(this.Id).getRewardId();
        }
Yazawazi's avatar
Yazawazi committed
222
223
224
225

        if (GenshinData.getRewardDataMap().get(this.nameCardRewardId) != null) {
            this.nameCardId = GenshinData.getRewardDataMap().get(this.nameCardRewardId).getRewardItemList().get(0).getItemId();
        }
Melledy's avatar
Melledy committed
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
    	
    	int size = GenshinData.getAvatarCurveDataMap().size();
    	this.hpGrowthCurve = new float[size];
    	this.attackGrowthCurve = new float[size];
    	this.defenseGrowthCurve = new float[size];
    	for (AvatarCurveData curveData : GenshinData.getAvatarCurveDataMap().values()) {
    		int level = curveData.getLevel() - 1;
    		for (PropGrowCurve growCurve : this.PropGrowCurves) {
    			FightProperty prop = FightProperty.getPropByName(growCurve.getType());
    			switch (prop) {
    				case FIGHT_PROP_BASE_HP:
    					this.hpGrowthCurve[level] = curveData.getCurveInfos().get(growCurve.getGrowCurve());
    					break;
    				case FIGHT_PROP_BASE_ATTACK:
    					this.attackGrowthCurve[level] = curveData.getCurveInfos().get(growCurve.getGrowCurve());
    					break;
    				case FIGHT_PROP_BASE_DEFENSE:
    					this.defenseGrowthCurve[level] = curveData.getCurveInfos().get(growCurve.getGrowCurve());
    					break;
    				default:
    					break;
    			}
    		}
    	}
    	
    	/*
    	for (PropGrowCurve growCurve : this.PropGrowCurves) {
    		FightProperty prop = FightProperty.getPropByName(growCurve.getType());
    		this.growthCurveMap.put(prop.getId(), growCurve.getGrowCurve());
    	}
    	*/
    	
    	// Cache abilities
    	String[] split = this.IconName.split("_");
    	if (split.length > 0) {
    		this.name = split[split.length - 1];
    		
    		AbilityEmbryoEntry info = GenshinData.getAbilityEmbryoInfo().get(this.name);
    		if (info != null) {
    			this.abilities = new IntArrayList(info.getAbilities().length);
    			for (String ability : info.getAbilities()) {
    				this.abilities.add(Utils.abilityHash(ability));
    			}
    		}
    	}
    }
}