Changing how banners work

This commit is contained in:
Няшик Няшный 2022-05-19 12:40:05 +03:00 committed by Melledy
parent eb54dcec0e
commit 1662278586
4 changed files with 8 additions and 8 deletions

View File

@ -143,7 +143,7 @@ public class GachaBanner {
String details = "http" + (HTTP_ENCRYPTION.useInRouting ? "s" : "") + "://" String details = "http" + (HTTP_ENCRYPTION.useInRouting ? "s" : "") + "://"
+ lr(HTTP_INFO.accessAddress, HTTP_INFO.bindAddress) + ":" + lr(HTTP_INFO.accessAddress, HTTP_INFO.bindAddress) + ":"
+ lr(HTTP_INFO.accessPort, HTTP_INFO.bindPort) + lr(HTTP_INFO.accessPort, HTTP_INFO.bindPort)
+ "/gacha/details?s=" + sessionKey + "&gachaType=" + gachaType; + "/gacha/details?s=" + sessionKey + "&scheduleId=" + scheduleId;
// Grasscutter.getLogger().info("record = " + record); // Grasscutter.getLogger().info("record = " + record);
ItemParamData costItem1 = this.getCost(1); ItemParamData costItem1 = this.getCost(1);

View File

@ -82,7 +82,7 @@ public class GachaManager {
List<GachaBanner> banners = Grasscutter.getGsonFactory().fromJson(fileReader, TypeToken.getParameterized(Collection.class, GachaBanner.class).getType()); List<GachaBanner> banners = Grasscutter.getGsonFactory().fromJson(fileReader, TypeToken.getParameterized(Collection.class, GachaBanner.class).getType());
if(banners.size() > 0) { if(banners.size() > 0) {
for (GachaBanner banner : banners) { for (GachaBanner banner : banners) {
getGachaBanners().put(banner.getGachaType(), banner); getGachaBanners().put(banner.getScheduleId(), banner);
} }
Grasscutter.getLogger().info("Banners successfully loaded."); Grasscutter.getLogger().info("Banners successfully loaded.");
@ -236,7 +236,7 @@ public class GachaManager {
}; };
} }
public synchronized void doPulls(Player player, int gachaType, int times) { public synchronized void doPulls(Player player, int scheduleId, int times) {
// Sanity check // Sanity check
if (times != 10 && times != 1) { if (times != 10 && times != 1) {
return; return;
@ -248,7 +248,7 @@ public class GachaManager {
} }
// Get banner // Get banner
GachaBanner banner = this.getGachaBanners().get(gachaType); GachaBanner banner = this.getGachaBanners().get(scheduleId);
if (banner == null) { if (banner == null) {
player.sendPacket(new PacketDoGachaRsp()); player.sendPacket(new PacketDoGachaRsp());
return; return;
@ -285,7 +285,7 @@ public class GachaManager {
} }
// Write gacha record // Write gacha record
GachaRecord gachaRecord = new GachaRecord(itemId, player.getUid(), gachaType); GachaRecord gachaRecord = new GachaRecord(itemId, player.getUid(), banner.getGachaType());
DatabaseHelper.saveGachaRecord(gachaRecord); DatabaseHelper.saveGachaRecord(gachaRecord);
// Create gacha item // Create gacha item

View File

@ -104,9 +104,9 @@ public final class GachaHandler implements Router {
.replace("{{LANGUAGE}}", Utils.getLanguageCode(account.getLocale())); .replace("{{LANGUAGE}}", Utils.getLanguageCode(account.getLocale()));
// Get the banner info for the banner we want. // Get the banner info for the banner we want.
int gachaType = Integer.parseInt(request.query("gachaType")); int scheduleId = Integer.parseInt(request.query("scheduleId"));
GachaManager manager = Grasscutter.getGameServer().getGachaManager(); GachaManager manager = Grasscutter.getGameServer().getGachaManager();
GachaBanner banner = manager.getGachaBanners().get(gachaType); GachaBanner banner = manager.getGachaBanners().get(scheduleId);
// Add 5-star items. // Add 5-star items.
Set<String> fiveStarItems = new LinkedHashSet<>(); Set<String> fiveStarItems = new LinkedHashSet<>();

View File

@ -12,6 +12,6 @@ public class HandlerDoGachaReq extends PacketHandler {
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
DoGachaReq req = DoGachaReq.parseFrom(payload); DoGachaReq req = DoGachaReq.parseFrom(payload);
session.getServer().getGachaManager().doPulls(session.getPlayer(), req.getGachaType(), req.getGachaTimes()); session.getServer().getGachaManager().doPulls(session.getPlayer(), req.getGachaScheduleId(), req.getGachaTimes());
} }
} }