Participant.java 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 com.l2jserver.gameserver.model.L2World;
  17. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  18. import com.l2jserver.gameserver.templates.StatsSet;
  19. /**
  20. *
  21. * @author DS
  22. *
  23. */
  24. public final class Participant
  25. {
  26. public final int objectId;
  27. public L2PcInstance player;
  28. public final String name;
  29. public final int side;
  30. public final int baseClass;
  31. public boolean disconnected = false;
  32. public boolean defaulted = false;
  33. public final StatsSet stats;
  34. public Participant(L2PcInstance plr, int olympiadSide)
  35. {
  36. objectId = plr.getObjectId();
  37. player = plr;
  38. name = plr.getName();
  39. side = olympiadSide;
  40. baseClass = plr.getBaseClass();
  41. stats = Olympiad.getNobleStats(objectId);
  42. }
  43. public Participant(int objId, int olympiadSide)
  44. {
  45. objectId = objId;
  46. player = null;
  47. name = "-";
  48. side = olympiadSide;
  49. baseClass = 0;
  50. stats = null;
  51. }
  52. public final void updatePlayer()
  53. {
  54. if (player == null || !player.isOnline())
  55. player = L2World.getInstance().getPlayer(objectId);
  56. }
  57. public final void updateStat(String statName, int increment)
  58. {
  59. stats.set(statName, Math.max(stats.getInteger(statName) + increment, 0));
  60. }
  61. public final void updateNobleStats()
  62. {
  63. Olympiad.updateNobleStats(objectId, stats);
  64. }
  65. }