2
0

TaskRaidPointsReset.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Copyright (C) 2004-2015 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.taskmanager.tasks;
  20. import java.util.Calendar;
  21. import java.util.Map;
  22. import java.util.Map.Entry;
  23. import com.l2jserver.Config;
  24. import com.l2jserver.gameserver.data.sql.impl.ClanTable;
  25. import com.l2jserver.gameserver.instancemanager.RaidBossPointsManager;
  26. import com.l2jserver.gameserver.model.L2Clan;
  27. import com.l2jserver.gameserver.taskmanager.Task;
  28. import com.l2jserver.gameserver.taskmanager.TaskManager;
  29. import com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask;
  30. import com.l2jserver.gameserver.taskmanager.TaskTypes;
  31. public class TaskRaidPointsReset extends Task
  32. {
  33. public static final String NAME = "raid_points_reset";
  34. @Override
  35. public String getName()
  36. {
  37. return NAME;
  38. }
  39. @Override
  40. public void onTimeElapsed(ExecutedTask task)
  41. {
  42. Calendar cal = Calendar.getInstance();
  43. if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY)
  44. {
  45. // reward clan reputation points
  46. Map<Integer, Integer> rankList = RaidBossPointsManager.getInstance().getRankList();
  47. for (L2Clan c : ClanTable.getInstance().getClans())
  48. {
  49. for (Entry<Integer, Integer> entry : rankList.entrySet())
  50. {
  51. if ((entry.getValue() <= 100) && c.isMember(entry.getKey()))
  52. {
  53. int reputation = 0;
  54. switch (entry.getValue())
  55. {
  56. case 1:
  57. reputation = Config.RAID_RANKING_1ST;
  58. break;
  59. case 2:
  60. reputation = Config.RAID_RANKING_2ND;
  61. break;
  62. case 3:
  63. reputation = Config.RAID_RANKING_3RD;
  64. break;
  65. case 4:
  66. reputation = Config.RAID_RANKING_4TH;
  67. break;
  68. case 5:
  69. reputation = Config.RAID_RANKING_5TH;
  70. break;
  71. case 6:
  72. reputation = Config.RAID_RANKING_6TH;
  73. break;
  74. case 7:
  75. reputation = Config.RAID_RANKING_7TH;
  76. break;
  77. case 8:
  78. reputation = Config.RAID_RANKING_8TH;
  79. break;
  80. case 9:
  81. reputation = Config.RAID_RANKING_9TH;
  82. break;
  83. case 10:
  84. reputation = Config.RAID_RANKING_10TH;
  85. break;
  86. default:
  87. if (entry.getValue() <= 50)
  88. {
  89. reputation = Config.RAID_RANKING_UP_TO_50TH;
  90. }
  91. else
  92. {
  93. reputation = Config.RAID_RANKING_UP_TO_100TH;
  94. }
  95. break;
  96. }
  97. c.addReputationScore(reputation, true);
  98. }
  99. }
  100. }
  101. RaidBossPointsManager.getInstance().cleanUp();
  102. _log.info("Raid Points Reset Global Task: launched.");
  103. }
  104. }
  105. @Override
  106. public void initializate()
  107. {
  108. super.initializate();
  109. TaskManager.addUniqueTask(NAME, TaskTypes.TYPE_GLOBAL_TASK, "1", "00:10:00", "");
  110. }
  111. }