OlympiadGameClassed.java 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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.model.olympiad;
  16. import java.util.List;
  17. import com.l2jserver.Config;
  18. import com.l2jserver.util.Rnd;
  19. /**
  20. *
  21. * @author DS
  22. *
  23. */
  24. public class OlympiadGameClassed extends OlympiadGameNormal
  25. {
  26. private OlympiadGameClassed(int id, Participant[] opponents)
  27. {
  28. super(id, opponents);
  29. }
  30. @Override
  31. public final CompetitionType getType()
  32. {
  33. return CompetitionType.CLASSED;
  34. }
  35. @Override
  36. protected final int getDivider()
  37. {
  38. return Config.ALT_OLY_DIVIDER_CLASSED;
  39. }
  40. @Override
  41. protected final int[][] getReward()
  42. {
  43. return Config.ALT_OLY_CLASSED_REWARD;
  44. }
  45. @Override
  46. protected final String getWeeklyMatchType()
  47. {
  48. return COMP_DONE_WEEK_CLASSED;
  49. }
  50. protected static final OlympiadGameClassed createGame(int id, List<List<Integer>> classList)
  51. {
  52. if (classList == null || classList.isEmpty())
  53. return null;
  54. List<Integer> list;
  55. Participant[] opponents;
  56. while (!classList.isEmpty())
  57. {
  58. list = classList.get(Rnd.nextInt(classList.size()));
  59. if (list == null || list.size() < 2)
  60. {
  61. classList.remove(list);
  62. continue;
  63. }
  64. opponents = OlympiadGameNormal.createListOfParticipants(list);
  65. if (opponents == null)
  66. {
  67. classList.remove(list);
  68. continue;
  69. }
  70. return new OlympiadGameClassed(id, opponents);
  71. }
  72. return null;
  73. }
  74. }