Commit 16622785 authored by Няшик Няшный's avatar Няшик Няшный Committed by Melledy
Browse files

Changing how banners work

parent eb54dcec
...@@ -143,7 +143,7 @@ public class GachaBanner { ...@@ -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);
......
...@@ -82,7 +82,7 @@ public class GachaManager { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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
......
...@@ -104,9 +104,9 @@ public final class GachaHandler implements Router { ...@@ -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<>();
......
...@@ -12,6 +12,6 @@ public class HandlerDoGachaReq extends PacketHandler { ...@@ -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());
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment