ItemData.java 6.41 KB
Newer Older
Melledy's avatar
Melledy committed
1
package emu.grasscutter.data.excels;
Melledy's avatar
Melledy committed
2

ImmuState's avatar
ImmuState committed
3
4
import java.util.List;

5
import emu.grasscutter.data.GameResource;
Melledy's avatar
Melledy committed
6
import emu.grasscutter.data.ResourceType;
ImmuState's avatar
ImmuState committed
7
import emu.grasscutter.data.common.ItemUseData;
Melledy's avatar
Melledy committed
8
9
10
11
12
import emu.grasscutter.game.props.FightProperty;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;

@ResourceType(name = {"MaterialExcelConfigData.json", "WeaponExcelConfigData.json", "ReliquaryExcelConfigData.json"})
13
public class ItemData extends GameResource {
Melledy's avatar
Melledy committed
14
	
Melledy's avatar
Melledy committed
15
16
17
18
19
20
21
22
23
24
25
26
	private int id;
    private int stackLimit = 1;
    private int maxUseCount;
    private int rankLevel;
    private String effectName;
    private int[] satiationParams;
    private int rank;
    private int weight;
    private int gadgetId;
    
    private int[] destroyReturnMaterial;
    private int[] destroyReturnMaterialCount;
ImmuState's avatar
ImmuState committed
27
28

    private List<ItemUseData> itemUse;
Melledy's avatar
Melledy committed
29
30
    
    // Food
Melledy's avatar
Melledy committed
31
32
33
    private String foodQuality;
    private String useTarget;
    private String[] iseParam;
Melledy's avatar
Melledy committed
34
35
    
    // String enums
Melledy's avatar
Melledy committed
36
37
38
39
40
    private String itemType;
    private String materialType;
    private String equipType;
    private String effectType;
    private String destroyRule;
Melledy's avatar
Melledy committed
41
42
    
    // Relic
Melledy's avatar
Melledy committed
43
44
45
46
47
48
49
    private int mainPropDepotId;
    private int appendPropDepotId;
    private int appendPropNum;
    private int setId;
    private int[] addPropLevels;
    private int baseConvExp;
    private int maxLevel;
Melledy's avatar
Melledy committed
50
51
    
    // Weapon
Melledy's avatar
Melledy committed
52
53
54
55
56
57
58
59
    private int weaponPromoteId;
    private int weaponBaseExp;
    private int storyId;
    private int avatarPromoteId;
    private int awakenMaterial;
    private int[] awakenCosts;
    private int[] skillAffix;
    private WeaponProperty[] weaponProp;
Melledy's avatar
Melledy committed
60
61
    
    // Hash
Melledy's avatar
Melledy committed
62
63
    private String icon;
    private long nameTextMapHash;
Melledy's avatar
Melledy committed
64
65
    
    // Post load
Melledy's avatar
Melledy committed
66
67
68
    private transient emu.grasscutter.game.inventory.MaterialType materialEnumType;
    private transient emu.grasscutter.game.inventory.ItemType itemEnumType;
    private transient emu.grasscutter.game.inventory.EquipType equipEnumType;
Melledy's avatar
Melledy committed
69
70
71
72
73
    
    private IntSet addPropLevelSet;
    
    @Override
	public int getId(){
Melledy's avatar
Melledy committed
74
        return this.id;
Melledy's avatar
Melledy committed
75
76
77
    }
    
    public String getMaterialTypeString(){
Melledy's avatar
Melledy committed
78
        return this.materialType;
Melledy's avatar
Melledy committed
79
80
81
    }
    
    public int getStackLimit(){
Melledy's avatar
Melledy committed
82
        return this.stackLimit;
Melledy's avatar
Melledy committed
83
84
85
    }
    
    public int getMaxUseCount(){
Melledy's avatar
Melledy committed
86
        return this.maxUseCount;
Melledy's avatar
Melledy committed
87
88
89
    }
    
    public String getUseTarget(){
Melledy's avatar
Melledy committed
90
        return this.useTarget;
Melledy's avatar
Melledy committed
91
92
93
    }
    
    public String[] getUseParam(){
Melledy's avatar
Melledy committed
94
        return this.iseParam;
Melledy's avatar
Melledy committed
95
96
97
    }
    
    public int getRankLevel(){
Melledy's avatar
Melledy committed
98
        return this.rankLevel;
Melledy's avatar
Melledy committed
99
100
101
    }
    
    public String getFoodQuality(){
Melledy's avatar
Melledy committed
102
        return this.foodQuality;
Melledy's avatar
Melledy committed
103
104
105
    }
    
    public String getEffectName(){
Melledy's avatar
Melledy committed
106
        return this.effectName;
Melledy's avatar
Melledy committed
107
108
109
    }
    
    public int[] getSatiationParams(){
Melledy's avatar
Melledy committed
110
        return this.satiationParams;
Melledy's avatar
Melledy committed
111
112
113
    }
    
    public int[] getDestroyReturnMaterial(){
Melledy's avatar
Melledy committed
114
        return this.destroyReturnMaterial;
Melledy's avatar
Melledy committed
115
116
117
    }
    
    public int[] getDestroyReturnMaterialCount(){
Melledy's avatar
Melledy committed
118
        return this.destroyReturnMaterialCount;
Melledy's avatar
Melledy committed
119
    }
ImmuState's avatar
ImmuState committed
120
121
122
123
124

    public List<ItemUseData> getItemUse() {
        return itemUse;
    }

Melledy's avatar
Melledy committed
125
    public long getNameTextMapHash(){
Melledy's avatar
Melledy committed
126
        return this.nameTextMapHash;
Melledy's avatar
Melledy committed
127
128
129
    }
    
    public String getIcon(){
Melledy's avatar
Melledy committed
130
        return this.icon;
Melledy's avatar
Melledy committed
131
132
133
    }
    
    public String getItemTypeString(){
Melledy's avatar
Melledy committed
134
        return this.itemType;
Melledy's avatar
Melledy committed
135
136
137
    }
    
    public int getRank(){
Melledy's avatar
Melledy committed
138
        return this.rank;
Melledy's avatar
Melledy committed
139
140
141
    }
    
    public int getGadgetId() {
Melledy's avatar
Melledy committed
142
		return gadgetId;
Melledy's avatar
Melledy committed
143
144
145
    }
    
	public int getBaseConvExp() {
Melledy's avatar
Melledy committed
146
		return baseConvExp;
Melledy's avatar
Melledy committed
147
148
149
	}
	
	public int getMainPropDepotId() {
Melledy's avatar
Melledy committed
150
		return mainPropDepotId;
Melledy's avatar
Melledy committed
151
152
153
	}
	
	public int getAppendPropDepotId() {
Melledy's avatar
Melledy committed
154
		return appendPropDepotId;
Melledy's avatar
Melledy committed
155
156
157
	}
	
	public int getAppendPropNum() {
Melledy's avatar
Melledy committed
158
		return appendPropNum;
Melledy's avatar
Melledy committed
159
160
161
	}
	
	public int getSetId() {
Melledy's avatar
Melledy committed
162
		return setId;
Melledy's avatar
Melledy committed
163
164
165
	}
	
	public int getWeaponPromoteId() {
Melledy's avatar
Melledy committed
166
		return weaponPromoteId;
Melledy's avatar
Melledy committed
167
168
169
	}
	
	public int getWeaponBaseExp() {
Melledy's avatar
Melledy committed
170
		return weaponBaseExp;
Melledy's avatar
Melledy committed
171
172
	}
	
Yazawazi's avatar
Yazawazi committed
173
	public int getAwakenMaterial() {
Melledy's avatar
Melledy committed
174
        	return awakenMaterial;
Yazawazi's avatar
Yazawazi committed
175
176
    	}
	
Melledy's avatar
Melledy committed
177
	public int[] getAwakenCosts() {
Melledy's avatar
Melledy committed
178
		return awakenCosts;
Melledy's avatar
Melledy committed
179
180
181
182
183
184
185
	}
	
	public IntSet getAddPropLevelSet() {
		return addPropLevelSet;
	}
	
	public int[] getSkillAffix() {
Melledy's avatar
Melledy committed
186
		return skillAffix;
Melledy's avatar
Melledy committed
187
188
189
	}
	
	public WeaponProperty[] getWeaponProperties() {
Melledy's avatar
Melledy committed
190
		return weaponProp;
Melledy's avatar
Melledy committed
191
192
193
	}
	
	public int getMaxLevel() {
Melledy's avatar
Melledy committed
194
		return maxLevel;
Melledy's avatar
Melledy committed
195
196
197
	}
	
	public emu.grasscutter.game.inventory.ItemType getItemType() {
Melledy's avatar
Melledy committed
198
    	return this.itemEnumType;
Melledy's avatar
Melledy committed
199
200
201
    }
    
    public emu.grasscutter.game.inventory.MaterialType getMaterialType() {
Melledy's avatar
Melledy committed
202
    	return this.materialEnumType;
Melledy's avatar
Melledy committed
203
204
205
    }
    
    public emu.grasscutter.game.inventory.EquipType getEquipType() {
Melledy's avatar
Melledy committed
206
    	return this.equipEnumType;
Melledy's avatar
Melledy committed
207
208
209
210
211
212
213
    }
    
    public boolean canAddRelicProp(int level) {
    	return this.addPropLevelSet != null & this.addPropLevelSet.contains(level);
    }
    
	public boolean isEquip() {
Melledy's avatar
Melledy committed
214
		return this.itemEnumType == emu.grasscutter.game.inventory.ItemType.ITEM_RELIQUARY || this.itemEnumType == emu.grasscutter.game.inventory.ItemType.ITEM_WEAPON;
Melledy's avatar
Melledy committed
215
216
217
218
	}
    
    @Override
	public void onLoad() {
Melledy's avatar
Melledy committed
219
220
    	this.itemEnumType = emu.grasscutter.game.inventory.ItemType.getTypeByName(getItemTypeString());
    	this.materialEnumType = emu.grasscutter.game.inventory.MaterialType.getTypeByName(getMaterialTypeString());
Melledy's avatar
Melledy committed
221

Melledy's avatar
Melledy committed
222
223
224
225
		if (this.itemEnumType == emu.grasscutter.game.inventory.ItemType.ITEM_RELIQUARY) {
			this.equipEnumType = emu.grasscutter.game.inventory.EquipType.getTypeByName(this.equipType);
			if (this.addPropLevels != null && this.addPropLevels.length > 0) {
				this.addPropLevelSet = new IntOpenHashSet(this.addPropLevels);
Melledy's avatar
Melledy committed
226
			}
Melledy's avatar
Melledy committed
227
228
		} else if (this.itemEnumType == emu.grasscutter.game.inventory.ItemType.ITEM_WEAPON) {
			this.equipEnumType = emu.grasscutter.game.inventory.EquipType.EQUIP_WEAPON;
Melledy's avatar
Melledy committed
229
		} else {
Melledy's avatar
Melledy committed
230
			this.equipEnumType = emu.grasscutter.game.inventory.EquipType.EQUIP_NONE;
Melledy's avatar
Melledy committed
231
232
233
234
235
236
237
238
239
240
241
		}
		
		if (this.getWeaponProperties() != null) {
			for (WeaponProperty weaponProperty : this.getWeaponProperties()) {
				weaponProperty.onLoad();
			}
		}
    }
    
    public static class WeaponProperty {
    	private FightProperty fightProp;
242
243
244
        private String propType;
        private float initValue;
        private String type;
Melledy's avatar
Melledy committed
245
246

        public String getPropType(){
247
            return this.propType;
Melledy's avatar
Melledy committed
248
249
250
        }
        
        public float getInitValue(){
251
            return this.initValue;
Melledy's avatar
Melledy committed
252
253
254
        }
        
        public String getType(){
255
            return this.type;
Melledy's avatar
Melledy committed
256
257
258
259
260
261
262
        }

		public FightProperty getFightProp() {
			return fightProp;
		}

		public void onLoad() {
263
			this.fightProp = FightProperty.getPropByName(propType);
Melledy's avatar
Melledy committed
264
265
266
		}
        
    }
Yazawazi's avatar
Yazawazi committed
267
}