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. * @author DS
  21. */
  22. public class OlympiadGameClassed extends OlympiadGameNormal
  23. {
  24. private OlympiadGameClassed(int id, Participant[] opponents)
  25. {
  26. super(id, opponents);
  27. }
  28. @Override
  29. public final CompetitionType getType()
  30. {
  31. return CompetitionType.CLASSED;
  32. }
  33. @Override
  34. protected final int getDivider()
  35. {
  36. return Config.ALT_OLY_DIVIDER_CLASSED;
  37. }
  38. @Override
  39. protected final int[][] getReward()
  40. {
  41. return Config.ALT_OLY_CLASSED_REWARD;
  42. }
  43. @Override
  44. protected final String getWeeklyMatchType()
  45. {
  46. return COMP_DONE_WEEK_CLASSED;
  47. }
  48. protected static final OlympiadGameClassed createGame(int id, List<List<Integer>> classList)
  49. {
  50. if ((classList == null) || classList.isEmpty())
  51. {
  52. return null;
  53. }
  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. }