Completed the Daily Mission refactoring.
This commit is contained in:
@ -19,9 +19,9 @@ package com.l2jmobius.gameserver.model;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.OneDayRewardStatus;
|
||||
import com.l2jmobius.gameserver.handler.AbstractOneDayRewardHandler;
|
||||
import com.l2jmobius.gameserver.handler.OneDayRewardHandler;
|
||||
import com.l2jmobius.gameserver.enums.DailyMissionStatus;
|
||||
import com.l2jmobius.gameserver.handler.AbstractDailyMissionHandler;
|
||||
import com.l2jmobius.gameserver.handler.DailyMissionHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.base.ClassId;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
@ -29,7 +29,7 @@ import com.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class OneDayRewardDataHolder
|
||||
public class DailyMissionDataHolder
|
||||
{
|
||||
private final int _id;
|
||||
private final int _rewardId;
|
||||
@ -38,11 +38,11 @@ public class OneDayRewardDataHolder
|
||||
private final int _requiredCompletions;
|
||||
private final StatsSet _params;
|
||||
private final boolean _isOneTime;
|
||||
private final AbstractOneDayRewardHandler _handler;
|
||||
private final AbstractDailyMissionHandler _handler;
|
||||
|
||||
public OneDayRewardDataHolder(StatsSet set)
|
||||
public DailyMissionDataHolder(StatsSet set)
|
||||
{
|
||||
final Function<OneDayRewardDataHolder, AbstractOneDayRewardHandler> handler = OneDayRewardHandler.getInstance().getHandler(set.getString("handler"));
|
||||
final Function<DailyMissionDataHolder, AbstractDailyMissionHandler> handler = DailyMissionHandler.getInstance().getHandler(set.getString("handler"));
|
||||
|
||||
_id = set.getInt("id");
|
||||
_rewardId = set.getInt("reward_id");
|
||||
@ -91,7 +91,7 @@ public class OneDayRewardDataHolder
|
||||
|
||||
public boolean isDisplayable(L2PcInstance player)
|
||||
{
|
||||
return (!_isOneTime || (getStatus(player) != OneDayRewardStatus.COMPLETED.getClientId())) && (_classRestriction.isEmpty() || _classRestriction.contains(player.getClassId()));
|
||||
return (!_isOneTime || (getStatus(player) != DailyMissionStatus.COMPLETED.getClientId())) && (_classRestriction.isEmpty() || _classRestriction.contains(player.getClassId()));
|
||||
}
|
||||
|
||||
public void requestReward(L2PcInstance player)
|
||||
@ -104,12 +104,12 @@ public class OneDayRewardDataHolder
|
||||
|
||||
public int getStatus(L2PcInstance player)
|
||||
{
|
||||
return _handler != null ? _handler.getStatus(player) : OneDayRewardStatus.NOT_AVAILABLE.getClientId();
|
||||
return _handler != null ? _handler.getStatus(player) : DailyMissionStatus.NOT_AVAILABLE.getClientId();
|
||||
}
|
||||
|
||||
public int getProgress(L2PcInstance player)
|
||||
{
|
||||
return _handler != null ? _handler.getProgress(player) : OneDayRewardStatus.NOT_AVAILABLE.getClientId();
|
||||
return _handler != null ? _handler.getProgress(player) : DailyMissionStatus.NOT_AVAILABLE.getClientId();
|
||||
}
|
||||
|
||||
public void reset()
|
@ -16,29 +16,29 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.OneDayRewardStatus;
|
||||
import com.l2jmobius.gameserver.enums.DailyMissionStatus;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class OneDayRewardPlayerEntry
|
||||
public class DailyMissionPlayerEntry
|
||||
{
|
||||
private final int _objectId;
|
||||
private final int _rewardId;
|
||||
private OneDayRewardStatus _status = OneDayRewardStatus.NOT_AVAILABLE;
|
||||
private DailyMissionStatus _status = DailyMissionStatus.NOT_AVAILABLE;
|
||||
private int _progress;
|
||||
private long _lastCompleted;
|
||||
|
||||
public OneDayRewardPlayerEntry(int objectId, int rewardId)
|
||||
public DailyMissionPlayerEntry(int objectId, int rewardId)
|
||||
{
|
||||
_objectId = objectId;
|
||||
_rewardId = rewardId;
|
||||
}
|
||||
|
||||
public OneDayRewardPlayerEntry(int objectId, int rewardId, int status, int progress, long lastCompleted)
|
||||
public DailyMissionPlayerEntry(int objectId, int rewardId, int status, int progress, long lastCompleted)
|
||||
{
|
||||
this(objectId, rewardId);
|
||||
_status = OneDayRewardStatus.valueOf(status);
|
||||
_status = DailyMissionStatus.valueOf(status);
|
||||
_progress = progress;
|
||||
_lastCompleted = lastCompleted;
|
||||
}
|
||||
@ -53,12 +53,12 @@ public class OneDayRewardPlayerEntry
|
||||
return _rewardId;
|
||||
}
|
||||
|
||||
public OneDayRewardStatus getStatus()
|
||||
public DailyMissionStatus getStatus()
|
||||
{
|
||||
return _status;
|
||||
}
|
||||
|
||||
public void setStatus(OneDayRewardStatus status)
|
||||
public void setStatus(DailyMissionStatus status)
|
||||
{
|
||||
_status = status;
|
||||
}
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.OneDayRewardDataHolder;
|
||||
import com.l2jmobius.gameserver.model.DailyMissionDataHolder;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
@ -115,7 +115,7 @@ public abstract class Condition implements ConditionListener
|
||||
return test(caster, target, null, null);
|
||||
}
|
||||
|
||||
public final boolean test(L2Character caster, OneDayRewardDataHolder onewayreward)
|
||||
public final boolean test(L2Character caster, DailyMissionDataHolder onewayreward)
|
||||
{
|
||||
return test(caster, null, null, null);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class PlayerVariables extends AbstractVariables
|
||||
public static final String HAIR_ACCESSORY_VARIABLE_NAME = "HAIR_ACCESSORY_ENABLED";
|
||||
public static final String WORLD_CHAT_VARIABLE_NAME = "WORLD_CHAT_POINTS";
|
||||
public static final String VITALITY_ITEMS_USED_VARIABLE_NAME = "VITALITY_ITEMS_USED";
|
||||
private static final String ONE_DAY_REWARDS = "ONE_DAY_REWARDS";
|
||||
private static final String DAILY_MISSION_REWARDS = "DAILY_MISSION_REWARDS";
|
||||
public static final String CEREMONY_OF_CHAOS_PROHIBITED_PENALTIES = "CEREMONY_OF_CHAOS_PENALTIES";
|
||||
public static final String ABILITY_POINTS_MAIN_CLASS = "ABILITY_POINTS";
|
||||
public static final String ABILITY_POINTS_DUAL_CLASS = "ABILITY_POINTS_DUAL_CLASS";
|
||||
@ -163,9 +163,9 @@ public class PlayerVariables extends AbstractVariables
|
||||
return L2World.getInstance().getPlayer(_objectId);
|
||||
}
|
||||
|
||||
public void addOneDayReward(int rewardId)
|
||||
public void addDailyMissionReward(int rewardId)
|
||||
{
|
||||
String result = getString(ONE_DAY_REWARDS, "");
|
||||
String result = getString(DAILY_MISSION_REWARDS, "");
|
||||
if (result.isEmpty())
|
||||
{
|
||||
result = Integer.toString(rewardId);
|
||||
@ -174,13 +174,13 @@ public class PlayerVariables extends AbstractVariables
|
||||
{
|
||||
result += "," + rewardId;
|
||||
}
|
||||
set(ONE_DAY_REWARDS, result);
|
||||
set(DAILY_MISSION_REWARDS, result);
|
||||
}
|
||||
|
||||
public void removeOneDayReward(int rewardId)
|
||||
public void removeDailyMissionReward(int rewardId)
|
||||
{
|
||||
String result = "";
|
||||
final String data = getString(ONE_DAY_REWARDS, "");
|
||||
final String data = getString(DAILY_MISSION_REWARDS, "");
|
||||
for (String s : data.split(","))
|
||||
{
|
||||
if (s.equals(Integer.toString(rewardId)))
|
||||
@ -196,12 +196,12 @@ public class PlayerVariables extends AbstractVariables
|
||||
result += "," + s;
|
||||
}
|
||||
}
|
||||
set(ONE_DAY_REWARDS, result);
|
||||
set(DAILY_MISSION_REWARDS, result);
|
||||
}
|
||||
|
||||
public boolean hasOneDayReward(int rewardId)
|
||||
public boolean hasDailyMissionReward(int rewardId)
|
||||
{
|
||||
final String data = getString(ONE_DAY_REWARDS, "");
|
||||
final String data = getString(DAILY_MISSION_REWARDS, "");
|
||||
for (String s : data.split(","))
|
||||
{
|
||||
if (s.equals(Integer.toString(rewardId)))
|
||||
@ -212,13 +212,13 @@ public class PlayerVariables extends AbstractVariables
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<Integer> getOneDayRewards()
|
||||
public List<Integer> getDailyMissionRewards()
|
||||
{
|
||||
List<Integer> rewards = null;
|
||||
final String data = getString(ONE_DAY_REWARDS, "");
|
||||
final String data = getString(DAILY_MISSION_REWARDS, "");
|
||||
if (!data.isEmpty())
|
||||
{
|
||||
for (String s : getString(ONE_DAY_REWARDS, "").split(","))
|
||||
for (String s : getString(DAILY_MISSION_REWARDS, "").split(","))
|
||||
{
|
||||
if (Util.isDigit(s))
|
||||
{
|
||||
|
Reference in New Issue
Block a user