From 1662278586b713b860b1b8dace3000a0120f7424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D1=8F=D1=88=D0=B8=D0=BA=20=D0=9D=D1=8F=D1=88=D0=BD?= =?UTF-8?q?=D1=8B=D0=B9?= Date: Thu, 19 May 2022 12:40:05 +0300 Subject: [PATCH] Changing how banners work --- src/main/java/emu/grasscutter/game/gacha/GachaBanner.java | 2 +- .../java/emu/grasscutter/game/gacha/GachaManager.java | 8 ++++---- .../grasscutter/server/http/handlers/GachaHandler.java | 4 ++-- .../grasscutter/server/packet/recv/HandlerDoGachaReq.java | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java b/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java index d3b5d8959..6a42d1392 100644 --- a/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java +++ b/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java @@ -143,7 +143,7 @@ public class GachaBanner { String details = "http" + (HTTP_ENCRYPTION.useInRouting ? "s" : "") + "://" + lr(HTTP_INFO.accessAddress, HTTP_INFO.bindAddress) + ":" + lr(HTTP_INFO.accessPort, HTTP_INFO.bindPort) - + "/gacha/details?s=" + sessionKey + "&gachaType=" + gachaType; + + "/gacha/details?s=" + sessionKey + "&scheduleId=" + scheduleId; // Grasscutter.getLogger().info("record = " + record); ItemParamData costItem1 = this.getCost(1); diff --git a/src/main/java/emu/grasscutter/game/gacha/GachaManager.java b/src/main/java/emu/grasscutter/game/gacha/GachaManager.java index 6ecc2b6b4..edd7231d9 100644 --- a/src/main/java/emu/grasscutter/game/gacha/GachaManager.java +++ b/src/main/java/emu/grasscutter/game/gacha/GachaManager.java @@ -82,7 +82,7 @@ public class GachaManager { List banners = Grasscutter.getGsonFactory().fromJson(fileReader, TypeToken.getParameterized(Collection.class, GachaBanner.class).getType()); if(banners.size() > 0) { for (GachaBanner banner : banners) { - getGachaBanners().put(banner.getGachaType(), banner); + getGachaBanners().put(banner.getScheduleId(), banner); } 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 if (times != 10 && times != 1) { return; @@ -248,7 +248,7 @@ public class GachaManager { } // Get banner - GachaBanner banner = this.getGachaBanners().get(gachaType); + GachaBanner banner = this.getGachaBanners().get(scheduleId); if (banner == null) { player.sendPacket(new PacketDoGachaRsp()); return; @@ -285,7 +285,7 @@ public class GachaManager { } // Write gacha record - GachaRecord gachaRecord = new GachaRecord(itemId, player.getUid(), gachaType); + GachaRecord gachaRecord = new GachaRecord(itemId, player.getUid(), banner.getGachaType()); DatabaseHelper.saveGachaRecord(gachaRecord); // Create gacha item diff --git a/src/main/java/emu/grasscutter/server/http/handlers/GachaHandler.java b/src/main/java/emu/grasscutter/server/http/handlers/GachaHandler.java index 8edbea554..071ffb01a 100644 --- a/src/main/java/emu/grasscutter/server/http/handlers/GachaHandler.java +++ b/src/main/java/emu/grasscutter/server/http/handlers/GachaHandler.java @@ -104,9 +104,9 @@ public final class GachaHandler implements Router { .replace("{{LANGUAGE}}", Utils.getLanguageCode(account.getLocale())); // 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(); - GachaBanner banner = manager.getGachaBanners().get(gachaType); + GachaBanner banner = manager.getGachaBanners().get(scheduleId); // Add 5-star items. Set fiveStarItems = new LinkedHashSet<>(); diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerDoGachaReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerDoGachaReq.java index 0aa680a18..1c06dbbfa 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerDoGachaReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerDoGachaReq.java @@ -12,6 +12,6 @@ public class HandlerDoGachaReq extends PacketHandler { public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { 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()); } }