OlympiadGameClassed.java 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. 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 3;
  39. }
  40. @Override
  41. protected final int[][] getReward()
  42. {
  43. return Config.ALT_OLY_CLASSED_REWARD;
  44. }
  45. protected static final OlympiadGameClassed createGame(int id, List<List<Integer>> classList)
  46. {
  47. if (classList == null || classList.isEmpty())
  48. return null;
  49. List<Integer> list;
  50. Participant[] opponents;
  51. while (!classList.isEmpty())
  52. {
  53. list = classList.get(Rnd.nextInt(classList.size()));
  54. if (list == null || list.size() < 2)
  55. {
  56. classList.remove(list);
  57. continue;
  58. }
  59. opponents = OlympiadGameNormal.createListOfParticipants(list);
  60. if (opponents == null)
  61. {
  62. classList.remove(list);
  63. continue;
  64. }
  65. return new OlympiadGameClassed(id, opponents);
  66. }
  67. return null;
  68. }
  69. }