source
Source for my MapleSolaxiaV2 (v83 MapleStory).
This commit is contained in:
53
src/server/quest/requirements/CompletedQuestRequirement.java
Normal file
53
src/server/quest/requirements/CompletedQuestRequirement.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.requirements;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class CompletedQuestRequirement extends MapleQuestRequirement {
|
||||
private int reqQuest;
|
||||
|
||||
|
||||
public CompletedQuestRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.COMPLETED_QUEST);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
reqQuest = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
return chr.getCompletedQuests().size() >= reqQuest;
|
||||
}
|
||||
}
|
||||
60
src/server/quest/requirements/EndDateRequirement.java
Normal file
60
src/server/quest/requirements/EndDateRequirement.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.requirements;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import java.util.Calendar;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class EndDateRequirement extends MapleQuestRequirement {
|
||||
private String timeStr;
|
||||
|
||||
|
||||
public EndDateRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.END_DATE);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
timeStr = MapleDataTool.getString(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(Integer.parseInt(timeStr.substring(0, 4)), Integer.parseInt(timeStr.substring(4, 6)), Integer.parseInt(timeStr.substring(6, 8)), Integer.parseInt(timeStr.substring(8, 10)), 0);
|
||||
return cal.getTimeInMillis() >= System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
56
src/server/quest/requirements/FieldEnterRequirement.java
Normal file
56
src/server/quest/requirements/FieldEnterRequirement.java
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.requirements;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class FieldEnterRequirement extends MapleQuestRequirement {
|
||||
private int mapId = -1;
|
||||
|
||||
|
||||
public FieldEnterRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.FIELD_ENTER);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
MapleData zeroField = data.getChildByPath("0");
|
||||
if (zeroField != null) {
|
||||
mapId = MapleDataTool.getInt(zeroField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
return mapId == chr.getMapId();
|
||||
}
|
||||
}
|
||||
71
src/server/quest/requirements/InfoExRequirement.java
Normal file
71
src/server/quest/requirements/InfoExRequirement.java
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.requirements;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.MapleQuestStatus;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class InfoExRequirement extends MapleQuestRequirement {
|
||||
private List<String> infoExpected = new ArrayList<>();
|
||||
private int questID;
|
||||
|
||||
|
||||
public InfoExRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.INFO_EX);
|
||||
processData(data);
|
||||
questID = quest.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
// Because we have to...
|
||||
for(MapleData infoEx : data.getChildren()) {
|
||||
MapleData value = infoEx.getChildByPath("value");
|
||||
infoExpected.add(MapleDataTool.getString(value, ""));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
MapleQuestStatus status = chr.getQuest(MapleQuest.getInstance(questID));
|
||||
return infoExpected.contains(status.getInfo());
|
||||
}
|
||||
|
||||
public List<String> getInfo() {
|
||||
return infoExpected;
|
||||
}
|
||||
|
||||
public String getFirstInfo() {
|
||||
return !infoExpected.isEmpty() ? infoExpected.get(0) : "";
|
||||
}
|
||||
}
|
||||
58
src/server/quest/requirements/IntervalRequirement.java
Normal file
58
src/server/quest/requirements/IntervalRequirement.java
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.requirements;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.MapleQuestStatus;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class IntervalRequirement extends MapleQuestRequirement {
|
||||
private int interval = -1;
|
||||
private int questID;
|
||||
|
||||
public IntervalRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.INTERVAL);
|
||||
processData(data);
|
||||
questID = quest.getId();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
interval = MapleDataTool.getInt(data) * 60 * 1000;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
boolean check = !chr.getQuest(MapleQuest.getInstance(questID)).getStatus().equals(MapleQuestStatus.Status.COMPLETED);
|
||||
boolean check2 = chr.getQuest(MapleQuest.getInstance(questID)).getCompletionTime() <= System.currentTimeMillis() - interval;
|
||||
return check || check2;
|
||||
}
|
||||
}
|
||||
96
src/server/quest/requirements/ItemRequirement.java
Normal file
96
src/server/quest/requirements/ItemRequirement.java
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.requirements;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.MapleItemInformationProvider;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
import client.MapleCharacter;
|
||||
import client.inventory.Item;
|
||||
import client.inventory.MapleInventoryType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class ItemRequirement extends MapleQuestRequirement {
|
||||
Map<Integer, Integer> items = new HashMap<>();
|
||||
|
||||
|
||||
public ItemRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.ITEM);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
for (MapleData itemEntry : data.getChildren()) {
|
||||
int itemId = MapleDataTool.getInt(itemEntry.getChildByPath("id"));
|
||||
int count = MapleDataTool.getInt(itemEntry.getChildByPath("count"), 0);
|
||||
|
||||
items.put(itemId, count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
for(Integer itemId : items.keySet()) {
|
||||
int countNeeded = items.get(itemId);
|
||||
int count = 0;
|
||||
|
||||
MapleInventoryType iType = ii.getInventoryType(itemId);
|
||||
|
||||
if (iType.equals(MapleInventoryType.UNDEFINED)) {
|
||||
return false;
|
||||
}
|
||||
for (Item item : chr.getInventory(iType).listById(itemId)) {
|
||||
count += item.getQuantity();
|
||||
}
|
||||
//Weird stuff, nexon made some quests only available when wearing gm clothes. This enables us to accept it ><
|
||||
if (iType.equals(MapleInventoryType.EQUIP)) {
|
||||
for (Item item : chr.getInventory(MapleInventoryType.EQUIPPED).listById(itemId)) {
|
||||
count += item.getQuantity();
|
||||
}
|
||||
}
|
||||
|
||||
if(count < countNeeded || countNeeded <= 0 && count > 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getItemAmountNeeded(int itemid) {
|
||||
if(items.containsKey(itemid)) {
|
||||
return items.get(itemid);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
67
src/server/quest/requirements/JobRequirement.java
Normal file
67
src/server/quest/requirements/JobRequirement.java
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.requirements;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
import client.MapleCharacter;
|
||||
import client.MapleJob;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class JobRequirement extends MapleQuestRequirement {
|
||||
List<Integer> jobs = new ArrayList<>();
|
||||
|
||||
public JobRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.JOB);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
for (MapleData jobEntry : data.getChildren()) {
|
||||
jobs.add(MapleDataTool.getInt(jobEntry));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
for(Integer job : jobs) {
|
||||
if (chr.getJob().equals(MapleJob.getById(job)) || chr.isGM()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
56
src/server/quest/requirements/MapleQuestRequirement.java
Normal file
56
src/server/quest/requirements/MapleQuestRequirement.java
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.requirements;
|
||||
|
||||
import provider.MapleData;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
import client.MapleCharacter;
|
||||
|
||||
/**
|
||||
* Base class for a Quest Requirement. Quest system uses it for all requirements.
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public abstract class MapleQuestRequirement {
|
||||
private final MapleQuestRequirementType type;
|
||||
|
||||
public MapleQuestRequirement(MapleQuestRequirementType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the requirement to see if the player currently meets it.
|
||||
* @param chr The {@link MapleCharacter} to check on.
|
||||
* @param npcid The NPC ID it was called from.
|
||||
* @return boolean If the check was passed or not.
|
||||
*/
|
||||
public abstract boolean check(MapleCharacter chr, Integer npcid);
|
||||
|
||||
/**
|
||||
* Processes the data and stores it in the class for future use.
|
||||
* @param data The data to process.
|
||||
*/
|
||||
public abstract void processData(MapleData data);
|
||||
|
||||
public MapleQuestRequirementType getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
57
src/server/quest/requirements/MaxLevelRequirement.java
Normal file
57
src/server/quest/requirements/MaxLevelRequirement.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.requirements;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class MaxLevelRequirement extends MapleQuestRequirement {
|
||||
private int maxLevel;
|
||||
|
||||
|
||||
public MaxLevelRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.MAX_LEVEL);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
maxLevel = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
return maxLevel >= chr.getLevel();
|
||||
}
|
||||
}
|
||||
54
src/server/quest/requirements/MinLevelRequirement.java
Normal file
54
src/server/quest/requirements/MinLevelRequirement.java
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.requirements;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class MinLevelRequirement extends MapleQuestRequirement {
|
||||
private int minLevel;
|
||||
|
||||
|
||||
public MinLevelRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.MIN_LEVEL);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
minLevel = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
return chr.getLevel() >= minLevel;
|
||||
}
|
||||
}
|
||||
67
src/server/quest/requirements/MinTamenessRequirement.java
Normal file
67
src/server/quest/requirements/MinTamenessRequirement.java
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.requirements;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.inventory.MaplePet;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class MinTamenessRequirement extends MapleQuestRequirement {
|
||||
private int minTameness;
|
||||
|
||||
|
||||
public MinTamenessRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.MIN_PET_TAMENESS);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
minTameness = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
int curCloseness = 0;
|
||||
|
||||
for(MaplePet pet : chr.getPets()) {
|
||||
if(pet == null) continue;
|
||||
|
||||
if(pet.getCloseness() > curCloseness)
|
||||
curCloseness = pet.getCloseness();
|
||||
}
|
||||
|
||||
return curCloseness >= minTameness;
|
||||
}
|
||||
}
|
||||
89
src/server/quest/requirements/MobRequirement.java
Normal file
89
src/server/quest/requirements/MobRequirement.java
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.requirements;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
import tools.FilePrinter;
|
||||
import client.MapleCharacter;
|
||||
import client.MapleQuestStatus;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class MobRequirement extends MapleQuestRequirement {
|
||||
Map<Integer, Integer> mobs = new HashMap<>();
|
||||
private int questID;
|
||||
|
||||
public MobRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.MOB);
|
||||
processData(data);
|
||||
questID = quest.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
for (MapleData questEntry : data.getChildren()) {
|
||||
int mobID = MapleDataTool.getInt(questEntry.getChildByPath("id"));
|
||||
int countReq = MapleDataTool.getInt(questEntry.getChildByPath("count"));
|
||||
mobs.put(mobID, countReq);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
MapleQuestStatus status = chr.getQuest(MapleQuest.getInstance(questID));
|
||||
for(Integer mobID : mobs.keySet()) {
|
||||
int countReq = mobs.get(mobID);
|
||||
int progress;
|
||||
|
||||
try {
|
||||
progress = Integer.parseInt(status.getProgress(mobID));
|
||||
} catch (NumberFormatException ex) {
|
||||
FilePrinter.printError(FilePrinter.EXCEPTION_CAUGHT, ex, "Mob: " + mobID + " Quest: " + questID + "CID: " + chr.getId() + " Progress: " + status.getProgress(mobID));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(progress < countReq)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getRequiredMobCount(int mobid) {
|
||||
if(mobs.containsKey(mobid)) {
|
||||
return mobs.get(mobid);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.requirements;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class MonsterBookCountRequirement extends MapleQuestRequirement {
|
||||
private int reqCards;
|
||||
|
||||
|
||||
public MonsterBookCountRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.MONSTER_BOOK);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
reqCards = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
return chr.getMonsterBook().getTotalCards() >= reqCards;
|
||||
}
|
||||
}
|
||||
55
src/server/quest/requirements/NpcRequirement.java
Normal file
55
src/server/quest/requirements/NpcRequirement.java
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.requirements;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class NpcRequirement extends MapleQuestRequirement {
|
||||
private int reqNPC;
|
||||
private final boolean autoComplete, autoStart;
|
||||
|
||||
public NpcRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.NPC);
|
||||
processData(data);
|
||||
this.autoComplete = quest.isAutoComplete();
|
||||
this.autoStart = quest.isAutoStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
reqNPC = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
return npcid != null && npcid == reqNPC && (autoComplete || autoStart || chr.getMap().containsNPC(npcid));
|
||||
}
|
||||
}
|
||||
64
src/server/quest/requirements/PetRequirement.java
Normal file
64
src/server/quest/requirements/PetRequirement.java
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.requirements;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.inventory.MaplePet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class PetRequirement extends MapleQuestRequirement {
|
||||
List<Integer> petIDs = new ArrayList<>();
|
||||
|
||||
|
||||
public PetRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.PET);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
for(MapleData petData : data.getChildren()) {
|
||||
petIDs.add(MapleDataTool.getInt(petData.getChildByPath("id")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
for(MaplePet pet : chr.getPets()) {
|
||||
if(petIDs.contains(pet.getItemId()))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
60
src/server/quest/requirements/QuestRequirement.java
Normal file
60
src/server/quest/requirements/QuestRequirement.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package server.quest.requirements;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
import client.MapleCharacter;
|
||||
import client.MapleQuestStatus;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class QuestRequirement extends MapleQuestRequirement {
|
||||
Map<Integer, Integer> quests = new HashMap<>();
|
||||
|
||||
public QuestRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.QUEST);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
for (MapleData questEntry : data.getChildren()) {
|
||||
int questID = MapleDataTool.getInt(questEntry.getChildByPath("id"));
|
||||
int stateReq = MapleDataTool.getInt(questEntry.getChildByPath("state"));
|
||||
quests.put(questID, stateReq);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
for(Integer questID : quests.keySet()) {
|
||||
int stateReq = quests.get(questID);
|
||||
MapleQuestStatus q = chr.getQuest(MapleQuest.getInstance(questID));
|
||||
|
||||
if(q == null && MapleQuestStatus.Status.getById(stateReq).equals(MapleQuestStatus.Status.NOT_STARTED))
|
||||
continue;
|
||||
|
||||
if(q == null || !q.getStatus().equals(MapleQuestStatus.Status.getById(stateReq))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user