123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- /*
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program. If not, see <http://www.gnu.org/licenses/>.
- */
- package com.l2jserver.gameserver.model.olympiad;
- import com.l2jserver.gameserver.model.L2World;
- import com.l2jserver.gameserver.model.StatsSet;
- import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- /**
- * @author DS, Zoey76
- */
- public final class Participant
- {
- private final int objectId;
- private L2PcInstance player;
- private final String name;
- private final int side;
- private final int baseClass;
- private boolean disconnected = false;
- private boolean defaulted = false;
- private final StatsSet stats;
- public String clanName;
- public int clanId;
-
- public Participant(L2PcInstance plr, int olympiadSide)
- {
- objectId = plr.getObjectId();
- player = plr;
- name = plr.getName();
- side = olympiadSide;
- baseClass = plr.getBaseClass();
- stats = Olympiad.getNobleStats(getObjectId());
- clanName = plr.getClan() != null ? plr.getClan().getName() : "";
- clanId = plr.getClanId();
- }
-
- public Participant(int objId, int olympiadSide)
- {
- objectId = objId;
- player = null;
- name = "-";
- side = olympiadSide;
- baseClass = 0;
- stats = null;
- clanName = "";
- clanId = 0;
- }
-
- /**
- * Updates the reference to {@link #player}, if it's null or appears off-line.
- * @return {@code true} if after the update the player isn't null, {@code false} otherwise.
- */
- public final boolean updatePlayer()
- {
- if ((player == null) || !player.isOnline())
- {
- player = L2World.getInstance().getPlayer(getObjectId());
- }
- return (player != null);
- }
-
- /**
- * @param statName
- * @param increment
- */
- public final void updateStat(String statName, int increment)
- {
- stats.set(statName, Math.max(stats.getInteger(statName) + increment, 0));
- }
-
- /**
- * @return the name the player's name.
- */
- public String getName()
- {
- return name;
- }
-
- /**
- * @return the name the player's clan name.
- */
- public String getClanName()
- {
- return clanName;
- }
-
- /**
- * @return the name the player's id.
- */
- public int getClanId()
- {
- return clanId;
- }
-
- /**
- * @return the player
- */
- public L2PcInstance getPlayer()
- {
- return player;
- }
-
- /**
- * @return the objectId
- */
- public int getObjectId()
- {
- return objectId;
- }
-
- /**
- * @return the stats
- */
- public StatsSet getStats()
- {
- return stats;
- }
-
- /**
- * @param noble the player to set
- */
- public void setPlayer(L2PcInstance noble)
- {
- player = noble;
- }
-
- /**
- * @return the side
- */
- public int getSide()
- {
- return side;
- }
-
- /**
- * @return the baseClass
- */
- public int getBaseClass()
- {
- return baseClass;
- }
-
- /**
- * @return the disconnected
- */
- public boolean isDisconnected()
- {
- return disconnected;
- }
-
- /**
- * @param val the disconnected to set
- */
- public void setDisconnected(boolean val)
- {
- disconnected = val;
- }
-
- /**
- * @return the defaulted
- */
- public boolean isDefaulted()
- {
- return defaulted;
- }
-
- /**
- * @param val the value to set.
- */
- public void setDefaulted(boolean val)
- {
- defaulted = val;
- }
- }
|