/*
* This file is part of aion-unique <aion-unique.com>.
*
* aion-unique 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.
*
* aion-unique 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 aion-unique. If not, see <http://www.gnu.org/licenses/>.
*/
package com.aionemu.gameserver.skillengine;
import com.aionemu.gameserver.dataholders.DataManager;
import com.aionemu.gameserver.model.gameobjects.Creature;
import com.aionemu.gameserver.model.gameobjects.VisibleObject;
import com.aionemu.gameserver.model.gameobjects.player.Player;
import com.aionemu.gameserver.skillengine.model.ActivationAttribute;
import com.aionemu.gameserver.skillengine.model.Skill;
import com.aionemu.gameserver.skillengine.model.SkillTemplate;
/**
* @author ATracer
*
*/
public class SkillEngine
{
public static final SkillEngine skillEngine = new SkillEngine();
/**
* should not be instantiated directly
*/
private SkillEngine()
{
}
/**
* This method is used for skills that were learned by player
*
* @param player
* @param skillId
* @return Skill
*/
public Skill getSkillFor(Player player, int skillId, VisibleObject firstTarget)
{
SkillTemplate template = DataManager.SKILL_DATA.getSkillTemplate(skillId);
if(template == null)
return null;
// player doesn't have such skill and ist not provoked
if(template.getActivationAttribute() != ActivationAttribute.PROVOKED)
{
if(!player.getSkillList().isSkillPresent(skillId))
return null;
}
Creature target = null;
if(firstTarget instanceof Creature)
target = (Creature) firstTarget;
return new Skill(template, player, target);
}
/**
* This method is used for not learned skills (item skills etc)
*
* @param creature
* @param skillId
* @param skillLevel
* @return Skill
*/
public Skill getSkill(Creature creature, int skillId, int skillLevel, VisibleObject firstTarget)
{
SkillTemplate template = DataManager.SKILL_DATA.getSkillTemplate(skillId);
if(template == null)
return null;
Creature target = null;
if(firstTarget instanceof Creature)
target = (Creature) firstTarget;
return new Skill(template, creature, skillLevel, target);
}
public static SkillEngine getInstance()
{
return skillEngine;
}
}