From c99a361ca737cd1a8720d1cf1214b67b56cb4c62 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 25 Apr 2024 22:04:32 -0500 Subject: [PATCH] added set profit dev command --- src/engine/devcmd/cmds/setProfit.java | 72 +++++++++++++++++++++++ src/engine/gameManager/DevCmdManager.java | 1 + 2 files changed, 73 insertions(+) create mode 100644 src/engine/devcmd/cmds/setProfit.java diff --git a/src/engine/devcmd/cmds/setProfit.java b/src/engine/devcmd/cmds/setProfit.java new file mode 100644 index 00000000..6e54200e --- /dev/null +++ b/src/engine/devcmd/cmds/setProfit.java @@ -0,0 +1,72 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + + +package engine.devcmd.cmds; + +import engine.Enum.GameObjectType; +import engine.InterestManagement.WorldGrid; +import engine.devcmd.AbstractDevCmd; +import engine.gameManager.*; +import engine.objects.*; +import org.pmw.tinylog.Logger; + +/** + * @author Eighty + */ +public class setProfit extends AbstractDevCmd { + + public setProfit() { + super("setprofit"); + } + + @Override + protected void _doCmd(PlayerCharacter pc, String[] words, + AbstractGameObject target) { + + if (words.length < 2) { + this.sendUsage(pc); + return; + } + float updateValue; + try { + updateValue = Float.parseFloat(words[1]); + + } catch (NumberFormatException e) { + throwbackError(pc, + "Failed to parse supplied contractID or level to an Integer."); + return; // NaN + } + if(target.getObjectType().equals(GameObjectType.NPC) == false){ + + return; + } + NPC npc = (NPC)target; + if(words[0].toLowerCase().equals("buy")){ + npc.buyPercent = updateValue; + npc.updateDatabase(); + return; + } + if(words[0].toLowerCase().equals("sell")){ + npc.sellPercent = updateValue; + npc.updateDatabase(); + return; + } + } + + @Override + protected String _getHelpString() { + return "Sets profit margin of targeted NPC"; + } + + @Override + protected String _getUsageString() { + return "' /setprofit buy/sell VALUE(1.0)'"; + } + +} diff --git a/src/engine/gameManager/DevCmdManager.java b/src/engine/gameManager/DevCmdManager.java index 0f9fb133..85db7a23 100644 --- a/src/engine/gameManager/DevCmdManager.java +++ b/src/engine/gameManager/DevCmdManager.java @@ -121,6 +121,7 @@ public enum DevCmdManager { DevCmdManager.registerDevCmd(new PurgeObjectsCmd()); DevCmdManager.registerDevCmd(new SplatMobCmd()); DevCmdManager.registerDevCmd(new SlotNpcCmd()); + DevCmdManager.registerDevCmd(new setProfit()); DevCmdManager.registerDevCmd(new GateInfoCmd()); DevCmdManager.registerDevCmd(new ShowOffsetCmd()); DevCmdManager.registerDevCmd(new RealmInfoCmd());