1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-11 09:42:54 +00:00

Semi-working attack service

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-05-30 20:02:19 -03:00
parent 52d4be0bf2
commit ae3007559f
61 changed files with 537 additions and 181 deletions

View File

@@ -28,6 +28,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.l2jserver.model.id.template.ItemTemplateID;
import com.l2jserver.model.template.calculator.ItemPhysicalDamageActorCalculator;
import com.l2jserver.model.world.Item;
import com.l2jserver.util.jaxb.ItemTemplateIDAdapter;
@@ -58,15 +59,26 @@ public class ItemTemplate extends AbstractTemplate<Item> {
protected int price = 0;
@XmlElement(name = "icon")
protected String icon;
@XmlElement(name = "weight")
@XmlElement(name = "effect")
protected EffectContainer effect;
@XmlType(namespace = "item")
private static class EffectContainer {
@XmlAttribute(name = "type")
protected EffectType effect = null;
protected EffectType effect;
}
@XmlType(namespace = "item")
protected static class StatsContainer {
@XmlElement(name = "physicalDamage")
protected StatAttribute physicalDamage;
@XmlElement(name = "magicalDamage")
protected StatAttribute magicalDamage;
}
@XmlElement(name = "stats")
protected StatsContainer stats;
protected ItemMaterial material;
public enum ItemMaterial {
@@ -77,6 +89,38 @@ public class ItemTemplate extends AbstractTemplate<Item> {
IMMEDIATE;
}
@XmlType(namespace = "item")
public static class StatAttribute {
@XmlElement(name = "set")
protected StatSet set;
public static class StatSet {
protected int order;
protected double value;
/**
* @return the order
*/
public int getOrder() {
return order;
}
/**
* @return the value
*/
public double getValue() {
return value;
}
}
/**
* @return the set
*/
public StatSet getSet() {
return set;
}
}
@Override
public Item create() {
log.debug("Creating a new Item instance with template {}", this);
@@ -125,6 +169,24 @@ public class ItemTemplate extends AbstractTemplate<Item> {
return material;
}
/**
* @return the physical damage
*/
public ItemPhysicalDamageActorCalculator getPhysicalDamage() {
if (stats == null)
return null;
return new ItemPhysicalDamageActorCalculator(stats.physicalDamage.set);
}
/**
* @return the magical damage
*/
public StatAttribute getMagicalDamage() {
if (stats == null)
return null;
return stats.magicalDamage;
}
/*
* (non-Javadoc)
*

View File

@@ -0,0 +1,38 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver 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.
*
* l2jserver 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 l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.template.calculator;
import com.l2jserver.model.template.ActorTemplate;
import com.l2jserver.model.template.ItemTemplate.StatAttribute.StatSet;
import com.l2jserver.model.world.Actor;
import com.l2jserver.model.world.actor.calculator.ActorCalculator;
import com.l2jserver.model.world.actor.calculator.ActorCalculatorFunction;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class ItemPhysicalDamageActorCalculator extends ActorCalculator {
public ItemPhysicalDamageActorCalculator(final StatSet set) {
super(new ActorCalculatorFunction(set.getOrder()) {
@Override
protected double calculate(Actor a, ActorTemplate<?> t, double value) {
return set.getValue();
}
});
}
}