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

3
import emu.grasscutter.data.GameResource;
Melledy's avatar
Melledy committed
4
5
6
7
8
9
import emu.grasscutter.data.ResourceType;
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"})
10
public class ItemData extends GameResource {
Melledy's avatar
Melledy committed
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
	
	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;
    
    // Food
    private String FoodQuality;
    private String UseTarget;
    private String[] UseParam;
    
    // String enums
    private String ItemType;
    private String MaterialType;
    private String EquipType;
    private String EffectType;
    private String DestroyRule;
    
    // Relic
    private int MainPropDepotId;
    private int AppendPropDepotId;
    private int AppendPropNum;
    private int SetId;
    private int[] AddPropLevels;
    private int BaseConvExp;
    private int MaxLevel;
    
    // Weapon
    private int WeaponPromoteId;
    private int WeaponBaseExp;
    private int StoryId;
    private int AvatarPromoteId;
Yazawazi's avatar
Yazawazi committed
51
    private int AwakenMaterial;
Melledy's avatar
Melledy committed
52
53
54
55
56
57
58
59
60
61
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
    private int[] AwakenCosts;
    private int[] SkillAffix;
    private WeaponProperty[] WeaponProp;
    
    // Hash
    private String Icon;
    private long NameTextMapHash;
    
    // Post load
    private transient emu.grasscutter.game.inventory.MaterialType materialType;
    private transient emu.grasscutter.game.inventory.ItemType itemType;
    private transient emu.grasscutter.game.inventory.EquipType equipType;
    
    private IntSet addPropLevelSet;
    
    @Override
	public int getId(){
        return this.Id;
    }
    
    public String getMaterialTypeString(){
        return this.MaterialType;
    }
    
    public int getStackLimit(){
        return this.StackLimit;
    }
    
    public int getMaxUseCount(){
        return this.MaxUseCount;
    }
    
    public String getUseTarget(){
        return this.UseTarget;
    }
    
    public String[] getUseParam(){
        return this.UseParam;
    }
    
    public int getRankLevel(){
        return this.RankLevel;
    }
    
    public String getFoodQuality(){
        return this.FoodQuality;
    }
    
    public String getEffectName(){
        return this.EffectName;
    }
    
    public int[] getSatiationParams(){
        return this.SatiationParams;
    }
    
    public int[] getDestroyReturnMaterial(){
        return this.DestroyReturnMaterial;
    }
    
    public int[] getDestroyReturnMaterialCount(){
        return this.DestroyReturnMaterialCount;
    }
    
    public long getNameTextMapHash(){
        return this.NameTextMapHash;
    }
    
    public String getIcon(){
        return this.Icon;
    }
    
    public String getItemTypeString(){
        return this.ItemType;
    }
    
    public int getRank(){
        return this.Rank;
    }
    
    public int getGadgetId() {
		return GadgetId;
    }
    
	public int getBaseConvExp() {
		return BaseConvExp;
	}
	
	public int getMainPropDepotId() {
		return MainPropDepotId;
	}
	
	public int getAppendPropDepotId() {
		return AppendPropDepotId;
	}
	
	public int getAppendPropNum() {
		return AppendPropNum;
	}
	
	public int getSetId() {
		return SetId;
	}
	
	public int getWeaponPromoteId() {
		return WeaponPromoteId;
	}
	
	public int getWeaponBaseExp() {
		return WeaponBaseExp;
	}
	
Yazawazi's avatar
Yazawazi committed
164
165
166
167
	public int getAwakenMaterial() {
        	return AwakenMaterial;
    	}
	
Melledy's avatar
Melledy committed
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
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
	public int[] getAwakenCosts() {
		return AwakenCosts;
	}
	
	public IntSet getAddPropLevelSet() {
		return addPropLevelSet;
	}
	
	public int[] getSkillAffix() {
		return SkillAffix;
	}
	
	public WeaponProperty[] getWeaponProperties() {
		return WeaponProp;
	}
	
	public int getMaxLevel() {
		return MaxLevel;
	}
	
	public emu.grasscutter.game.inventory.ItemType getItemType() {
    	return this.itemType;
    }
    
    public emu.grasscutter.game.inventory.MaterialType getMaterialType() {
    	return this.materialType;
    }
    
    public emu.grasscutter.game.inventory.EquipType getEquipType() {
    	return this.equipType;
    }
    
    public boolean canAddRelicProp(int level) {
    	return this.addPropLevelSet != null & this.addPropLevelSet.contains(level);
    }
    
	public boolean isEquip() {
		return this.itemType == emu.grasscutter.game.inventory.ItemType.ITEM_RELIQUARY || this.itemType == emu.grasscutter.game.inventory.ItemType.ITEM_WEAPON;
	}
    
    @Override
	public void onLoad() {
    	this.itemType = emu.grasscutter.game.inventory.ItemType.getTypeByName(getItemTypeString());
    	this.materialType = emu.grasscutter.game.inventory.MaterialType.getTypeByName(getMaterialTypeString());

		if (this.itemType == emu.grasscutter.game.inventory.ItemType.ITEM_RELIQUARY) {
			this.equipType = emu.grasscutter.game.inventory.EquipType.getTypeByName(this.EquipType);
			if (this.AddPropLevels != null && this.AddPropLevels.length > 0) {
				this.addPropLevelSet = new IntOpenHashSet(this.AddPropLevels);
			}
		} else if (this.itemType == emu.grasscutter.game.inventory.ItemType.ITEM_WEAPON) {
			this.equipType = emu.grasscutter.game.inventory.EquipType.EQUIP_WEAPON;
		} else {
			this.equipType = emu.grasscutter.game.inventory.EquipType.EQUIP_NONE;
		}
		
		if (this.getWeaponProperties() != null) {
			for (WeaponProperty weaponProperty : this.getWeaponProperties()) {
				weaponProperty.onLoad();
			}
		}
    }
    
    public static class WeaponProperty {
    	private FightProperty fightProp;
        private String PropType;
        private float InitValue;
        private String Type;

        public String getPropType(){
            return this.PropType;
        }
        
        public float getInitValue(){
            return this.InitValue;
        }
        
        public String getType(){
            return this.Type;
        }

		public FightProperty getFightProp() {
			return fightProp;
		}

		public void onLoad() {
			this.fightProp = FightProperty.getPropByName(PropType);
		}
        
    }
Yazawazi's avatar
Yazawazi committed
258
}