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

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
	
Melledy's avatar
Melledy committed
12
13
14
15
16
17
18
	private int avatarPromoteId;
	private int promoteLevel;
	private int scoinCost;
	private ItemParamData[] costItems;
	private int unlockMaxLevel;
	private FightPropData[] addProps;
	private int requiredPlayerLevel;
Melledy's avatar
Melledy committed
19
20
21
	
	@Override
	public int getId() {
Melledy's avatar
Melledy committed
22
		return (avatarPromoteId << 8) + promoteLevel;
Melledy's avatar
Melledy committed
23
24
25
	}

	public int getAvatarPromoteId() {
Melledy's avatar
Melledy committed
26
		return avatarPromoteId;
Melledy's avatar
Melledy committed
27
28
29
	}

	public int getPromoteLevel() {
Melledy's avatar
Melledy committed
30
		return promoteLevel;
Melledy's avatar
Melledy committed
31
32
33
	}

	public ItemParamData[] getCostItems() {
Melledy's avatar
Melledy committed
34
		return costItems;
Melledy's avatar
Melledy committed
35
36
37
	}

	public int getCoinCost() {
Melledy's avatar
Melledy committed
38
		return scoinCost;
Melledy's avatar
Melledy committed
39
40
41
	}

	public FightPropData[] getAddProps() {
Melledy's avatar
Melledy committed
42
		return addProps;
Melledy's avatar
Melledy committed
43
44
45
	}

	public int getUnlockMaxLevel() {
Melledy's avatar
Melledy committed
46
		return unlockMaxLevel;
Melledy's avatar
Melledy committed
47
48
49
	}

	public int getRequiredPlayerLevel() {
Melledy's avatar
Melledy committed
50
		return requiredPlayerLevel;
Melledy's avatar
Melledy committed
51
52
53
54
55
56
57
58
59
60
61
62
	}

	@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);
		}
Melledy's avatar
Melledy committed
63
		this.costItems = trim.toArray(new ItemParamData[trim.size()]);
Melledy's avatar
Melledy committed
64
65
66
67
68
69
70
71
		// 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);
			}
		}
Melledy's avatar
Melledy committed
72
		this.addProps = parsed.toArray(new FightPropData[parsed.size()]);
Melledy's avatar
Melledy committed
73
74
	}
}