TaskRaidPointsReset.java 3.3 KB

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