OlympiadGameClassed.java 2.1 KB

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