ConditionPlayerCanSummonSiegeGolem.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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.conditions;
  20. import com.l2jserver.gameserver.SevenSigns;
  21. import com.l2jserver.gameserver.instancemanager.CastleManager;
  22. import com.l2jserver.gameserver.instancemanager.FortManager;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.entity.Castle;
  25. import com.l2jserver.gameserver.model.entity.Fort;
  26. import com.l2jserver.gameserver.model.stats.Env;
  27. import com.l2jserver.gameserver.network.SystemMessageId;
  28. /**
  29. * Player Can Summon Siege Golem implementation.
  30. * @author Adry_85
  31. */
  32. public class ConditionPlayerCanSummonSiegeGolem extends Condition
  33. {
  34. private final boolean _val;
  35. public ConditionPlayerCanSummonSiegeGolem(boolean val)
  36. {
  37. _val = val;
  38. }
  39. @Override
  40. public boolean testImpl(Env env)
  41. {
  42. boolean canSummonSiegeGolem = true;
  43. if ((env.getPlayer() == null) || env.getPlayer().isAlikeDead() || env.getPlayer().isCursedWeaponEquipped() || (env.getPlayer().getClan() == null))
  44. {
  45. canSummonSiegeGolem = false;
  46. }
  47. final Castle castle = CastleManager.getInstance().getCastle(env.getPlayer());
  48. final Fort fort = FortManager.getInstance().getFort(env.getPlayer());
  49. if ((castle == null) && (fort == null))
  50. {
  51. canSummonSiegeGolem = false;
  52. }
  53. L2PcInstance player = env.getPlayer().getActingPlayer();
  54. if (((fort != null) && (fort.getResidenceId() == 0)) || ((castle != null) && (castle.getResidenceId() == 0)))
  55. {
  56. player.sendPacket(SystemMessageId.INCORRECT_TARGET);
  57. canSummonSiegeGolem = false;
  58. }
  59. else if (((castle != null) && !castle.getSiege().getIsInProgress()) || ((fort != null) && !fort.getSiege().getIsInProgress()))
  60. {
  61. player.sendPacket(SystemMessageId.INCORRECT_TARGET);
  62. canSummonSiegeGolem = false;
  63. }
  64. else if ((player.getClanId() != 0) && (((castle != null) && (castle.getSiege().getAttackerClan(player.getClanId()) == null)) || ((fort != null) && (fort.getSiege().getAttackerClan(player.getClanId()) == null))))
  65. {
  66. player.sendPacket(SystemMessageId.INCORRECT_TARGET);
  67. canSummonSiegeGolem = false;
  68. }
  69. else if ((SevenSigns.getInstance().checkSummonConditions(env.getPlayer())))
  70. {
  71. canSummonSiegeGolem = false;
  72. }
  73. return (_val == canSummonSiegeGolem);
  74. }
  75. }