BattlePassMissionData.java 2.41 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
package emu.grasscutter.data.excels;

import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;

import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.game.props.BattlePassMissionRefreshType;
import emu.grasscutter.game.props.WatcherTriggerType;
import emu.grasscutter.net.proto.BattlePassMissionOuterClass.BattlePassMission.MissionStatus;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.FieldDefaults;

@ResourceType(name = {"BattlePassMissionExcelConfigData.json"})
@Getter
public class BattlePassMissionData extends GameResource {
    private int addPoint;
    private int id;
    private int scheduleId;
    private int progress;
    private TriggerConfig triggerConfig;
    private BattlePassMissionRefreshType refreshType;
    
    private transient Set<Integer> mainParams;

    @Override
    public int getId() {
        return this.id;
    }
    
    public WatcherTriggerType getTriggerType() {
		return this.getTriggerConfig().getTriggerType();
	}
    
38
39
40
41
	public boolean isCycleRefresh() {
		return getRefreshType() == null || getRefreshType() == BattlePassMissionRefreshType.BATTLE_PASS_MISSION_REFRESH_CYCLE_CROSS_SCHEDULE;
	}
    
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
    public boolean isValidRefreshType() {
    	return getRefreshType() == null || 
    		getRefreshType() == BattlePassMissionRefreshType.BATTLE_PASS_MISSION_REFRESH_CYCLE_CROSS_SCHEDULE || 
    		getScheduleId() == 2701;
    }
    
    @Override
    public void onLoad() {
    	if (this.getTriggerConfig() != null && getTriggerConfig().getParamList()[0].length() > 0) {
    		this.mainParams = Arrays.stream(getTriggerConfig().getParamList()[0].split("[:;,]")).map(Integer::parseInt).collect(Collectors.toSet());
    	}
    }
    
    @Getter
    public static class TriggerConfig {
    	private WatcherTriggerType triggerType;
    	private String[] paramList;
    }
    
    public emu.grasscutter.net.proto.BattlePassMissionOuterClass.BattlePassMission toProto() {
		var protoBuilder = emu.grasscutter.net.proto.BattlePassMissionOuterClass.BattlePassMission.newBuilder();
		
		protoBuilder
			.setMissionId(getId())
			.setTotalProgress(this.getProgress())
			.setRewardBattlePassPoint(this.getAddPoint())
			.setMissionStatus(MissionStatus.MISSION_STATUS_UNFINISHED)
			.setMissionType(this.getRefreshType() == null ? 0 : this.getRefreshType().getValue());
		
		return protoBuilder.build();
	}
}