diff --git a/scripts/npc/gachaponInfo.js b/scripts/npc/gachaponInfo.js index 68dad89a8d..a803118eaa 100644 --- a/scripts/npc/gachaponInfo.js +++ b/scripts/npc/gachaponInfo.js @@ -27,9 +27,9 @@ var status; var gachaMessages; function start() { - const MapleGachapon = Java.type('server.gachapon.MapleGachapon'); - gachaMessages = MapleGachapon.Gachapon.getLootInfo(); - gachas = MapleGachapon.Gachapon.values(); + const Gachapon = Java.type('server.gachapon.Gachapon'); + gachaMessages = Gachapon.GachaponType.getLootInfo(); + gachas = Gachapon.GachaponType.values(); status = -1; action(1, 0, 0); diff --git a/src/main/java/client/command/commands/gm0/GachaCommand.java b/src/main/java/client/command/commands/gm0/GachaCommand.java index 2b88b74599..95856616dc 100644 --- a/src/main/java/client/command/commands/gm0/GachaCommand.java +++ b/src/main/java/client/command/commands/gm0/GachaCommand.java @@ -26,7 +26,7 @@ package client.command.commands.gm0; import client.Client; import client.command.Command; import server.ItemInformationProvider; -import server.gachapon.MapleGachapon; +import server.gachapon.Gachapon; public class GachaCommand extends Command { { @@ -35,7 +35,7 @@ public class GachaCommand extends Command { @Override public void execute(Client c, String[] params) { - MapleGachapon.Gachapon gacha = null; + Gachapon.GachaponType gacha = null; String search = c.getPlayer().getLastCommandMessage(); String gachaName = ""; String [] names = {"Henesys", "Ellinia", "Perion", "Kerning City", "Sleepywood", "Mushroom Shrine", "Showa Spa Male", "Showa Spa Female", "New Leaf City", "Nautilus Harbor"}; @@ -43,7 +43,7 @@ public class GachaCommand extends Command { for (int i = 0; i < names.length; i++){ if (search.equalsIgnoreCase(names[i])){ gachaName = names[i]; - gacha = MapleGachapon.Gachapon.getByNpcId(ids[i]); + gacha = Gachapon.GachaponType.getByNpcId(ids[i]); } } if (gacha == null){ diff --git a/src/main/java/scripting/npc/NPCConversationManager.java b/src/main/java/scripting/npc/NPCConversationManager.java index 3f74b063ed..d9277025d8 100644 --- a/src/main/java/scripting/npc/NPCConversationManager.java +++ b/src/main/java/scripting/npc/NPCConversationManager.java @@ -47,8 +47,8 @@ import server.SkillbookInformationProvider.SkillBookEntry; import server.events.gm.Event; import server.expeditions.Expedition; import server.expeditions.ExpeditionType; -import server.gachapon.MapleGachapon; -import server.gachapon.MapleGachapon.MapleGachaponItem; +import server.gachapon.Gachapon; +import server.gachapon.Gachapon.GachaponItem; import server.life.LifeFactory; import server.life.PlayerNPC; import server.maps.MapManager; @@ -401,7 +401,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction { public void doGachapon() { int[] maps = {100000000, 101000000, 102000000, 103000000, 105040300, 800000000, 809000101, 809000201, 600000000, 120000000}; - MapleGachaponItem item = MapleGachapon.getInstance().process(npc); + GachaponItem item = Gachapon.getInstance().process(npc); Item itemGained = gainItem(item.getId(), (short) (item.getId() / 10000 == 200 ? 100 : 1), true, true); // For normal potions, make it give 100. diff --git a/src/main/java/server/gachapon/Gachapon.java b/src/main/java/server/gachapon/Gachapon.java new file mode 100644 index 0000000000..c725d061b4 --- /dev/null +++ b/src/main/java/server/gachapon/Gachapon.java @@ -0,0 +1,164 @@ +/* + This file is part of the OdinMS Maple Story Server + Copyright (C) 2008 Patrick Huy + Matthias Butz + Jan Christian Meyer + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation version 3 as published by + the Free Software Foundation. You may not use, modify or distribute + this program under any other version of the GNU Affero General Public + License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package server.gachapon; + +import server.ItemInformationProvider; +import tools.Randomizer; + +/** + * @author Alan (SharpAceX) + */ +public class Gachapon { + + private static final Gachapon instance = new Gachapon(); + + public static Gachapon getInstance() { + return instance; + } + + public enum GachaponType { + + GLOBAL(-1, -1, -1, -1, new Global()), + HENESYS(9100100, 90, 8, 2, new Henesys()), + ELLINIA(9100101, 90, 8, 2, new Ellinia()), + PERION(9100102, 90, 8, 2, new Perion()), + KERNING_CITY(9100103, 90, 8, 2, new KerningCity()), + SLEEPYWOOD(9100104, 90, 8, 2, new Sleepywood()), + MUSHROOM_SHRINE(9100105, 90, 8, 2, new MushroomShrine()), + SHOWA_SPA_MALE(9100106, 90, 8, 2, new ShowaSpaMale()), + SHOWA_SPA_FEMALE(9100107, 90, 8, 2, new ShowaSpaFemale()), + LUDIBRIUM(9100108, 90, 8, 2, new Ludibrium()), + NEW_LEAF_CITY(9100109, 90, 8, 2, new NewLeafCity()), + EL_NATH(9100110, 90, 8, 2, new ElNath()), + NAUTILUS_HARBOR(9100117, 90, 8, 2, new NautilusHarbor()); + + private static final GachaponType[] values = GachaponType.values(); + + private final GachaponItems gachapon; + private final int npcId; + private final int common; + private final int uncommon; + private final int rare; + + GachaponType(int npcid, int c, int u, int r, GachaponItems g) { + this.npcId = npcid; + this.gachapon = g; + this.common = c; + this.uncommon = u; + this.rare = r; + } + + private int getTier() { + int chance = Randomizer.nextInt(common + uncommon + rare) + 1; + if (chance > common + uncommon) { + return 2; //Rare + } else if (chance > common) { + return 1; //Uncommon + } else { + return 0; //Common + } + } + + public int[] getItems(int tier) { + return gachapon.getItems(tier); + } + + public int getItem(int tier) { + int[] gacha = getItems(tier); + int[] global = GLOBAL.getItems(tier); + int chance = Randomizer.nextInt(gacha.length + global.length); + return chance < gacha.length ? gacha[chance] : global[chance - gacha.length]; + } + + public static GachaponType getByNpcId(int npcId) { + for (GachaponType gacha : values) { + if (npcId == gacha.npcId) { + return gacha; + } + } + return null; + } + + public static String[] getLootInfo() { + ItemInformationProvider ii = ItemInformationProvider.getInstance(); + + String[] strList = new String[values.length + 1]; + + String menuStr = ""; + int j = 0; + for (GachaponType gacha : values) { + menuStr += "#L" + j + "#" + gacha.name() + "#l\r\n"; + j++; + + String str = ""; + for (int i = 0; i < 3; i++) { + int[] gachaItems = gacha.getItems(i); + + if (gachaItems.length > 0) { + str += (" #rTier " + i + "#k:\r\n"); + for (int itemid : gachaItems) { + String itemName = ii.getName(itemid); + if (itemName == null) { + itemName = "MISSING NAME #" + itemid; + } + + str += (" " + itemName + "\r\n"); + } + + str += "\r\n"; + } + } + str += "\r\n"; + + strList[j] = str; + } + strList[0] = menuStr; + + return strList; + } + } + + public GachaponItem process(int npcId) { + GachaponType gacha = GachaponType.getByNpcId(npcId); + int tier = gacha.getTier(); + int item = gacha.getItem(tier); + return new GachaponItem(tier, item); + } + + public static class GachaponItem { + private final int id; + private final int tier; + + public GachaponItem(int t, int i) { + id = i; + tier = t; + } + + public int getTier() { + return tier; + } + + public int getId() { + return id; + } + } +} diff --git a/src/main/java/server/gachapon/MapleGachapon.java b/src/main/java/server/gachapon/MapleGachapon.java deleted file mode 100644 index c8bc0632a4..0000000000 --- a/src/main/java/server/gachapon/MapleGachapon.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - This file is part of the OdinMS Maple Story Server - Copyright (C) 2008 Patrick Huy - Matthias Butz - Jan Christian Meyer - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation version 3 as published by - the Free Software Foundation. You may not use, modify or distribute - this program under any other version of the GNU Affero General Public - License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package server.gachapon; - -import server.ItemInformationProvider; -import tools.Randomizer; - -/** - * - * @author Alan (SharpAceX) - */ -public class MapleGachapon { - - private static final MapleGachapon instance = new MapleGachapon(); - - public static MapleGachapon getInstance() { - return instance; - } - - public enum Gachapon { - - GLOBAL(-1, -1, -1, -1, new Global()), - HENESYS(9100100, 90, 8, 2, new Henesys()), - ELLINIA(9100101, 90, 8, 2, new Ellinia()), - PERION(9100102, 90, 8, 2, new Perion()), - KERNING_CITY(9100103, 90, 8, 2, new KerningCity()), - SLEEPYWOOD(9100104, 90, 8, 2, new Sleepywood()), - MUSHROOM_SHRINE(9100105, 90, 8, 2, new MushroomShrine()), - SHOWA_SPA_MALE(9100106, 90, 8, 2, new ShowaSpaMale()), - SHOWA_SPA_FEMALE(9100107, 90, 8, 2, new ShowaSpaFemale()), - LUDIBRIUM(9100108, 90, 8, 2, new Ludibrium()), - NEW_LEAF_CITY(9100109, 90, 8, 2, new NewLeafCity()), - EL_NATH(9100110, 90, 8, 2, new ElNath()), - NAUTILUS_HARBOR(9100117, 90, 8, 2, new NautilusHarbor()); - - private static final Gachapon[] values = Gachapon.values(); - - private GachaponItems gachapon; - private int npcId; - private int common; - private int uncommon; - private int rare; - - private Gachapon(int npcid, int c, int u, int r, GachaponItems g) { - this.npcId = npcid; - this.gachapon = g; - this.common = c; - this.uncommon = u; - this.rare = r; - } - - private int getTier() { - int chance = Randomizer.nextInt(common + uncommon + rare) + 1; - if (chance > common + uncommon) { - return 2; //Rare - } else if (chance > common) { - return 1; //Uncommon - } else { - return 0; //Common - } - } - - public int [] getItems(int tier){ - return gachapon.getItems(tier); - } - - public int getItem(int tier) { - int[] gacha = getItems(tier); - int[] global = GLOBAL.getItems(tier); - int chance = Randomizer.nextInt(gacha.length + global.length); - return chance < gacha.length ? gacha[chance] : global[chance - gacha.length]; - } - - public static Gachapon getByNpcId(int npcId) { - for (Gachapon gacha : values) { - if (npcId == gacha.npcId) { - return gacha; - } - } - return null; - } - - public static String[] getLootInfo() { - ItemInformationProvider ii = ItemInformationProvider.getInstance(); - - String[] strList = new String[values.length + 1]; - - String menuStr = ""; - int j = 0; - for (Gachapon gacha : values) { - menuStr += "#L" + j + "#" + gacha.name() + "#l\r\n"; - j++; - - String str = ""; - for (int i = 0; i < 3; i++) { - int[] gachaItems = gacha.getItems(i); - - if (gachaItems.length > 0) { - str += (" #rTier " + i + "#k:\r\n"); - for (int itemid : gachaItems) { - String itemName = ii.getName(itemid); - if (itemName == null) { - itemName = "MISSING NAME #" + itemid; - } - - str += (" " + itemName + "\r\n"); - } - - str += "\r\n"; - } - } - str += "\r\n"; - - strList[j] = str; - } - strList[0] = menuStr; - - return strList; - } - } - - public MapleGachaponItem process(int npcId) { - Gachapon gacha = Gachapon.getByNpcId(npcId); - int tier = gacha.getTier(); - int item = gacha.getItem(tier); - return new MapleGachaponItem(tier, item); - } - - public class MapleGachaponItem { - private int id; - private int tier; - - public MapleGachaponItem(int t, int i) { - id = i; - tier = t; - } - - public int getTier() { - return tier; - } - - public int getId() { - return id; - } - } -}