/* This file is part of the OdinMS Maple Story Server Copyright (C) 2008 Patrick Huy Matthias Butz Jan Christian Meyer 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 . */ package client.inventory; import provider.MapleData; import provider.MapleDataProvider; import provider.MapleDataProviderFactory; import provider.MapleDataTool; import java.io.File; import java.util.HashMap; import java.util.Map; /** * * @author Danny (Leifde) */ public class PetDataFactory { private static MapleDataProvider dataRoot = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/Item.wz")); private static Map petCommands = new HashMap<>(); private static Map 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; } } }