GachaBanner.java 4.03 KB
Newer Older
Melledy's avatar
Melledy committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package emu.grasscutter.game.gacha;

import emu.grasscutter.Grasscutter;
import emu.grasscutter.net.proto.GachaInfoOuterClass.GachaInfo;
import emu.grasscutter.net.proto.GachaUpInfoOuterClass.GachaUpInfo;

public class GachaBanner {
	private int gachaType;
	private int scheduleId;
	private String prefabPath;
	private String previewPrefabPath;
	private String titlePath;
	private int costItem;
	private int beginTime;
	private int endTime;
	private int sortId;
	private int[] rateUpItems1;
	private int[] rateUpItems2;
Melledy's avatar
Melledy committed
19
20
	private int baseYellowWeight = 60; // Max 10000
	private int basePurpleWeight = 510; // Max 10000
Melledy's avatar
Melledy committed
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
	private int eventChance = 50; // Chance to win a featured event item
	private int softPity = 75;
	private int hardPity = 90;
	private BannerType bannerType = BannerType.STANDARD;
	
	public int getGachaType() {
		return gachaType;
	}

	public BannerType getBannerType() {
		return bannerType;
	}

	public int getScheduleId() {
		return scheduleId;
	}

	public String getPrefabPath() {
		return prefabPath;
	}

	public String getPreviewPrefabPath() {
		return previewPrefabPath;
	}

	public String getTitlePath() {
		return titlePath;
	}

	public int getCostItem() {
		return costItem;
	}

	public int getBeginTime() {
		return beginTime;
	}

	public int getEndTime() {
		return endTime;
	}

	public int getSortId() {
		return sortId;
	}

Melledy's avatar
Melledy committed
66
67
68
69
70
71
72
73
	public int getBaseYellowWeight() {
		return baseYellowWeight;
	}

	public int getBasePurpleWeight() {
		return basePurpleWeight;
	}

Melledy's avatar
Melledy committed
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
	public int[] getRateUpItems1() {
		return rateUpItems1;
	}

	public int[] getRateUpItems2() {
		return rateUpItems2;
	}
	
	public int getSoftPity() {
		return softPity - 1;
	}

	public int getHardPity() {
		return hardPity - 1;
	}

	public int getEventChance() {
		return eventChance;
	}

94
	@Deprecated
Melledy's avatar
Melledy committed
95
	public GachaInfo toProto() {
96
97
98
		return toProto("");
	}
	public GachaInfo toProto(String sessionKey) {
99
		String record = "http" + (Grasscutter.getConfig().getDispatchOptions().FrontHTTPS ? "s" : "") + "://"
100
101
102
103
104
105
106
107
108
						+ (Grasscutter.getConfig().getDispatchOptions().PublicIp.isEmpty() ? 
							Grasscutter.getConfig().getDispatchOptions().Ip : 
							Grasscutter.getConfig().getDispatchOptions().PublicIp)
						+ ":"
						+ Integer.toString(Grasscutter.getConfig().getDispatchOptions().PublicPort == 0 ?
							Grasscutter.getConfig().getDispatchOptions().Port : 
							Grasscutter.getConfig().getDispatchOptions().PublicPort)
						+ "/gacha?s=" + sessionKey + "&gachaType=" + gachaType;
		// Grasscutter.getLogger().info("record = " + record);
Melledy's avatar
Melledy committed
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
		GachaInfo.Builder info = GachaInfo.newBuilder()
				.setGachaType(this.getGachaType())
				.setScheduleId(this.getScheduleId())
				.setBeginTime(this.getBeginTime())
				.setEndTime(this.getEndTime())
				.setCostItemId(this.getCostItem())
	            .setCostItemNum(1)
	            .setGachaPrefabPath(this.getPrefabPath())
	            .setGachaPreviewPrefabPath(this.getPreviewPrefabPath())
	            .setGachaProbUrl(record)
	            .setGachaProbUrlOversea(record)
	            .setGachaRecordUrl(record)
	            .setGachaRecordUrlOversea(record)
	            .setTenCostItemId(this.getCostItem())
	            .setTenCostItemNum(10)
	            .setLeftGachaTimes(Integer.MAX_VALUE)
	            .setGachaTimesLimit(Integer.MAX_VALUE)
	            .setGachaSortId(this.getSortId());
		
		if (this.getTitlePath() != null) {
			info.setGachaTitlePath(this.getTitlePath());
		}
		
		if (this.getRateUpItems1().length > 0) {
			GachaUpInfo.Builder upInfo = GachaUpInfo.newBuilder().setItemParentType(1);
			
			for (int id : getRateUpItems1()) {
				upInfo.addItemIdList(id);
				info.addMainNameId(id);
			}
			
			info.addGachaUpInfoList(upInfo);
		}
		
		if (this.getRateUpItems2().length > 0) {
			GachaUpInfo.Builder upInfo = GachaUpInfo.newBuilder().setItemParentType(2);
			
			for (int id : getRateUpItems2()) {
				upInfo.addItemIdList(id);
				if (info.getSubNameIdCount() == 0) {
					info.addSubNameId(id);
				}
			}
			
			info.addGachaUpInfoList(upInfo);
		}
		
		return info.build();
	}
	
	public enum BannerType {
		STANDARD, EVENT, WEAPON;
	}
}