2022-04-17 12:43:07 +00:00
|
|
|
package emu.grasscutter.game.gacha;
|
|
|
|
|
|
|
|
import emu.grasscutter.net.proto.GachaInfoOuterClass.GachaInfo;
|
|
|
|
import emu.grasscutter.net.proto.GachaUpInfoOuterClass.GachaUpInfo;
|
2022-05-06 14:09:45 +00:00
|
|
|
import emu.grasscutter.utils.Utils;
|
2022-04-17 12:43:07 +00:00
|
|
|
|
2022-05-11 04:30:07 +00:00
|
|
|
import static emu.grasscutter.Configuration.*;
|
|
|
|
|
2022-05-11 16:53:51 +00:00
|
|
|
import emu.grasscutter.Grasscutter;
|
2022-05-11 09:54:59 +00:00
|
|
|
import emu.grasscutter.data.common.ItemParamData;
|
|
|
|
|
2022-04-17 12:43:07 +00:00
|
|
|
public class GachaBanner {
|
|
|
|
private int gachaType;
|
|
|
|
private int scheduleId;
|
|
|
|
private String prefabPath;
|
|
|
|
private String previewPrefabPath;
|
|
|
|
private String titlePath;
|
2022-05-11 09:54:59 +00:00
|
|
|
private int costItemId = 0;
|
|
|
|
private int costItemAmount = 1;
|
|
|
|
private int costItemId10 = 0;
|
|
|
|
private int costItemAmount10 = 10;
|
2022-04-17 12:43:07 +00:00
|
|
|
private int beginTime;
|
|
|
|
private int endTime;
|
|
|
|
private int sortId;
|
2022-05-06 14:09:45 +00:00
|
|
|
private int[] rateUpItems4 = {};
|
|
|
|
private int[] rateUpItems5 = {};
|
|
|
|
private int[] fallbackItems3 = {11301, 11302, 11306, 12301, 12302, 12305, 13303, 14301, 14302, 14304, 15301, 15302, 15304};
|
|
|
|
private int[] fallbackItems4Pool1 = {1014, 1020, 1023, 1024, 1025, 1027, 1031, 1032, 1034, 1036, 1039, 1043, 1044, 1045, 1048, 1053, 1055, 1056, 1064};
|
|
|
|
private int[] fallbackItems4Pool2 = {11401, 11402, 11403, 11405, 12401, 12402, 12403, 12405, 13401, 13407, 14401, 14402, 14403, 14409, 15401, 15402, 15403, 15405};
|
|
|
|
private int[] fallbackItems5Pool1 = {1003, 1016, 1042, 1035, 1041};
|
|
|
|
private int[] fallbackItems5Pool2 = {11501, 11502, 12501, 12502, 13502, 13505, 14501, 14502, 15501, 15502};
|
|
|
|
private boolean removeC6FromPool = false;
|
|
|
|
private boolean autoStripRateUpFromFallback = true;
|
|
|
|
private int[][] weights4 = {{1,510}, {8,510}, {10,10000}};
|
|
|
|
private int[][] weights5 = {{1,75}, {73,150}, {90,10000}};
|
|
|
|
private int[][] poolBalanceWeights4 = {{1,255}, {17,255}, {21,10455}};
|
|
|
|
private int[][] poolBalanceWeights5 = {{1,30}, {147,150}, {181,10230}};
|
|
|
|
private int eventChance4 = 50; // Chance to win a featured event item
|
|
|
|
private int eventChance5 = 50; // Chance to win a featured event item
|
2022-04-17 12:43:07 +00:00
|
|
|
private BannerType bannerType = BannerType.STANDARD;
|
2022-05-06 14:09:45 +00:00
|
|
|
|
|
|
|
// Kinda wanna deprecate these but they're in people's configs
|
|
|
|
private int[] rateUpItems1 = {};
|
|
|
|
private int[] rateUpItems2 = {};
|
|
|
|
private int eventChance = -1;
|
2022-05-11 09:54:59 +00:00
|
|
|
private int costItem = 0;
|
2022-04-17 12:43:07 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-05-11 09:54:59 +00:00
|
|
|
public ItemParamData getCost(int numRolls) {
|
|
|
|
return switch (numRolls) {
|
|
|
|
case 10 -> new ItemParamData((costItemId10 > 0) ? costItemId10 : getCostItem(), costItemAmount10);
|
|
|
|
default -> new ItemParamData(getCostItem(), costItemAmount * numRolls);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-04-17 12:43:07 +00:00
|
|
|
public int getCostItem() {
|
2022-05-11 09:54:59 +00:00
|
|
|
return (costItem > 0) ? costItem : costItemId;
|
2022-04-17 12:43:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getBeginTime() {
|
|
|
|
return beginTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getEndTime() {
|
|
|
|
return endTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getSortId() {
|
|
|
|
return sortId;
|
|
|
|
}
|
|
|
|
|
2022-05-06 14:09:45 +00:00
|
|
|
public int[] getRateUpItems4() {
|
|
|
|
return (rateUpItems2.length > 0) ? rateUpItems2 : rateUpItems4;
|
2022-04-27 17:26:27 +00:00
|
|
|
}
|
2022-05-06 14:09:45 +00:00
|
|
|
public int[] getRateUpItems5() {
|
|
|
|
return (rateUpItems1.length > 0) ? rateUpItems1 : rateUpItems5;
|
2022-04-27 17:26:27 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 14:09:45 +00:00
|
|
|
public int[] getFallbackItems3() {return fallbackItems3;}
|
|
|
|
public int[] getFallbackItems4Pool1() {return fallbackItems4Pool1;}
|
|
|
|
public int[] getFallbackItems4Pool2() {return fallbackItems4Pool2;}
|
|
|
|
public int[] getFallbackItems5Pool1() {return fallbackItems5Pool1;}
|
|
|
|
public int[] getFallbackItems5Pool2() {return fallbackItems5Pool2;}
|
2022-04-17 12:43:07 +00:00
|
|
|
|
2022-05-06 14:09:45 +00:00
|
|
|
public boolean getRemoveC6FromPool() {return removeC6FromPool;}
|
|
|
|
public boolean getAutoStripRateUpFromFallback() {return autoStripRateUpFromFallback;}
|
|
|
|
|
|
|
|
|
|
|
|
public int getWeight(int rarity, int pity) {
|
|
|
|
return switch(rarity) {
|
|
|
|
case 4 -> Utils.lerp(pity, weights4);
|
|
|
|
default -> Utils.lerp(pity, weights5);
|
|
|
|
};
|
2022-04-17 12:43:07 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 14:09:45 +00:00
|
|
|
public int getPoolBalanceWeight(int rarity, int pity) {
|
|
|
|
return switch(rarity) {
|
|
|
|
case 4 -> Utils.lerp(pity, poolBalanceWeights4);
|
|
|
|
default -> Utils.lerp(pity, poolBalanceWeights5);
|
|
|
|
};
|
2022-04-17 12:43:07 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 14:09:45 +00:00
|
|
|
public int getEventChance(int rarity) {
|
|
|
|
return switch(rarity) {
|
|
|
|
case 4 -> eventChance4;
|
|
|
|
default -> (eventChance > -1) ? eventChance : eventChance5;
|
|
|
|
};
|
2022-04-17 12:43:07 +00:00
|
|
|
}
|
|
|
|
|
2022-05-01 19:49:44 +00:00
|
|
|
@Deprecated
|
2022-04-17 12:43:07 +00:00
|
|
|
public GachaInfo toProto() {
|
2022-05-01 19:49:44 +00:00
|
|
|
return toProto("");
|
|
|
|
}
|
2022-05-11 04:30:07 +00:00
|
|
|
|
2022-05-01 19:49:44 +00:00
|
|
|
public GachaInfo toProto(String sessionKey) {
|
2022-05-14 03:22:30 +00:00
|
|
|
String record = "http" + (HTTP_ENCRYPTION.useInRouting ? "s" : "") + "://"
|
|
|
|
+ lr(HTTP_INFO.accessAddress, HTTP_INFO.bindAddress) + ":"
|
|
|
|
+ lr(HTTP_INFO.accessPort, HTTP_INFO.bindPort)
|
2022-05-01 19:49:44 +00:00
|
|
|
+ "/gacha?s=" + sessionKey + "&gachaType=" + gachaType;
|
2022-05-14 16:10:43 +00:00
|
|
|
String details = "http" + (HTTP_ENCRYPTION.useInRouting ? "s" : "") + "://"
|
|
|
|
+ lr(HTTP_INFO.accessAddress, HTTP_INFO.bindAddress) + ":"
|
|
|
|
+ lr(HTTP_INFO.accessPort, HTTP_INFO.bindPort)
|
2022-05-19 09:40:05 +00:00
|
|
|
+ "/gacha/details?s=" + sessionKey + "&scheduleId=" + scheduleId;
|
2022-05-11 18:19:25 +00:00
|
|
|
|
2022-05-01 19:49:44 +00:00
|
|
|
// Grasscutter.getLogger().info("record = " + record);
|
2022-05-11 16:53:51 +00:00
|
|
|
ItemParamData costItem1 = this.getCost(1);
|
|
|
|
ItemParamData costItem10 = this.getCost(10);
|
2022-04-17 12:43:07 +00:00
|
|
|
GachaInfo.Builder info = GachaInfo.newBuilder()
|
|
|
|
.setGachaType(this.getGachaType())
|
|
|
|
.setScheduleId(this.getScheduleId())
|
|
|
|
.setBeginTime(this.getBeginTime())
|
|
|
|
.setEndTime(this.getEndTime())
|
2022-05-11 16:53:51 +00:00
|
|
|
.setCostItemId(costItem1.getId())
|
|
|
|
.setCostItemNum(costItem1.getCount())
|
|
|
|
.setTenCostItemId(costItem10.getId())
|
|
|
|
.setTenCostItemNum(costItem10.getCount())
|
2022-04-17 12:43:07 +00:00
|
|
|
.setGachaPrefabPath(this.getPrefabPath())
|
|
|
|
.setGachaPreviewPrefabPath(this.getPreviewPrefabPath())
|
2022-05-11 18:19:25 +00:00
|
|
|
.setGachaProbUrl(details)
|
|
|
|
.setGachaProbUrlOversea(details)
|
2022-04-17 12:43:07 +00:00
|
|
|
.setGachaRecordUrl(record)
|
|
|
|
.setGachaRecordUrlOversea(record)
|
|
|
|
.setLeftGachaTimes(Integer.MAX_VALUE)
|
|
|
|
.setGachaTimesLimit(Integer.MAX_VALUE)
|
|
|
|
.setGachaSortId(this.getSortId());
|
|
|
|
if (this.getTitlePath() != null) {
|
2022-05-28 06:58:12 +00:00
|
|
|
info.setTitleTextmap(this.getTitlePath());
|
2022-04-17 12:43:07 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 14:09:45 +00:00
|
|
|
if (this.getRateUpItems5().length > 0) {
|
2022-04-17 12:43:07 +00:00
|
|
|
GachaUpInfo.Builder upInfo = GachaUpInfo.newBuilder().setItemParentType(1);
|
|
|
|
|
2022-05-06 14:09:45 +00:00
|
|
|
for (int id : getRateUpItems5()) {
|
2022-04-17 12:43:07 +00:00
|
|
|
upInfo.addItemIdList(id);
|
2022-05-28 06:58:12 +00:00
|
|
|
info.addDisplayUp5ItemList(id);
|
2022-04-17 12:43:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
info.addGachaUpInfoList(upInfo);
|
|
|
|
}
|
|
|
|
|
2022-05-06 14:09:45 +00:00
|
|
|
if (this.getRateUpItems4().length > 0) {
|
2022-04-17 12:43:07 +00:00
|
|
|
GachaUpInfo.Builder upInfo = GachaUpInfo.newBuilder().setItemParentType(2);
|
|
|
|
|
2022-05-06 14:09:45 +00:00
|
|
|
for (int id : getRateUpItems4()) {
|
2022-04-17 12:43:07 +00:00
|
|
|
upInfo.addItemIdList(id);
|
2022-05-28 06:58:12 +00:00
|
|
|
if (info.getDisplayUp4ItemListCount() == 0) {
|
|
|
|
info.addDisplayUp4ItemList(id);
|
2022-04-17 12:43:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
info.addGachaUpInfoList(upInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return info.build();
|
|
|
|
}
|
|
|
|
|
|
|
|
public enum BannerType {
|
|
|
|
STANDARD, EVENT, WEAPON;
|
|
|
|
}
|
|
|
|
}
|