L2Seed.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * Copyright (C) 2004-2014 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.model;
  20. import com.l2jserver.Config;
  21. import com.l2jserver.gameserver.datatables.ItemTable;
  22. import com.l2jserver.gameserver.model.items.L2Item;
  23. public final class L2Seed
  24. {
  25. private final int _seedId;
  26. private final int _cropId; // crop type
  27. private final int _level; // seed level
  28. private final int _matureId; // mature crop type
  29. private final int _reward1;
  30. private final int _reward2;
  31. private final int _castleId; // id of manor (castle id) where seed can be farmed
  32. private final boolean _isAlternative;
  33. private final int _limitSeeds;
  34. private final int _limitCrops;
  35. private final int _seedReferencePrice;
  36. private final int _cropReferencePrice;
  37. public L2Seed(StatsSet set)
  38. {
  39. _cropId = set.getInt("id");
  40. _seedId = set.getInt("seedId");
  41. _level = set.getInt("level");
  42. _matureId = set.getInt("mature_Id");
  43. _reward1 = set.getInt("reward1");
  44. _reward2 = set.getInt("reward2");
  45. _castleId = set.getInt("castleId");
  46. _isAlternative = set.getBoolean("alternative");
  47. _limitCrops = set.getInt("limit_crops");
  48. _limitSeeds = set.getInt("limit_seed");
  49. // Set prices
  50. L2Item item = ItemTable.getInstance().getTemplate(_cropId);
  51. _cropReferencePrice = (item != null) ? item.getReferencePrice() : 1;
  52. item = ItemTable.getInstance().getTemplate(_seedId);
  53. _seedReferencePrice = (item != null) ? item.getReferencePrice() : 1;
  54. }
  55. public final int getCastleId()
  56. {
  57. return _castleId;
  58. }
  59. public final int getSeedId()
  60. {
  61. return _seedId;
  62. }
  63. public final int getCropId()
  64. {
  65. return _cropId;
  66. }
  67. public final int getMatureId()
  68. {
  69. return _matureId;
  70. }
  71. public final int getReward(int type)
  72. {
  73. return (type == 1) ? _reward1 : _reward2;
  74. }
  75. public final int getLevel()
  76. {
  77. return _level;
  78. }
  79. public final boolean isAlternative()
  80. {
  81. return _isAlternative;
  82. }
  83. public final int getSeedLimit()
  84. {
  85. return _limitSeeds * Config.RATE_DROP_MANOR;
  86. }
  87. public final int getCropLimit()
  88. {
  89. return _limitCrops * Config.RATE_DROP_MANOR;
  90. }
  91. public final int getSeedReferencePrice()
  92. {
  93. return _seedReferencePrice;
  94. }
  95. public final int getSeedMaxPrice()
  96. {
  97. return _seedReferencePrice * 10;
  98. }
  99. public final int getSeedMinPrice()
  100. {
  101. return (int) (_seedReferencePrice * 0.6);
  102. }
  103. public final int getCropReferencePrice()
  104. {
  105. return _cropReferencePrice;
  106. }
  107. public final int getCropMaxPrice()
  108. {
  109. return _cropReferencePrice * 10;
  110. }
  111. public final int getCropMinPrice()
  112. {
  113. return (int) (_cropReferencePrice * 0.6);
  114. }
  115. @Override
  116. public final String toString()
  117. {
  118. return "SeedData [_id=" + _seedId + ", _level=" + _level + ", _crop=" + _cropId + ", _mature=" + _matureId + ", _type1=" + _reward1 + ", _type2=" + _reward2 + ", _manorId=" + _castleId + ", _isAlternative=" + _isAlternative + ", _limitSeeds=" + _limitSeeds + ", _limitCrops=" + _limitCrops + "]";
  119. }
  120. }