2
0

Banking.java 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
  16. import net.sf.l2j.Config;
  17. import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
  18. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  19. import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;
  20. /**
  21. * This class trades Gold Bars for Adena and vice versa.
  22. *
  23. * @author Ahmed
  24. */
  25. public class Banking implements IVoicedCommandHandler
  26. {
  27. private static String[] _voicedCommands =
  28. {
  29. "bank",
  30. "withdraw",
  31. "deposit"
  32. };
  33. /**
  34. *
  35. * @see net.sf.l2j.gameserver.handler.IVoicedCommandHandler#useVoicedCommand(java.lang.String, net.sf.l2j.gameserver.model.actor.instance.L2PcInstance, java.lang.String)
  36. */
  37. public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
  38. {
  39. if (command.equalsIgnoreCase("bank"))
  40. {
  41. activeChar.sendMessage(".deposit (" + Config.BANKING_SYSTEM_ADENA + " Adena = " + Config.BANKING_SYSTEM_GOLDBARS + " Goldbar) / .withdraw (" + Config.BANKING_SYSTEM_GOLDBARS + " Goldbar = " + Config.BANKING_SYSTEM_ADENA + " Adena)");
  42. }
  43. else if (command.equalsIgnoreCase("deposit"))
  44. {
  45. if (activeChar.getInventory().getInventoryItemCount(57, 0) >= Config.BANKING_SYSTEM_ADENA)
  46. {
  47. InventoryUpdate iu = new InventoryUpdate();
  48. activeChar.getInventory().reduceAdena("Goldbar", Config.BANKING_SYSTEM_ADENA, activeChar, null);
  49. activeChar.getInventory().addItem("Goldbar", 3470, Config.BANKING_SYSTEM_GOLDBARS, activeChar, null);
  50. activeChar.getInventory().updateDatabase();
  51. activeChar.sendPacket(iu);
  52. activeChar.sendMessage("Thank you, you now have " + Config.BANKING_SYSTEM_GOLDBARS + " Goldbar(s), and " + Config.BANKING_SYSTEM_ADENA + " less adena.");
  53. }
  54. else
  55. {
  56. activeChar.sendMessage("You do not have enough Adena to convert to Goldbar(s), you need " + Config.BANKING_SYSTEM_ADENA + " Adena.");
  57. }
  58. }
  59. else if (command.equalsIgnoreCase("withdraw"))
  60. {
  61. if (activeChar.getInventory().getInventoryItemCount(3470, 0) >= Config.BANKING_SYSTEM_GOLDBARS)
  62. {
  63. InventoryUpdate iu = new InventoryUpdate();
  64. activeChar.getInventory().destroyItemByItemId("Adena", 3470, Config.BANKING_SYSTEM_GOLDBARS, activeChar, null);
  65. activeChar.getInventory().addAdena("Adena", Config.BANKING_SYSTEM_ADENA, activeChar, null);
  66. activeChar.getInventory().updateDatabase();
  67. activeChar.sendPacket(iu);
  68. activeChar.sendMessage("Thank you, you now have " + Config.BANKING_SYSTEM_ADENA + " Adena, and " + Config.BANKING_SYSTEM_GOLDBARS + " less Goldbar(s).");
  69. }
  70. else
  71. {
  72. activeChar.sendMessage("You do not have any Goldbars to turn into " + Config.BANKING_SYSTEM_ADENA + " Adena.");
  73. }
  74. }
  75. return true;
  76. }
  77. /**
  78. *
  79. * @see net.sf.l2j.gameserver.handler.IVoicedCommandHandler#getVoicedCommandList()
  80. */
  81. public String[] getVoicedCommandList()
  82. {
  83. return _voicedCommands;
  84. }
  85. }