78 lines
2.8 KiB
Java
78 lines
2.8 KiB
Java
/*
|
|
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 client.inventory;
|
|
|
|
import provider.MapleData;
|
|
import provider.MapleDataProvider;
|
|
import provider.MapleDataProviderFactory;
|
|
import provider.MapleDataTool;
|
|
import provider.wz.WZFiles;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
*
|
|
* @author Danny (Leifde)
|
|
*/
|
|
public class PetDataFactory {
|
|
private static MapleDataProvider dataRoot = MapleDataProviderFactory.getDataProvider(WZFiles.ITEM);
|
|
private static Map<String, PetCommand> petCommands = new HashMap<>();
|
|
private static Map<Integer, Integer> petHunger = new HashMap<>();
|
|
|
|
public static PetCommand getPetCommand(int petId, int skillId) {
|
|
PetCommand ret = petCommands.get(petId + "" + skillId);
|
|
if (ret != null) {
|
|
return ret;
|
|
}
|
|
synchronized (petCommands) {
|
|
ret = petCommands.get(petId + "" + skillId);
|
|
if (ret == null) {
|
|
MapleData skillData = dataRoot.getData("Pet/" + petId + ".img");
|
|
int prob = 0;
|
|
int inc = 0;
|
|
if (skillData != null) {
|
|
prob = MapleDataTool.getInt("interact/" + skillId + "/prob", skillData, 0);
|
|
inc = MapleDataTool.getInt("interact/" + skillId + "/inc", skillData, 0);
|
|
}
|
|
ret = new PetCommand(petId, skillId, prob, inc);
|
|
petCommands.put(petId + "" + skillId, ret);
|
|
}
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
public static int getHunger(int petId) {
|
|
Integer ret = petHunger.get(petId);
|
|
if (ret != null) {
|
|
return ret;
|
|
}
|
|
synchronized (petHunger) {
|
|
ret = petHunger.get(petId);
|
|
if (ret == null) {
|
|
ret = MapleDataTool.getInt(dataRoot.getData("Pet/" + petId + ".img").getChildByPath("info/hungry"), 1);
|
|
}
|
|
return ret;
|
|
}
|
|
}
|
|
}
|