AvatarPromoteData.java 1.73 KB
Newer Older
Melledy's avatar
Melledy committed
1
2
3
package emu.grasscutter.data.def;

import java.util.ArrayList;
4
import emu.grasscutter.data.GameResource;
Melledy's avatar
Melledy committed
5
6
7
8
9
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.common.FightPropData;
import emu.grasscutter.data.common.ItemParamData;

@ResourceType(name = "AvatarPromoteExcelConfigData.json")
10
public class AvatarPromoteData 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
	
	private int AvatarPromoteId;
	private int PromoteLevel;
	private int ScoinCost;
	private ItemParamData[] CostItems;
	private int UnlockMaxLevel;
	private FightPropData[] AddProps;
	private int RequiredPlayerLevel;
	
	@Override
	public int getId() {
		return (AvatarPromoteId << 8) + PromoteLevel;
	}

	public int getAvatarPromoteId() {
		return AvatarPromoteId;
	}

	public int getPromoteLevel() {
		return PromoteLevel;
	}

	public ItemParamData[] getCostItems() {
		return CostItems;
	}

	public int getCoinCost() {
		return ScoinCost;
	}

	public FightPropData[] getAddProps() {
		return AddProps;
	}

	public int getUnlockMaxLevel() {
		return UnlockMaxLevel;
	}

	public int getRequiredPlayerLevel() {
		return RequiredPlayerLevel;
	}

	@Override
	public void onLoad() {
		// Trim item params
		ArrayList<ItemParamData> trim = new ArrayList<>(getAddProps().length);
		for (ItemParamData itemParam : getCostItems()) {
			if (itemParam.getId() == 0) {
				continue;
			}
			trim.add(itemParam);
		}
		this.CostItems = trim.toArray(new ItemParamData[trim.size()]);
		// Trim fight prop data (just in case)
		ArrayList<FightPropData> parsed = new ArrayList<>(getAddProps().length);
		for (FightPropData prop : getAddProps()) {
			if (prop.getPropType() != null && prop.getValue() != 0f) {
				prop.onLoad();
				parsed.add(prop);
			}
		}
		this.AddProps = parsed.toArray(new FightPropData[parsed.size()]);
	}
}