BattlePassReward.java 1.35 KB
Newer Older
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
package emu.grasscutter.game.battlepass;

import dev.morphia.annotations.Entity;
import dev.morphia.annotations.Transient;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.excels.BattlePassMissionData;
import emu.grasscutter.data.excels.BattlePassRewardData;
import emu.grasscutter.game.props.BattlePassMissionStatus;
import emu.grasscutter.net.proto.BattlePassRewardTagOuterClass.BattlePassRewardTag;
import emu.grasscutter.net.proto.BattlePassUnlockStatusOuterClass.BattlePassUnlockStatus;

@Entity
public class BattlePassReward {
	private int level;
	private int rewardId;
	private boolean paid;

	@Transient
	private BattlePassMissionData data;
	
	@Deprecated // Morphia only
	public BattlePassReward() {}
	
	public BattlePassReward(int level, int rewardId, boolean paid) {
		this.level = level;
		this.rewardId = rewardId;
		this.paid = paid;
	}

	public int getLevel() {
		return level;
	}

	public int getRewardId() {
		return rewardId;
	}

	public boolean isPaid() {
		return paid;
	}

	public BattlePassRewardTag toProto() {
		var protoBuilder = BattlePassRewardTag.newBuilder();
		
		protoBuilder
			.setLevel(this.getLevel())
			.setRewardId(this.getRewardId())
			.setUnlockStatus(this.isPaid() ? BattlePassUnlockStatus.BATTLE_PASS_UNLOCK_STATUS_PAID : BattlePassUnlockStatus.BATTLE_PASS_UNLOCK_STATUS_FREE);
			
		return protoBuilder.build();
	}
}