mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-06 07:32:46 +00:00
@@ -146,14 +146,14 @@ public class CharacterInformationBroadcastPacket extends AbstractServerPacket {
|
|||||||
buffer.writeInt(0x00); // unk
|
buffer.writeInt(0x00); // unk
|
||||||
|
|
||||||
// FIXME half of those are walk speed
|
// FIXME half of those are walk speed
|
||||||
buffer.writeInt((int) character.getStats().getRunSpeed());
|
buffer.writeInt(character.getStats().getRunSpeed());
|
||||||
buffer.writeInt((int) character.getStats().getRunSpeed());
|
buffer.writeInt(character.getStats().getRunSpeed());
|
||||||
buffer.writeInt((int) character.getStats().getRunSpeed());
|
buffer.writeInt(character.getStats().getRunSpeed());
|
||||||
buffer.writeInt((int) character.getStats().getRunSpeed());
|
buffer.writeInt(character.getStats().getRunSpeed());
|
||||||
buffer.writeInt((int) character.getStats().getRunSpeed());
|
buffer.writeInt(character.getStats().getRunSpeed());
|
||||||
buffer.writeInt((int) character.getStats().getRunSpeed());
|
buffer.writeInt(character.getStats().getRunSpeed());
|
||||||
buffer.writeInt((int) character.getStats().getRunSpeed());
|
buffer.writeInt(character.getStats().getRunSpeed());
|
||||||
buffer.writeInt((int) character.getStats().getRunSpeed());
|
buffer.writeInt(character.getStats().getRunSpeed());
|
||||||
|
|
||||||
buffer.writeDouble(0x01); // move speed multiplier
|
buffer.writeDouble(0x01); // move speed multiplier
|
||||||
buffer.writeDouble(0x01); // attack speed multiplier
|
buffer.writeDouble(0x01); // attack speed multiplier
|
||||||
|
|||||||
@@ -205,10 +205,10 @@ public class CharacterInformationPacket extends AbstractServerPacket {
|
|||||||
buffer.writeInt(0x00); // 0-non-pvp 1-pvp = violett name
|
buffer.writeInt(0x00); // 0-non-pvp 1-pvp = violett name
|
||||||
buffer.writeInt(character.getKarma()); // karma
|
buffer.writeInt(character.getKarma()); // karma
|
||||||
|
|
||||||
buffer.writeInt((int) character.getStats().getRunSpeed());
|
buffer.writeInt(character.getStats().getRunSpeed());
|
||||||
buffer.writeInt((int) character.getStats().getWalkSpeed());
|
buffer.writeInt(character.getStats().getWalkSpeed());
|
||||||
buffer.writeInt((int) character.getStats().getRunSpeed());
|
buffer.writeInt(character.getStats().getRunSpeed());
|
||||||
buffer.writeInt((int) character.getStats().getWalkSpeed());
|
buffer.writeInt(character.getStats().getWalkSpeed());
|
||||||
buffer.writeInt(0); // unk
|
buffer.writeInt(0); // unk
|
||||||
buffer.writeInt(0); // unk
|
buffer.writeInt(0); // unk
|
||||||
buffer.writeInt(0); // fly speed -only if flying
|
buffer.writeInt(0); // fly speed -only if flying
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import org.jboss.netty.buffer.ChannelBuffer;
|
|||||||
import com.l2jserver.game.net.Lineage2Connection;
|
import com.l2jserver.game.net.Lineage2Connection;
|
||||||
import com.l2jserver.game.net.packet.AbstractServerPacket;
|
import com.l2jserver.game.net.packet.AbstractServerPacket;
|
||||||
import com.l2jserver.model.template.NPCTemplate;
|
import com.l2jserver.model.template.NPCTemplate;
|
||||||
import com.l2jserver.model.world.L2Character;
|
|
||||||
import com.l2jserver.model.world.NPC;
|
import com.l2jserver.model.world.NPC;
|
||||||
import com.l2jserver.util.BufferUtils;
|
import com.l2jserver.util.BufferUtils;
|
||||||
|
|
||||||
@@ -50,7 +49,7 @@ public class NPCInformationPacket extends AbstractServerPacket {
|
|||||||
buffer.writeInt(npc.getID().getID());
|
buffer.writeInt(npc.getID().getID());
|
||||||
buffer.writeInt(template.getID().getID() + 1000000); // npctype id
|
buffer.writeInt(template.getID().getID() + 1000000); // npctype id
|
||||||
if (npc instanceof NPC) {
|
if (npc instanceof NPC) {
|
||||||
buffer.writeInt((((NPCTemplate) template).isAttackable() ? 0x01
|
buffer.writeInt(((template).isAttackable() ? 0x01
|
||||||
: 0x00));
|
: 0x00));
|
||||||
} else {
|
} else {
|
||||||
buffer.writeInt(0x01);
|
buffer.writeInt(0x01);
|
||||||
@@ -84,8 +83,8 @@ public class NPCInformationPacket extends AbstractServerPacket {
|
|||||||
buffer.writeByte(0x00); // is in combat
|
buffer.writeByte(0x00); // is in combat
|
||||||
buffer.writeByte(0x00); // is like dead (faking)
|
buffer.writeByte(0x00); // is like dead (faking)
|
||||||
buffer.writeByte(0x00); // 0=teleported 1=default 2=summoned
|
buffer.writeByte(0x00); // 0=teleported 1=default 2=summoned
|
||||||
BufferUtils.writeString(buffer, ((NPCTemplate) template).getName());
|
BufferUtils.writeString(buffer, (template).getName());
|
||||||
BufferUtils.writeString(buffer, ((NPCTemplate) template).getTitle());
|
BufferUtils.writeString(buffer, (template).getTitle());
|
||||||
buffer.writeInt(0x00); // Title color 0=client default
|
buffer.writeInt(0x00); // Title color 0=client default
|
||||||
buffer.writeInt(0x00); // pvp flag
|
buffer.writeInt(0x00); // pvp flag
|
||||||
buffer.writeInt(0x00); // karma
|
buffer.writeInt(0x00); // karma
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package com.l2jserver.model.template;
|
package com.l2jserver.model.template;
|
||||||
|
|
||||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||||
|
import com.l2jserver.model.world.Actor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Template for effects
|
* Template for effects
|
||||||
@@ -33,6 +34,16 @@ public abstract class EffectTemplate extends AbstractTemplate<Object> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds this effect to the given <tt>actor</tt>
|
||||||
|
*
|
||||||
|
* @param actor
|
||||||
|
* the actor
|
||||||
|
*/
|
||||||
|
public void apply(Actor actor) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemTemplateID getID() {
|
public ItemTemplateID getID() {
|
||||||
return (ItemTemplateID) super.getID();
|
return (ItemTemplateID) super.getID();
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ public class NPC extends Actor {
|
|||||||
/**
|
/**
|
||||||
* @return the NPC template ID
|
* @return the NPC template ID
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public NPCTemplateID getTemplateID() {
|
public NPCTemplateID getTemplateID() {
|
||||||
return (NPCTemplateID) templateID;
|
return (NPCTemplateID) templateID;
|
||||||
}
|
}
|
||||||
@@ -106,6 +107,7 @@ public class NPC extends Actor {
|
|||||||
/**
|
/**
|
||||||
* @return the NPC template
|
* @return the NPC template
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public NPCTemplate getTemplate() {
|
public NPCTemplate getTemplate() {
|
||||||
return (NPCTemplate) templateID.getTemplate();
|
return (NPCTemplate) templateID.getTemplate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package com.l2jserver.model.world.actor.stat;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.l2jserver.model.world.Actor;
|
||||||
import com.l2jserver.util.calculator.Calculator;
|
import com.l2jserver.util.calculator.Calculator;
|
||||||
import com.l2jserver.util.calculator.CalculatorContext;
|
|
||||||
import com.l2jserver.util.calculator.DivisionFunction;
|
import com.l2jserver.util.calculator.DivisionFunction;
|
||||||
import com.l2jserver.util.calculator.Function;
|
import com.l2jserver.util.calculator.Function;
|
||||||
import com.l2jserver.util.calculator.MultiplicationFunction;
|
import com.l2jserver.util.calculator.MultiplicationFunction;
|
||||||
@@ -136,7 +136,7 @@ public class Stats {
|
|||||||
// PHYSICAL_ATTACK_SPEED;
|
// PHYSICAL_ATTACK_SPEED;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Map<StatType, List<Function<CalculatorContext>>> operations = CollectionFactory
|
private final Map<StatType, List<Function<Actor>>> operations = CollectionFactory
|
||||||
.newMap();
|
.newMap();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -150,7 +150,7 @@ public class Stats {
|
|||||||
* the value to set
|
* the value to set
|
||||||
*/
|
*/
|
||||||
public void set(Stats.StatType type, int order, double value) {
|
public void set(Stats.StatType type, int order, double value) {
|
||||||
func(type, new SetFunction(order, value));
|
func(type, new SetFunction<Actor>(order, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -164,7 +164,7 @@ public class Stats {
|
|||||||
* the value to be summed
|
* the value to be summed
|
||||||
*/
|
*/
|
||||||
public void add(Stats.StatType type, int order, double value) {
|
public void add(Stats.StatType type, int order, double value) {
|
||||||
func(type, new SumFunction(order, value));
|
func(type, new SumFunction<Actor>(order, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -178,7 +178,7 @@ public class Stats {
|
|||||||
* the value to be subtracted
|
* the value to be subtracted
|
||||||
*/
|
*/
|
||||||
public void sub(Stats.StatType type, int order, double value) {
|
public void sub(Stats.StatType type, int order, double value) {
|
||||||
func(type, new SubtractFunction(order, value));
|
func(type, new SubtractFunction<Actor>(order, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -192,7 +192,7 @@ public class Stats {
|
|||||||
* the value to be multiplied
|
* the value to be multiplied
|
||||||
*/
|
*/
|
||||||
public void mult(Stats.StatType type, int order, double value) {
|
public void mult(Stats.StatType type, int order, double value) {
|
||||||
func(type, new MultiplicationFunction(order, value));
|
func(type, new MultiplicationFunction<Actor>(order, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -206,7 +206,7 @@ public class Stats {
|
|||||||
* the value to be divided by
|
* the value to be divided by
|
||||||
*/
|
*/
|
||||||
public void div(Stats.StatType type, int order, double value) {
|
public void div(Stats.StatType type, int order, double value) {
|
||||||
func(type, new DivisionFunction(order, value));
|
func(type, new DivisionFunction<Actor>(order, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -223,7 +223,7 @@ public class Stats {
|
|||||||
// TODO enchant operation for weapon
|
// TODO enchant operation for weapon
|
||||||
}
|
}
|
||||||
|
|
||||||
public void func(StatType type, Function<CalculatorContext> function) {
|
public void func(StatType type, Function<Actor> function) {
|
||||||
getMap(type).add(function);
|
getMap(type).add(function);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,8 +234,8 @@ public class Stats {
|
|||||||
* the type
|
* the type
|
||||||
* @return the order-operation map
|
* @return the order-operation map
|
||||||
*/
|
*/
|
||||||
private List<Function<CalculatorContext>> getMap(Stats.StatType type) {
|
private List<Function<Actor>> getMap(Stats.StatType type) {
|
||||||
List<Function<CalculatorContext>> list = operations.get(type);
|
List<Function<Actor>> list = operations.get(type);
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
list = CollectionFactory.newList();
|
list = CollectionFactory.newList();
|
||||||
operations.put(type, list);
|
operations.put(type, list);
|
||||||
@@ -251,13 +251,11 @@ public class Stats {
|
|||||||
* @param calculator
|
* @param calculator
|
||||||
* the calculator
|
* the calculator
|
||||||
*/
|
*/
|
||||||
public void calculator(Stats.StatType type,
|
public void calculator(Stats.StatType type, Calculator<Actor> calculator) {
|
||||||
Calculator<CalculatorContext> calculator) {
|
final List<Function<Actor>> operations = this.operations.get(type);
|
||||||
final List<Function<CalculatorContext>> operations = this.operations
|
|
||||||
.get(type);
|
|
||||||
if (operations == null || operations.size() == 0)
|
if (operations == null || operations.size() == 0)
|
||||||
return;
|
return;
|
||||||
for (final Function<CalculatorContext> func : operations) {
|
for (final Function<Actor> func : operations) {
|
||||||
calculator.add(func);
|
calculator.add(func);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,13 +77,13 @@ public class CharacterStats {
|
|||||||
|
|
||||||
private final L2Character character;
|
private final L2Character character;
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private final Calculator<CharacterCalculatorContext>[] calculators = new Calculator[StatType
|
private final Calculator<L2Character>[] calculators = new Calculator[StatType
|
||||||
.values().length];
|
.values().length];
|
||||||
|
|
||||||
public CharacterStats(L2Character character) {
|
public CharacterStats(L2Character character) {
|
||||||
this.character = character;
|
this.character = character;
|
||||||
for (int i = 0; i < calculators.length; i++) {
|
for (int i = 0; i < calculators.length; i++) {
|
||||||
calculators[i] = new Calculator<CharacterCalculatorContext>();
|
calculators[i] = new Calculator<L2Character>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// bind default functions
|
// bind default functions
|
||||||
@@ -217,14 +217,14 @@ public class CharacterStats {
|
|||||||
// getCalculator(type).importFunctions(calculator);
|
// getCalculator(type).importFunctions(calculator);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
protected Calculator<CharacterCalculatorContext> getCalculator(StatType type) {
|
protected Calculator<L2Character> getCalculator(StatType type) {
|
||||||
return calculators[type.ordinal()];
|
return calculators[type.ordinal()];
|
||||||
}
|
}
|
||||||
|
|
||||||
public double calc(StatType type) {
|
public double calc(StatType type) {
|
||||||
final CharacterCalculatorContext ctx = new CharacterCalculatorContext(
|
final CharacterCalculatorContext ctx = new CharacterCalculatorContext(
|
||||||
character);
|
character);
|
||||||
getCalculator(type).calculate(ctx);
|
getCalculator(type).calculate(character, ctx);
|
||||||
return ctx.result;
|
return ctx.result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import org.apache.commons.math.util.FastMath;
|
|||||||
|
|
||||||
import com.l2jserver.model.world.L2Character;
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.util.calculator.AbstractFunction;
|
import com.l2jserver.util.calculator.AbstractFunction;
|
||||||
|
import com.l2jserver.util.calculator.CalculatorContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
@@ -28,15 +29,14 @@ import com.l2jserver.util.calculator.AbstractFunction;
|
|||||||
public class BaseAttackAccuracyCalculator extends CharacterCalculator {
|
public class BaseAttackAccuracyCalculator extends CharacterCalculator {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BaseAttackAccuracyCalculator() {
|
public BaseAttackAccuracyCalculator() {
|
||||||
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
|
super(new AbstractFunction<L2Character>(0x000) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result = ctx.character.getTemplate().getAccuracy();
|
ctx.result = c.getTemplate().getAccuracy();
|
||||||
}
|
}
|
||||||
}, new AbstractFunction<CharacterCalculatorContext>(0x100) {
|
}, new AbstractFunction<L2Character>(0x100) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
final L2Character c = ctx.character;
|
|
||||||
final int level = c.getLevel();
|
final int level = c.getLevel();
|
||||||
|
|
||||||
ctx.result += FastMath.sqrt(c.getStats().getDexterity()) * 6;
|
ctx.result += FastMath.sqrt(c.getStats().getDexterity()) * 6;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import org.apache.commons.math.util.FastMath;
|
|||||||
|
|
||||||
import com.l2jserver.model.world.L2Character;
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.util.calculator.AbstractFunction;
|
import com.l2jserver.util.calculator.AbstractFunction;
|
||||||
|
import com.l2jserver.util.calculator.CalculatorContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
@@ -28,15 +29,14 @@ import com.l2jserver.util.calculator.AbstractFunction;
|
|||||||
public class BaseAttackEvasionCalculator extends CharacterCalculator {
|
public class BaseAttackEvasionCalculator extends CharacterCalculator {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BaseAttackEvasionCalculator() {
|
public BaseAttackEvasionCalculator() {
|
||||||
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
|
super(new AbstractFunction<L2Character>(0x000) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result = ctx.character.getTemplate().getEvasionChance();
|
ctx.result = c.getTemplate().getEvasionChance();
|
||||||
}
|
}
|
||||||
}, new AbstractFunction<CharacterCalculatorContext>(0x100) {
|
}, new AbstractFunction<L2Character>(0x100) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
final L2Character c = ctx.character;
|
|
||||||
final int level = c.getLevel();
|
final int level = c.getLevel();
|
||||||
|
|
||||||
ctx.result += FastMath.sqrt(c.getStats().getDexterity()) * 6;
|
ctx.result += FastMath.sqrt(c.getStats().getDexterity()) * 6;
|
||||||
|
|||||||
@@ -17,8 +17,10 @@
|
|||||||
package com.l2jserver.model.world.character.calculator;
|
package com.l2jserver.model.world.character.calculator;
|
||||||
|
|
||||||
import com.l2jserver.model.template.CharacterTemplate;
|
import com.l2jserver.model.template.CharacterTemplate;
|
||||||
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||||
import com.l2jserver.util.calculator.AbstractFunction;
|
import com.l2jserver.util.calculator.AbstractFunction;
|
||||||
|
import com.l2jserver.util.calculator.CalculatorContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
@@ -27,28 +29,28 @@ import com.l2jserver.util.calculator.AbstractFunction;
|
|||||||
public class BaseCPCalculator extends CharacterCalculator {
|
public class BaseCPCalculator extends CharacterCalculator {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BaseCPCalculator() {
|
public BaseCPCalculator() {
|
||||||
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
|
super(new AbstractFunction<L2Character>(0x000) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result = ctx.character.getTemplate().getCpBase();
|
ctx.result = c.getTemplate().getCpBase();
|
||||||
}
|
}
|
||||||
}, new AbstractFunction<CharacterCalculatorContext>(0x100) {
|
}, new AbstractFunction<L2Character>(0x100) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
final CharacterTemplate template = ctx.character.getTemplate();
|
final CharacterTemplate template = c.getTemplate();
|
||||||
|
|
||||||
int lvl = ctx.character.getLevel() - template.getMinimumLevel();
|
int lvl = c.getLevel() - template.getMinimumLevel();
|
||||||
double mod = template.getCpMultiplier() * lvl;
|
double mod = template.getCpMultiplier() * lvl;
|
||||||
double max = (template.getCpAdd() + mod) * lvl;
|
double max = (template.getCpAdd() + mod) * lvl;
|
||||||
double min = (template.getCpAdd() * lvl) + mod;
|
double min = (template.getCpAdd() * lvl) + mod;
|
||||||
|
|
||||||
ctx.result += (max + min) / 2;
|
ctx.result += (max + min) / 2;
|
||||||
}
|
}
|
||||||
}, new AbstractFunction<CharacterCalculatorContext>(0x200) {
|
}, new AbstractFunction<L2Character>(0x200) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result *= BaseStats.CON.calculateBonus(ctx.character
|
ctx.result *= BaseStats.CON.calculateBonus(c.getStats()
|
||||||
.getStats().getConcentration());
|
.getConcentration());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.model.world.character.calculator;
|
package com.l2jserver.model.world.character.calculator;
|
||||||
|
|
||||||
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.util.calculator.AbstractFunction;
|
import com.l2jserver.util.calculator.AbstractFunction;
|
||||||
|
import com.l2jserver.util.calculator.CalculatorContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
@@ -24,10 +26,10 @@ import com.l2jserver.util.calculator.AbstractFunction;
|
|||||||
public class BaseConcentrationCalculator extends CharacterCalculator {
|
public class BaseConcentrationCalculator extends CharacterCalculator {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BaseConcentrationCalculator() {
|
public BaseConcentrationCalculator() {
|
||||||
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
|
super(new AbstractFunction<L2Character>(0x000) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result = ctx.character.getTemplate().getConcentration();
|
ctx.result = c.getTemplate().getConcentration();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,19 +16,20 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.model.world.character.calculator;
|
package com.l2jserver.model.world.character.calculator;
|
||||||
|
|
||||||
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.util.calculator.AbstractFunction;
|
import com.l2jserver.util.calculator.AbstractFunction;
|
||||||
|
import com.l2jserver.util.calculator.CalculatorContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public class BaseDexterityCalculator extends
|
public class BaseDexterityCalculator extends CharacterCalculator {
|
||||||
CharacterCalculator {
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BaseDexterityCalculator() {
|
public BaseDexterityCalculator() {
|
||||||
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
|
super(new AbstractFunction<L2Character>(0x000) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result = ctx.character.getTemplate().getDextry();
|
ctx.result = c.getTemplate().getDextry();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,10 @@
|
|||||||
package com.l2jserver.model.world.character.calculator;
|
package com.l2jserver.model.world.character.calculator;
|
||||||
|
|
||||||
import com.l2jserver.model.template.CharacterTemplate;
|
import com.l2jserver.model.template.CharacterTemplate;
|
||||||
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||||
import com.l2jserver.util.calculator.AbstractFunction;
|
import com.l2jserver.util.calculator.AbstractFunction;
|
||||||
|
import com.l2jserver.util.calculator.CalculatorContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
@@ -27,28 +29,28 @@ import com.l2jserver.util.calculator.AbstractFunction;
|
|||||||
public class BaseHPCalculator extends CharacterCalculator {
|
public class BaseHPCalculator extends CharacterCalculator {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BaseHPCalculator() {
|
public BaseHPCalculator() {
|
||||||
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
|
super(new AbstractFunction<L2Character>(0x000) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result = ctx.character.getTemplate().getHpBase();
|
ctx.result = c.getTemplate().getHpBase();
|
||||||
}
|
}
|
||||||
}, new AbstractFunction<CharacterCalculatorContext>(0x100) {
|
}, new AbstractFunction<L2Character>(0x100) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
final CharacterTemplate template = ctx.character.getTemplate();
|
final CharacterTemplate template = c.getTemplate();
|
||||||
|
|
||||||
int lvl = ctx.character.getLevel() - template.getMinimumLevel();
|
int lvl = c.getLevel() - template.getMinimumLevel();
|
||||||
double mod = template.getHpMultiplier() * lvl;
|
double mod = template.getHpMultiplier() * lvl;
|
||||||
double max = (template.getHpAdd() + mod) * lvl;
|
double max = (template.getHpAdd() + mod) * lvl;
|
||||||
double min = (template.getHpAdd() * lvl) + mod;
|
double min = (template.getHpAdd() * lvl) + mod;
|
||||||
|
|
||||||
ctx.result += (max + min) / 2;
|
ctx.result += (max + min) / 2;
|
||||||
}
|
}
|
||||||
}, new AbstractFunction<CharacterCalculatorContext>(0x200) {
|
}, new AbstractFunction<L2Character>(0x200) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result *= BaseStats.CON.calculateBonus(ctx.character
|
ctx.result *= BaseStats.CON.calculateBonus(c.getStats()
|
||||||
.getStats().getConcentration());
|
.getConcentration());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.model.world.character.calculator;
|
package com.l2jserver.model.world.character.calculator;
|
||||||
|
|
||||||
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.util.calculator.AbstractFunction;
|
import com.l2jserver.util.calculator.AbstractFunction;
|
||||||
|
import com.l2jserver.util.calculator.CalculatorContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
@@ -24,10 +26,10 @@ import com.l2jserver.util.calculator.AbstractFunction;
|
|||||||
public class BaseIntelligenceCalculator extends CharacterCalculator {
|
public class BaseIntelligenceCalculator extends CharacterCalculator {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BaseIntelligenceCalculator() {
|
public BaseIntelligenceCalculator() {
|
||||||
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
|
super(new AbstractFunction<L2Character>(0x000) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result = ctx.character.getTemplate().getIntelligence();
|
ctx.result = c.getTemplate().getIntelligence();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,10 @@
|
|||||||
package com.l2jserver.model.world.character.calculator;
|
package com.l2jserver.model.world.character.calculator;
|
||||||
|
|
||||||
import com.l2jserver.model.template.CharacterTemplate;
|
import com.l2jserver.model.template.CharacterTemplate;
|
||||||
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||||
import com.l2jserver.util.calculator.AbstractFunction;
|
import com.l2jserver.util.calculator.AbstractFunction;
|
||||||
|
import com.l2jserver.util.calculator.CalculatorContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
@@ -27,28 +29,28 @@ import com.l2jserver.util.calculator.AbstractFunction;
|
|||||||
public class BaseMPCalculator extends CharacterCalculator {
|
public class BaseMPCalculator extends CharacterCalculator {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BaseMPCalculator() {
|
public BaseMPCalculator() {
|
||||||
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
|
super(new AbstractFunction<L2Character>(0x000) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result = ctx.character.getTemplate().getMpBase();
|
ctx.result = c.getTemplate().getMpBase();
|
||||||
}
|
}
|
||||||
}, new AbstractFunction<CharacterCalculatorContext>(0x100) {
|
}, new AbstractFunction<L2Character>(0x100) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
final CharacterTemplate template = ctx.character.getTemplate();
|
final CharacterTemplate template = c.getTemplate();
|
||||||
|
|
||||||
int lvl = ctx.character.getLevel() - template.getMinimumLevel();
|
int lvl = c.getLevel() - template.getMinimumLevel();
|
||||||
double mod = template.getMpMultiplier() * lvl;
|
double mod = template.getMpMultiplier() * lvl;
|
||||||
double max = (template.getMpAdd() + mod) * lvl;
|
double max = (template.getMpAdd() + mod) * lvl;
|
||||||
double min = (template.getMpAdd() * lvl) + mod;
|
double min = (template.getMpAdd() * lvl) + mod;
|
||||||
|
|
||||||
ctx.result += (max + min) / 2;
|
ctx.result += (max + min) / 2;
|
||||||
}
|
}
|
||||||
}, new AbstractFunction<CharacterCalculatorContext>(0x200) {
|
}, new AbstractFunction<L2Character>(0x200) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result *= BaseStats.MEN.calculateBonus(ctx.character
|
ctx.result *= BaseStats.MEN.calculateBonus(c.getStats()
|
||||||
.getStats().getMentality());
|
.getMentality());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package com.l2jserver.model.world.character.calculator;
|
|||||||
import com.l2jserver.model.world.L2Character;
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||||
import com.l2jserver.util.calculator.AbstractFunction;
|
import com.l2jserver.util.calculator.AbstractFunction;
|
||||||
|
import com.l2jserver.util.calculator.CalculatorContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
@@ -27,15 +28,14 @@ import com.l2jserver.util.calculator.AbstractFunction;
|
|||||||
public class BaseMagicalAttackCalculator extends CharacterCalculator {
|
public class BaseMagicalAttackCalculator extends CharacterCalculator {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BaseMagicalAttackCalculator() {
|
public BaseMagicalAttackCalculator() {
|
||||||
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
|
super(new AbstractFunction<L2Character>(0x000) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result = ctx.character.getTemplate().getMagicalAttack();
|
ctx.result = c.getTemplate().getMagicalAttack();
|
||||||
}
|
}
|
||||||
}, new AbstractFunction<CharacterCalculatorContext>(0x200) {
|
}, new AbstractFunction<L2Character>(0x200) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
final L2Character c = ctx.character;
|
|
||||||
ctx.result *= Math
|
ctx.result *= Math
|
||||||
.pow(((100.0 - 11 + c.getLevel()) / 100.0), 2)
|
.pow(((100.0 - 11 + c.getLevel()) / 100.0), 2)
|
||||||
* Math.pow(BaseStats.INT.calculateBonus(c.getStats()
|
* Math.pow(BaseStats.INT.calculateBonus(c.getStats()
|
||||||
|
|||||||
@@ -16,8 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.model.world.character.calculator;
|
package com.l2jserver.model.world.character.calculator;
|
||||||
|
|
||||||
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||||
import com.l2jserver.util.calculator.AbstractFunction;
|
import com.l2jserver.util.calculator.AbstractFunction;
|
||||||
|
import com.l2jserver.util.calculator.CalculatorContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
@@ -26,16 +28,16 @@ import com.l2jserver.util.calculator.AbstractFunction;
|
|||||||
public class BaseMagicalAttackSpeedCalculator extends CharacterCalculator {
|
public class BaseMagicalAttackSpeedCalculator extends CharacterCalculator {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BaseMagicalAttackSpeedCalculator() {
|
public BaseMagicalAttackSpeedCalculator() {
|
||||||
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
|
super(new AbstractFunction<L2Character>(0x000) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result = ctx.character.getTemplate().getCastSpeed();
|
ctx.result = c.getTemplate().getCastSpeed();
|
||||||
}
|
}
|
||||||
}, new AbstractFunction<CharacterCalculatorContext>(0x200) {
|
}, new AbstractFunction<L2Character>(0x200) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result *= BaseStats.WIT.calculateBonus(ctx.character
|
ctx.result *= BaseStats.WIT.calculateBonus(c.getStats()
|
||||||
.getStats().getWitness());
|
.getWitness());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package com.l2jserver.model.world.character.calculator;
|
|||||||
import com.l2jserver.model.world.L2Character;
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||||
import com.l2jserver.util.calculator.AbstractFunction;
|
import com.l2jserver.util.calculator.AbstractFunction;
|
||||||
|
import com.l2jserver.util.calculator.CalculatorContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
@@ -26,17 +27,15 @@ import com.l2jserver.util.calculator.AbstractFunction;
|
|||||||
public class BaseMagicalCriticalRateCalculator extends CharacterCalculator {
|
public class BaseMagicalCriticalRateCalculator extends CharacterCalculator {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BaseMagicalCriticalRateCalculator() {
|
public BaseMagicalCriticalRateCalculator() {
|
||||||
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
|
super(new AbstractFunction<L2Character>(0x000) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
// XXX is the same as physical????
|
// XXX is the same as physical????
|
||||||
ctx.result = ctx.character.getTemplate().getCriticalChance();
|
ctx.result = c.getTemplate().getCriticalChance();
|
||||||
}
|
}
|
||||||
}, new AbstractFunction<CharacterCalculatorContext>(0x300) {
|
}, new AbstractFunction<L2Character>(0x300) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
final L2Character c = ctx.character;
|
|
||||||
|
|
||||||
// TODO only apply if using a weapon
|
// TODO only apply if using a weapon
|
||||||
ctx.result *= BaseStats.WIT.calculateBonus(c.getStats()
|
ctx.result *= BaseStats.WIT.calculateBonus(c.getStats()
|
||||||
.getWitness());
|
.getWitness());
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import com.l2jserver.model.world.L2Character;
|
|||||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||||
import com.l2jserver.model.world.character.CharacterInventory;
|
import com.l2jserver.model.world.character.CharacterInventory;
|
||||||
import com.l2jserver.util.calculator.AbstractFunction;
|
import com.l2jserver.util.calculator.AbstractFunction;
|
||||||
|
import com.l2jserver.util.calculator.CalculatorContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
@@ -33,15 +34,14 @@ import com.l2jserver.util.calculator.AbstractFunction;
|
|||||||
public class BaseMagicalDefenseCalculator extends CharacterCalculator {
|
public class BaseMagicalDefenseCalculator extends CharacterCalculator {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BaseMagicalDefenseCalculator() {
|
public BaseMagicalDefenseCalculator() {
|
||||||
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
|
super(new AbstractFunction<L2Character>(0x000) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result = ctx.character.getTemplate().getMagicalDefense();
|
ctx.result = c.getTemplate().getMagicalDefense();
|
||||||
}
|
}
|
||||||
}, new AbstractFunction<CharacterCalculatorContext>(0x200) {
|
}, new AbstractFunction<L2Character>(0x200) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
final L2Character c = ctx.character;
|
|
||||||
final CharacterInventory inv = c.getInventory();
|
final CharacterInventory inv = c.getInventory();
|
||||||
|
|
||||||
if (inv.has(LEFT_FINGER))
|
if (inv.has(LEFT_FINGER))
|
||||||
|
|||||||
@@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.model.world.character.calculator;
|
package com.l2jserver.model.world.character.calculator;
|
||||||
|
|
||||||
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.util.calculator.AbstractFunction;
|
import com.l2jserver.util.calculator.AbstractFunction;
|
||||||
|
import com.l2jserver.util.calculator.CalculatorContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
@@ -24,10 +26,10 @@ import com.l2jserver.util.calculator.AbstractFunction;
|
|||||||
public class BaseMentalityCalculator extends CharacterCalculator {
|
public class BaseMentalityCalculator extends CharacterCalculator {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BaseMentalityCalculator() {
|
public BaseMentalityCalculator() {
|
||||||
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
|
super(new AbstractFunction<L2Character>(0x000) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result = ctx.character.getTemplate().getMentality();
|
ctx.result = c.getTemplate().getMentality();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package com.l2jserver.model.world.character.calculator;
|
|||||||
import com.l2jserver.model.world.L2Character;
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||||
import com.l2jserver.util.calculator.AbstractFunction;
|
import com.l2jserver.util.calculator.AbstractFunction;
|
||||||
|
import com.l2jserver.util.calculator.CalculatorContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
@@ -27,15 +28,14 @@ import com.l2jserver.util.calculator.AbstractFunction;
|
|||||||
public class BasePhysicalAttackCalculator extends CharacterCalculator {
|
public class BasePhysicalAttackCalculator extends CharacterCalculator {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BasePhysicalAttackCalculator() {
|
public BasePhysicalAttackCalculator() {
|
||||||
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
|
super(new AbstractFunction<L2Character>(0x000) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result = ctx.character.getTemplate().getPhysicalAttack();
|
ctx.result = c.getTemplate().getPhysicalAttack();
|
||||||
}
|
}
|
||||||
}, new AbstractFunction<CharacterCalculatorContext>(0x100) {
|
}, new AbstractFunction<L2Character>(0x100) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
final L2Character c = ctx.character;
|
|
||||||
ctx.result *= BaseStats.STR.calculateBonus(c.getStats()
|
ctx.result *= BaseStats.STR.calculateBonus(c.getStats()
|
||||||
.getStrength()) * ((100.0 - 11 + c.getLevel()) / 100.0);
|
.getStrength()) * ((100.0 - 11 + c.getLevel()) / 100.0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.model.world.character.calculator;
|
package com.l2jserver.model.world.character.calculator;
|
||||||
|
|
||||||
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||||
import com.l2jserver.util.calculator.AbstractFunction;
|
import com.l2jserver.util.calculator.AbstractFunction;
|
||||||
|
import com.l2jserver.util.calculator.CalculatorContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
@@ -26,16 +28,16 @@ import com.l2jserver.util.calculator.AbstractFunction;
|
|||||||
public class BasePhysicalAttackSpeedCalculator extends CharacterCalculator {
|
public class BasePhysicalAttackSpeedCalculator extends CharacterCalculator {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BasePhysicalAttackSpeedCalculator() {
|
public BasePhysicalAttackSpeedCalculator() {
|
||||||
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
|
super(new AbstractFunction<L2Character>(0x000) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result = ctx.character.getTemplate().getAttackSpeed();
|
ctx.result = c.getTemplate().getAttackSpeed();
|
||||||
}
|
}
|
||||||
}, new AbstractFunction<CharacterCalculatorContext>(0x200) {
|
}, new AbstractFunction<L2Character>(0x200) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result *= BaseStats.DEX.calculateBonus(ctx.character
|
ctx.result *= BaseStats.DEX.calculateBonus(c.getStats()
|
||||||
.getStats().getDexterity());
|
.getDexterity());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package com.l2jserver.model.world.character.calculator;
|
|||||||
import com.l2jserver.model.world.L2Character;
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||||
import com.l2jserver.util.calculator.AbstractFunction;
|
import com.l2jserver.util.calculator.AbstractFunction;
|
||||||
|
import com.l2jserver.util.calculator.CalculatorContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
@@ -26,16 +27,14 @@ import com.l2jserver.util.calculator.AbstractFunction;
|
|||||||
public class BasePhysicalCriticalRateCalculator extends CharacterCalculator {
|
public class BasePhysicalCriticalRateCalculator extends CharacterCalculator {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BasePhysicalCriticalRateCalculator() {
|
public BasePhysicalCriticalRateCalculator() {
|
||||||
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
|
super(new AbstractFunction<L2Character>(0x000) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result = ctx.character.getTemplate().getCriticalChance();
|
ctx.result = c.getTemplate().getCriticalChance();
|
||||||
}
|
}
|
||||||
}, new AbstractFunction<CharacterCalculatorContext>(0x090) {
|
}, new AbstractFunction<L2Character>(0x090) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
final L2Character c = ctx.character;
|
|
||||||
|
|
||||||
ctx.result *= BaseStats.DEX.calculateBonus(c.getStats()
|
ctx.result *= BaseStats.DEX.calculateBonus(c.getStats()
|
||||||
.getDexterity());
|
.getDexterity());
|
||||||
ctx.result *= 10;
|
ctx.result *= 10;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import com.l2jserver.model.world.character.CharacterClass;
|
|||||||
import com.l2jserver.model.world.character.CharacterClass.ClassType;
|
import com.l2jserver.model.world.character.CharacterClass.ClassType;
|
||||||
import com.l2jserver.model.world.character.CharacterInventory;
|
import com.l2jserver.model.world.character.CharacterInventory;
|
||||||
import com.l2jserver.util.calculator.AbstractFunction;
|
import com.l2jserver.util.calculator.AbstractFunction;
|
||||||
|
import com.l2jserver.util.calculator.CalculatorContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
@@ -35,15 +36,14 @@ import com.l2jserver.util.calculator.AbstractFunction;
|
|||||||
public class BasePhysicalDefenseCalculator extends CharacterCalculator {
|
public class BasePhysicalDefenseCalculator extends CharacterCalculator {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BasePhysicalDefenseCalculator() {
|
public BasePhysicalDefenseCalculator() {
|
||||||
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
|
super(new AbstractFunction<L2Character>(0x000) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result = ctx.character.getTemplate().getPhysicalDefense();
|
ctx.result = c.getTemplate().getPhysicalDefense();
|
||||||
}
|
}
|
||||||
}, new AbstractFunction<CharacterCalculatorContext>(0x200) {
|
}, new AbstractFunction<L2Character>(0x200) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
final L2Character c = ctx.character;
|
|
||||||
final CharacterInventory inv = c.getInventory();
|
final CharacterInventory inv = c.getInventory();
|
||||||
|
|
||||||
// orc mystics are a special case
|
// orc mystics are a special case
|
||||||
|
|||||||
@@ -16,8 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.model.world.character.calculator;
|
package com.l2jserver.model.world.character.calculator;
|
||||||
|
|
||||||
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||||
import com.l2jserver.util.calculator.AbstractFunction;
|
import com.l2jserver.util.calculator.AbstractFunction;
|
||||||
|
import com.l2jserver.util.calculator.CalculatorContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
@@ -26,16 +28,16 @@ import com.l2jserver.util.calculator.AbstractFunction;
|
|||||||
public class BaseRunSpeedCalculator extends CharacterCalculator {
|
public class BaseRunSpeedCalculator extends CharacterCalculator {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BaseRunSpeedCalculator() {
|
public BaseRunSpeedCalculator() {
|
||||||
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
|
super(new AbstractFunction<L2Character>(0x000) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result = ctx.character.getTemplate().getRunSpeed();
|
ctx.result = c.getTemplate().getRunSpeed();
|
||||||
}
|
}
|
||||||
}, new AbstractFunction<CharacterCalculatorContext>(0x300) {
|
}, new AbstractFunction<L2Character>(0x300) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result *= BaseStats.DEX.calculateBonus(ctx.character
|
ctx.result *= BaseStats.DEX.calculateBonus(c.getStats()
|
||||||
.getStats().getDexterity());
|
.getDexterity());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.model.world.character.calculator;
|
package com.l2jserver.model.world.character.calculator;
|
||||||
|
|
||||||
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.util.calculator.AbstractFunction;
|
import com.l2jserver.util.calculator.AbstractFunction;
|
||||||
|
import com.l2jserver.util.calculator.CalculatorContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
@@ -24,10 +26,10 @@ import com.l2jserver.util.calculator.AbstractFunction;
|
|||||||
public class BaseStrengthCalculator extends CharacterCalculator {
|
public class BaseStrengthCalculator extends CharacterCalculator {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BaseStrengthCalculator() {
|
public BaseStrengthCalculator() {
|
||||||
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
|
super(new AbstractFunction<L2Character>(0x000) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result = ctx.character.getTemplate().getStrength();
|
ctx.result = c.getTemplate().getStrength();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.model.world.character.calculator;
|
package com.l2jserver.model.world.character.calculator;
|
||||||
|
|
||||||
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||||
import com.l2jserver.util.calculator.AbstractFunction;
|
import com.l2jserver.util.calculator.AbstractFunction;
|
||||||
|
import com.l2jserver.util.calculator.CalculatorContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
@@ -26,16 +28,16 @@ import com.l2jserver.util.calculator.AbstractFunction;
|
|||||||
public class BaseWalkSpeedCalculator extends CharacterCalculator {
|
public class BaseWalkSpeedCalculator extends CharacterCalculator {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BaseWalkSpeedCalculator() {
|
public BaseWalkSpeedCalculator() {
|
||||||
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
|
super(new AbstractFunction<L2Character>(0x000) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result = ctx.character.getTemplate().getWalkSpeed();
|
ctx.result = c.getTemplate().getWalkSpeed();
|
||||||
}
|
}
|
||||||
}, new AbstractFunction<CharacterCalculatorContext>(0x300) {
|
}, new AbstractFunction<L2Character>(0x300) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result *= BaseStats.DEX.calculateBonus(ctx.character
|
ctx.result *= BaseStats.DEX.calculateBonus(c.getStats()
|
||||||
.getStats().getDexterity());
|
.getDexterity());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.model.world.character.calculator;
|
package com.l2jserver.model.world.character.calculator;
|
||||||
|
|
||||||
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.util.calculator.AbstractFunction;
|
import com.l2jserver.util.calculator.AbstractFunction;
|
||||||
|
import com.l2jserver.util.calculator.CalculatorContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
@@ -24,10 +26,10 @@ import com.l2jserver.util.calculator.AbstractFunction;
|
|||||||
public class BaseWitnessCalculator extends CharacterCalculator {
|
public class BaseWitnessCalculator extends CharacterCalculator {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BaseWitnessCalculator() {
|
public BaseWitnessCalculator() {
|
||||||
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
|
super(new AbstractFunction<L2Character>(0x000) {
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CharacterCalculatorContext ctx) {
|
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||||
ctx.result = ctx.character.getTemplate().getMentality();
|
ctx.result = c.getTemplate().getMentality();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.model.world.character.calculator;
|
package com.l2jserver.model.world.character.calculator;
|
||||||
|
|
||||||
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.util.calculator.Calculator;
|
import com.l2jserver.util.calculator.Calculator;
|
||||||
import com.l2jserver.util.calculator.Function;
|
import com.l2jserver.util.calculator.Function;
|
||||||
|
|
||||||
@@ -23,9 +24,9 @@ import com.l2jserver.util.calculator.Function;
|
|||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CharacterCalculator extends Calculator<CharacterCalculatorContext> {
|
public class CharacterCalculator extends Calculator<L2Character> {
|
||||||
public CharacterCalculator(
|
public CharacterCalculator(
|
||||||
Function<CharacterCalculatorContext>... functions) {
|
Function<L2Character>... functions) {
|
||||||
super(functions);
|
super(functions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,12 +16,13 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.util.calculator;
|
package com.l2jserver.util.calculator;
|
||||||
|
|
||||||
|
import com.l2jserver.model.world.Actor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractFunction<T extends CalculatorContext> implements
|
public abstract class AbstractFunction<O extends Actor> implements Function<O> {
|
||||||
Function<T> {
|
|
||||||
private final int order;
|
private final int order;
|
||||||
|
|
||||||
public AbstractFunction(int order) {
|
public AbstractFunction(int order) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import java.util.Collections;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.l2jserver.model.world.Actor;
|
||||||
import com.l2jserver.util.factory.CollectionFactory;
|
import com.l2jserver.util.factory.CollectionFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,12 +29,11 @@ import com.l2jserver.util.factory.CollectionFactory;
|
|||||||
*
|
*
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public class Calculator<T extends CalculatorContext> extends
|
public class Calculator<O extends Actor> extends AbstractFunction<O> {
|
||||||
AbstractFunction<T> {
|
|
||||||
/**
|
/**
|
||||||
* List of operations in this calculator
|
* List of operations in this calculator
|
||||||
*/
|
*/
|
||||||
private final List<Function<T>> functions = CollectionFactory.newList();
|
private final List<Function<O>> functions = CollectionFactory.newList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new empty calculator. Functions can be add using
|
* Creates a new empty calculator. Functions can be add using
|
||||||
@@ -50,9 +50,9 @@ public class Calculator<T extends CalculatorContext> extends
|
|||||||
* @param functions
|
* @param functions
|
||||||
* the calculator functions
|
* the calculator functions
|
||||||
*/
|
*/
|
||||||
public Calculator(Function<T>... functions) {
|
public Calculator(Function<O>... functions) {
|
||||||
super(0x00);
|
super(0x00);
|
||||||
for (final Function<T> func : functions) {
|
for (final Function<O> func : functions) {
|
||||||
this.functions.add(func);
|
this.functions.add(func);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ public class Calculator<T extends CalculatorContext> extends
|
|||||||
* @param function
|
* @param function
|
||||||
* the operation
|
* the operation
|
||||||
*/
|
*/
|
||||||
public void add(Function<T> function) {
|
public void add(Function<O> function) {
|
||||||
functions.add(function);
|
functions.add(function);
|
||||||
Collections.sort(functions, FunctionOrderComparator.SHARED_INSTANCE);
|
Collections.sort(functions, FunctionOrderComparator.SHARED_INSTANCE);
|
||||||
}
|
}
|
||||||
@@ -83,10 +83,10 @@ public class Calculator<T extends CalculatorContext> extends
|
|||||||
* @param calculator
|
* @param calculator
|
||||||
* the calculator
|
* the calculator
|
||||||
*/
|
*/
|
||||||
public void importFunctions(Calculator<T> calculator) {
|
public void importFunctions(Calculator<O> calculator) {
|
||||||
for (final Function<T> function : calculator.functions) {
|
for (final Function<O> function : calculator.functions) {
|
||||||
if (function instanceof Calculator) {
|
if (function instanceof Calculator) {
|
||||||
importFunctions((Calculator<T>) function);
|
importFunctions((Calculator<O>) function);
|
||||||
} else {
|
} else {
|
||||||
functions.add(function);
|
functions.add(function);
|
||||||
}
|
}
|
||||||
@@ -101,10 +101,10 @@ public class Calculator<T extends CalculatorContext> extends
|
|||||||
* @param calculator
|
* @param calculator
|
||||||
* the calculator
|
* the calculator
|
||||||
*/
|
*/
|
||||||
public void removeFunctions(Calculator<T> calculator) {
|
public void removeFunctions(Calculator<O> calculator) {
|
||||||
for (final Function<T> function : calculator.functions) {
|
for (final Function<O> function : calculator.functions) {
|
||||||
if (function instanceof Calculator) {
|
if (function instanceof Calculator) {
|
||||||
removeFunctions((Calculator<T>) function);
|
removeFunctions((Calculator<O>) function);
|
||||||
} else {
|
} else {
|
||||||
functions.remove(function);
|
functions.remove(function);
|
||||||
}
|
}
|
||||||
@@ -112,9 +112,9 @@ public class Calculator<T extends CalculatorContext> extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void calculate(T ctx) {
|
public void calculate(O object, CalculatorContext ctx) {
|
||||||
for (final Function<T> function : functions) {
|
for (final Function<O> function : functions) {
|
||||||
function.calculate(ctx);
|
function.calculate(object, ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,13 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.util.calculator;
|
package com.l2jserver.util.calculator;
|
||||||
|
|
||||||
|
import com.l2jserver.model.world.Actor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function performs a division: <blockquote><code>chain value /
|
* This function performs a division: <blockquote><code>chain value /
|
||||||
* value</code></blockquote>
|
* value</code></blockquote>
|
||||||
*
|
*
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public class DivisionFunction extends AbstractFunction<CalculatorContext> {
|
public class DivisionFunction<O extends Actor> extends AbstractFunction<O> {
|
||||||
/**
|
/**
|
||||||
* The value
|
* The value
|
||||||
*/
|
*/
|
||||||
@@ -34,7 +36,7 @@ public class DivisionFunction extends AbstractFunction<CalculatorContext> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CalculatorContext ctx) {
|
public void calculate(O actor, CalculatorContext ctx) {
|
||||||
ctx.result /= this.value;
|
ctx.result /= this.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,12 +16,14 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.util.calculator;
|
package com.l2jserver.util.calculator;
|
||||||
|
|
||||||
|
import com.l2jserver.model.world.Actor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An function is nothing more than a mathematical operation.
|
* An function is nothing more than a mathematical operation.
|
||||||
*
|
*
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public interface Function<T extends CalculatorContext> {
|
public interface Function<O extends Actor> {
|
||||||
/**
|
/**
|
||||||
* Performs the operation in the calculation process.
|
* Performs the operation in the calculation process.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -33,7 +35,7 @@ public interface Function<T extends CalculatorContext> {
|
|||||||
* the input value
|
* the input value
|
||||||
* @return the output value
|
* @return the output value
|
||||||
*/
|
*/
|
||||||
void calculate(T ctx);
|
void calculate(O actor, CalculatorContext ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the order this function will be executed
|
* @return the order this function will be executed
|
||||||
|
|||||||
@@ -16,19 +16,21 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.util.calculator;
|
package com.l2jserver.util.calculator;
|
||||||
|
|
||||||
|
import com.l2jserver.model.world.Actor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function performs an modulus: <blockquote><code>|chain value|</code>
|
* This function performs an modulus: <blockquote><code>|chain value|</code>
|
||||||
* </blockquote>
|
* </blockquote>
|
||||||
*
|
*
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public class ModulusFunction extends AbstractFunction<CalculatorContext> {
|
public class ModulusFunction<O extends Actor> extends AbstractFunction<O> {
|
||||||
public ModulusFunction(int order) {
|
public ModulusFunction(int order) {
|
||||||
super(order);
|
super(order);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CalculatorContext ctx) {
|
public void calculate(O actor, CalculatorContext ctx) {
|
||||||
if (ctx.result < 0)
|
if (ctx.result < 0)
|
||||||
ctx.result *= -1;
|
ctx.result *= -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,13 +16,16 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.util.calculator;
|
package com.l2jserver.util.calculator;
|
||||||
|
|
||||||
|
import com.l2jserver.model.world.Actor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function performs an multiplication: <blockquote><code>chain value *
|
* This function performs an multiplication: <blockquote><code>chain value *
|
||||||
* value</code></blockquote>
|
* value</code></blockquote>
|
||||||
*
|
*
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public class MultiplicationFunction extends AbstractFunction<CalculatorContext> {
|
public class MultiplicationFunction<O extends Actor> extends
|
||||||
|
AbstractFunction<O> {
|
||||||
/**
|
/**
|
||||||
* The value
|
* The value
|
||||||
*/
|
*/
|
||||||
@@ -34,7 +37,7 @@ public class MultiplicationFunction extends AbstractFunction<CalculatorContext>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CalculatorContext ctx) {
|
public void calculate(O actor, CalculatorContext ctx) {
|
||||||
ctx.result *= this.value;
|
ctx.result *= this.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,19 +16,21 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.util.calculator;
|
package com.l2jserver.util.calculator;
|
||||||
|
|
||||||
|
import com.l2jserver.model.world.Actor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function performs an negate: <blockquote><code>-chain value</code>
|
* This function performs an negate: <blockquote><code>-chain value</code>
|
||||||
* </blockquote>
|
* </blockquote>
|
||||||
*
|
*
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public class NegateFunction extends AbstractFunction<CalculatorContext> {
|
public class NegateFunction<O extends Actor> extends AbstractFunction<O> {
|
||||||
public NegateFunction(int order) {
|
public NegateFunction(int order) {
|
||||||
super(order);
|
super(order);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CalculatorContext ctx) {
|
public void calculate(O actor, CalculatorContext ctx) {
|
||||||
ctx.result = -ctx.result;
|
ctx.result = -ctx.result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,18 +16,20 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.util.calculator;
|
package com.l2jserver.util.calculator;
|
||||||
|
|
||||||
|
import com.l2jserver.model.world.Actor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function performs an rounding in the number.
|
* This function performs an rounding in the number.
|
||||||
*
|
*
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public class RoundFunction extends AbstractFunction<CalculatorContext> {
|
public class RoundFunction<O extends Actor> extends AbstractFunction<O> {
|
||||||
public RoundFunction(int order) {
|
public RoundFunction(int order) {
|
||||||
super(order);
|
super(order);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CalculatorContext ctx) {
|
public void calculate(O actor, CalculatorContext ctx) {
|
||||||
ctx.result = Math.round(ctx.result);
|
ctx.result = Math.round(ctx.result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,12 +16,14 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.util.calculator;
|
package com.l2jserver.util.calculator;
|
||||||
|
|
||||||
|
import com.l2jserver.model.world.Actor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function performs an set. It ignores the input value and return its own.
|
* This function performs an set. It ignores the input value and return its own.
|
||||||
*
|
*
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public class SetFunction extends AbstractFunction<CalculatorContext> {
|
public class SetFunction<O extends Actor> extends AbstractFunction<O> {
|
||||||
/**
|
/**
|
||||||
* The value
|
* The value
|
||||||
*/
|
*/
|
||||||
@@ -33,7 +35,7 @@ public class SetFunction extends AbstractFunction<CalculatorContext> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CalculatorContext ctx) {
|
public void calculate(O actor, CalculatorContext ctx) {
|
||||||
ctx.result = value;
|
ctx.result = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,13 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.util.calculator;
|
package com.l2jserver.util.calculator;
|
||||||
|
|
||||||
|
import com.l2jserver.model.world.Actor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function performs an subtraction: <blockquote><code>chain value -
|
* This function performs an subtraction: <blockquote><code>chain value -
|
||||||
* value</code></blockquote>
|
* value</code></blockquote>
|
||||||
*
|
*
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public class SubtractFunction extends AbstractFunction<CalculatorContext> {
|
public class SubtractFunction<O extends Actor> extends AbstractFunction<O> {
|
||||||
/**
|
/**
|
||||||
* The value
|
* The value
|
||||||
*/
|
*/
|
||||||
@@ -34,7 +36,7 @@ public class SubtractFunction extends AbstractFunction<CalculatorContext> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CalculatorContext ctx) {
|
public void calculate(O actor, CalculatorContext ctx) {
|
||||||
ctx.result -= value;
|
ctx.result -= value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,13 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.util.calculator;
|
package com.l2jserver.util.calculator;
|
||||||
|
|
||||||
|
import com.l2jserver.model.world.Actor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function performs a sum: <blockquote><code>chain value +
|
* This function performs a sum: <blockquote><code>chain value +
|
||||||
* value</code></blockquote>
|
* value</code></blockquote>
|
||||||
*
|
*
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public class SumFunction extends AbstractFunction<CalculatorContext> {
|
public class SumFunction<O extends Actor> extends AbstractFunction<O> {
|
||||||
/**
|
/**
|
||||||
* The value
|
* The value
|
||||||
*/
|
*/
|
||||||
@@ -34,7 +36,7 @@ public class SumFunction extends AbstractFunction<CalculatorContext> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void calculate(CalculatorContext ctx) {
|
public void calculate(O actor, CalculatorContext ctx) {
|
||||||
ctx.result += value;
|
ctx.result += value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,148 +16,153 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.util.calculator;
|
package com.l2jserver.util.calculator;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CalculatorTest {
|
public class CalculatorTest {
|
||||||
@Test
|
// @Test
|
||||||
public void testSimple() {
|
// public void testSimple() {
|
||||||
final Calculator<CalculatorContext> calc = new Calculator<CalculatorContext>();
|
// final Calculator<?> calc = new Calculator<?>();
|
||||||
|
//
|
||||||
calc.add(new SetFunction(0, 10));
|
// calc.add(new SetFunction<?>(0, 10));
|
||||||
calc.add(new MultiplicationFunction(1, 2));
|
// calc.add(new MultiplicationFunction<?>(1, 2));
|
||||||
calc.add(new SetFunction(2, 30));
|
// calc.add(new SetFunction<?>(2, 30));
|
||||||
|
//
|
||||||
final CalculatorContext ctx = new CalculatorContext();
|
// final CalculatorContext ctx = new CalculatorContext();
|
||||||
calc.calculate(ctx);
|
// calc.calculate(null, ctx);
|
||||||
Assert.assertEquals(30.0, ctx.result);
|
// Assert.assertEquals(30.0, ctx.result);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Test
|
// @Test
|
||||||
public void testPercent() {
|
// public void testPercent() {
|
||||||
final Calculator<CalculatorContext> calc = new Calculator<CalculatorContext>();
|
// final Calculator<CalculatorContext> calc = new
|
||||||
|
// Calculator<CalculatorContext>();
|
||||||
calc.add(new SetFunction(0, 10));
|
//
|
||||||
calc.add(new MultiplicationFunction(1, 2));
|
// calc.add(new SetFunction(0, 10));
|
||||||
calc.add(new PercentFunction(2, 75));
|
// calc.add(new MultiplicationFunction(1, 2));
|
||||||
|
// calc.add(new PercentFunction(2, 75));
|
||||||
final CalculatorContext ctx = new CalculatorContext();
|
//
|
||||||
calc.calculate(ctx);
|
// final CalculatorContext ctx = new CalculatorContext();
|
||||||
Assert.assertEquals(15.0, ctx.result);
|
// calc.calculate(ctx);
|
||||||
}
|
// Assert.assertEquals(15.0, ctx.result);
|
||||||
|
// }
|
||||||
@Test
|
//
|
||||||
public void testComplex() {
|
// @Test
|
||||||
final Calculator<CalculatorContext> calc = new Calculator<CalculatorContext>();
|
// public void testComplex() {
|
||||||
|
// final Calculator<CalculatorContext> calc = new
|
||||||
calc.add(new SetFunction(0, 10));
|
// Calculator<CalculatorContext>();
|
||||||
calc.add(new MultiplicationFunction(1, 2));
|
//
|
||||||
calc.add(new PercentFunction(2, 75));
|
// calc.add(new SetFunction(0, 10));
|
||||||
calc.add(new SumFunction(3, 3));
|
// calc.add(new MultiplicationFunction(1, 2));
|
||||||
calc.add(new SubtractFunction(4, 8));
|
// calc.add(new PercentFunction(2, 75));
|
||||||
calc.add(new DivisionFunction(5, 2));
|
// calc.add(new SumFunction(3, 3));
|
||||||
|
// calc.add(new SubtractFunction(4, 8));
|
||||||
final CalculatorContext ctx = new CalculatorContext();
|
// calc.add(new DivisionFunction(5, 2));
|
||||||
calc.calculate(ctx);
|
//
|
||||||
Assert.assertEquals(5.0, ctx.result);
|
// final CalculatorContext ctx = new CalculatorContext();
|
||||||
}
|
// calc.calculate(ctx);
|
||||||
|
// Assert.assertEquals(5.0, ctx.result);
|
||||||
@Test
|
// }
|
||||||
public void testNesting() {
|
//
|
||||||
final Calculator<CalculatorContext> calc1 = new Calculator<CalculatorContext>();
|
// @Test
|
||||||
final CalculatorContext ctx1 = new CalculatorContext();
|
// public void testNesting() {
|
||||||
|
// final Calculator<CalculatorContext> calc1 = new
|
||||||
calc1.add(new SetFunction(0, 10));
|
// Calculator<CalculatorContext>();
|
||||||
calc1.add(new MultiplicationFunction(1, 2));
|
// final CalculatorContext ctx1 = new CalculatorContext();
|
||||||
calc1.add(new PercentFunction(2, 75));
|
//
|
||||||
calc1.add(new SumFunction(3, 3));
|
// calc1.add(new SetFunction(0, 10));
|
||||||
calc1.add(new SubtractFunction(4, 8));
|
// calc1.add(new MultiplicationFunction(1, 2));
|
||||||
calc1.add(new DivisionFunction(5, 2));
|
// calc1.add(new PercentFunction(2, 75));
|
||||||
|
// calc1.add(new SumFunction(3, 3));
|
||||||
calc1.calculate(ctx1);
|
// calc1.add(new SubtractFunction(4, 8));
|
||||||
Assert.assertEquals(5.0, ctx1.result);
|
// calc1.add(new DivisionFunction(5, 2));
|
||||||
|
//
|
||||||
final Calculator<CalculatorContext> calc2 = new Calculator<CalculatorContext>();
|
// calc1.calculate(ctx1);
|
||||||
final CalculatorContext ctx2 = new CalculatorContext();
|
// Assert.assertEquals(5.0, ctx1.result);
|
||||||
|
//
|
||||||
calc2.add(new MultiplicationFunction(0, 2));
|
// final Calculator<CalculatorContext> calc2 = new
|
||||||
calc2.add(new PercentFunction(1, 75));
|
// Calculator<CalculatorContext>();
|
||||||
calc2.add(new SumFunction(2, 3));
|
// final CalculatorContext ctx2 = new CalculatorContext();
|
||||||
calc2.add(new SubtractFunction(3, 8));
|
//
|
||||||
calc2.add(new DivisionFunction(4, 2));
|
// calc2.add(new MultiplicationFunction(0, 2));
|
||||||
|
// calc2.add(new PercentFunction(1, 75));
|
||||||
calc2.calculate(ctx2);
|
// calc2.add(new SumFunction(2, 3));
|
||||||
Assert.assertEquals(-2.5, ctx2.result);
|
// calc2.add(new SubtractFunction(3, 8));
|
||||||
|
// calc2.add(new DivisionFunction(4, 2));
|
||||||
final Calculator<CalculatorContext> calc3 = new Calculator<CalculatorContext>();
|
//
|
||||||
final CalculatorContext ctx3 = new CalculatorContext();
|
// calc2.calculate(ctx2);
|
||||||
calc3.add(calc1);
|
// Assert.assertEquals(-2.5, ctx2.result);
|
||||||
calc3.add(calc2);
|
//
|
||||||
|
// final Calculator<CalculatorContext> calc3 = new
|
||||||
// this should be executed
|
// Calculator<CalculatorContext>();
|
||||||
calc2.add(new SumFunction(10, 1));
|
// final CalculatorContext ctx3 = new CalculatorContext();
|
||||||
|
// calc3.add(calc1);
|
||||||
calc3.calculate(ctx3);
|
// calc3.add(calc2);
|
||||||
Assert.assertEquals(2.25, ctx3.result);
|
//
|
||||||
}
|
// // this should be executed
|
||||||
|
// calc2.add(new SumFunction(10, 1));
|
||||||
@Test
|
//
|
||||||
public void testImporting() {
|
// calc3.calculate(ctx3);
|
||||||
final Calculator<CalculatorContext> calc1 = new Calculator<CalculatorContext>();
|
// Assert.assertEquals(2.25, ctx3.result);
|
||||||
final CalculatorContext ctx1 = new CalculatorContext();
|
// }
|
||||||
|
//
|
||||||
calc1.add(new SetFunction(0, 10));
|
// @Test
|
||||||
calc1.add(new MultiplicationFunction(2, 2));
|
// public void testImporting() {
|
||||||
calc1.add(new PercentFunction(4, 75));
|
// final Calculator<CalculatorContext> calc1 = new
|
||||||
calc1.add(new SumFunction(6, 3));
|
// Calculator<CalculatorContext>();
|
||||||
calc1.add(new SubtractFunction(8, 8));
|
// final CalculatorContext ctx1 = new CalculatorContext();
|
||||||
calc1.add(new DivisionFunction(10, 2));
|
//
|
||||||
|
// calc1.add(new SetFunction(0, 10));
|
||||||
calc1.calculate(ctx1);
|
// calc1.add(new MultiplicationFunction(2, 2));
|
||||||
Assert.assertEquals(5.0, ctx1.result);
|
// calc1.add(new PercentFunction(4, 75));
|
||||||
|
// calc1.add(new SumFunction(6, 3));
|
||||||
final Calculator<CalculatorContext> calc2 = new Calculator<CalculatorContext>();
|
// calc1.add(new SubtractFunction(8, 8));
|
||||||
final CalculatorContext ctx2 = new CalculatorContext();
|
// calc1.add(new DivisionFunction(10, 2));
|
||||||
|
//
|
||||||
calc2.add(new MultiplicationFunction(1, 2));
|
// calc1.calculate(ctx1);
|
||||||
calc2.add(new PercentFunction(3, 75));
|
// Assert.assertEquals(5.0, ctx1.result);
|
||||||
calc2.add(new SumFunction(5, 3));
|
//
|
||||||
calc2.add(new SubtractFunction(7, 8));
|
// final Calculator<CalculatorContext> calc2 = new
|
||||||
calc2.add(new DivisionFunction(9, 2));
|
// Calculator<CalculatorContext>();
|
||||||
|
// final CalculatorContext ctx2 = new CalculatorContext();
|
||||||
calc2.calculate(ctx2);
|
//
|
||||||
Assert.assertEquals(-2.5, ctx2.result);
|
// calc2.add(new MultiplicationFunction(1, 2));
|
||||||
|
// calc2.add(new PercentFunction(3, 75));
|
||||||
final Calculator<CalculatorContext> calc3 = new Calculator<CalculatorContext>();
|
// calc2.add(new SumFunction(5, 3));
|
||||||
final CalculatorContext ctx3 = new CalculatorContext();
|
// calc2.add(new SubtractFunction(7, 8));
|
||||||
calc3.importFunctions(calc1);
|
// calc2.add(new DivisionFunction(9, 2));
|
||||||
calc3.importFunctions(calc2);
|
//
|
||||||
|
// calc2.calculate(ctx2);
|
||||||
// this should not be executed
|
// Assert.assertEquals(-2.5, ctx2.result);
|
||||||
calc2.add(new SumFunction(11, 50));
|
//
|
||||||
|
// final Calculator<CalculatorContext> calc3 = new
|
||||||
calc3.calculate(ctx3);
|
// Calculator<CalculatorContext>();
|
||||||
Assert.assertEquals(1.25, ctx3.result);
|
// final CalculatorContext ctx3 = new CalculatorContext();
|
||||||
}
|
// calc3.importFunctions(calc1);
|
||||||
|
// calc3.importFunctions(calc2);
|
||||||
@Test
|
//
|
||||||
public void testRounding() {
|
// // this should not be executed
|
||||||
final Calculator<CalculatorContext> calc = new Calculator<CalculatorContext>();
|
// calc2.add(new SumFunction(11, 50));
|
||||||
|
//
|
||||||
calc.add(new MultiplicationFunction(0, 2));
|
// calc3.calculate(ctx3);
|
||||||
calc.add(new PercentFunction(1, 75));
|
// Assert.assertEquals(1.25, ctx3.result);
|
||||||
calc.add(new SumFunction(2, 3));
|
// }
|
||||||
calc.add(new SubtractFunction(3, 8.1));
|
//
|
||||||
calc.add(new DivisionFunction(4, 2));
|
// @Test
|
||||||
calc.add(new RoundFunction(5));
|
// public void testRounding() {
|
||||||
|
// final Calculator<CalculatorContext> calc = new
|
||||||
final CalculatorContext ctx = new CalculatorContext();
|
// Calculator<CalculatorContext>();
|
||||||
calc.calculate(ctx);
|
//
|
||||||
Assert.assertEquals(-3.0, ctx.result);
|
// calc.add(new MultiplicationFunction(0, 2));
|
||||||
}
|
// calc.add(new PercentFunction(1, 75));
|
||||||
|
// calc.add(new SumFunction(2, 3));
|
||||||
|
// calc.add(new SubtractFunction(3, 8.1));
|
||||||
|
// calc.add(new DivisionFunction(4, 2));
|
||||||
|
// calc.add(new RoundFunction(5));
|
||||||
|
//
|
||||||
|
// final CalculatorContext ctx = new CalculatorContext();
|
||||||
|
// calc.calculate(ctx);
|
||||||
|
// Assert.assertEquals(-3.0, ctx.result);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public class ItemTemplateConversor {
|
|||||||
return "";
|
return "";
|
||||||
|
|
||||||
if (property.contains("_")) {
|
if (property.contains("_")) {
|
||||||
System.out.println(property);
|
System.out.println(property + " -> " + value);
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -126,16 +126,19 @@ public class NPCTemplateConverter {
|
|||||||
// System.exit(0);
|
// System.exit(0);
|
||||||
}
|
}
|
||||||
className += "Template";
|
className += "Template";
|
||||||
template = replace(template, "javaClassName", className);
|
|
||||||
|
|
||||||
folder = "";
|
folder = "";
|
||||||
name = className + ".java";
|
name = className + ".java";
|
||||||
|
|
||||||
folder = createFolder(npcType);
|
folder = createFolder(npcType);
|
||||||
|
if (folder.contains("villagemaster")) {
|
||||||
|
folder = "villagemaster";
|
||||||
|
}
|
||||||
|
|
||||||
String packageName = "";
|
String packageName = "";
|
||||||
if (folder.length() > 0)
|
if (folder.length() > 0)
|
||||||
packageName = "." + folder;
|
packageName = "." + folder;
|
||||||
|
template = replace(template, "javaClassName", className);
|
||||||
template = replace(template, "javaPackage", packageName);
|
template = replace(template, "javaPackage", packageName);
|
||||||
|
|
||||||
return new String[] { template, "/" + folder + "/", name };
|
return new String[] { template, "/" + folder + "/", name };
|
||||||
@@ -184,6 +187,10 @@ public class NPCTemplateConverter {
|
|||||||
l2j = l2j.substring(2);
|
l2j = l2j.substring(2);
|
||||||
if (l2j.equals("Npc"))
|
if (l2j.equals("Npc"))
|
||||||
return "";
|
return "";
|
||||||
|
if (l2j.contains("VillageMaster"))
|
||||||
|
return (l2j.replaceAll("VillageMaster", "") + "VillageMaster");
|
||||||
|
if(l2j.contains("Npc"))
|
||||||
|
l2j = l2j.replaceAll("Npc", "");
|
||||||
return l2j;
|
return l2j;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user