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

Character calculators

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-05-23 23:49:19 -03:00
parent 1909bb06cc
commit a1b1211616
206 changed files with 4749 additions and 1170 deletions

View File

@@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory;
import com.l2jserver.model.id.template.ActorTemplateID;
import com.l2jserver.model.world.Actor;
import com.l2jserver.model.world.actor.ActorAttributes;
import com.l2jserver.model.world.actor.stat.Stats;
/**
* Template for {@link Actor}
@@ -72,6 +73,8 @@ public abstract class ActorTemplate<T extends Actor> extends
}
protected abstract T createInstance();
public abstract Stats getTemplateStat();
/**
* @return the baseAttributes
@@ -488,5 +491,4 @@ public abstract class ActorTemplate<T extends Actor> extends
return craft;
}
}
}

View File

@@ -19,6 +19,7 @@ package com.l2jserver.model.template;
import com.l2jserver.model.id.template.CharacterTemplateID;
import com.l2jserver.model.world.Actor.ActorRace;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.actor.stat.Stats;
import com.l2jserver.model.world.character.CharacterClass;
import com.l2jserver.util.dimensional.Point;
@@ -37,6 +38,20 @@ public abstract class CharacterTemplate extends ActorTemplate<L2Character> {
*/
protected final Point spawnLocation;
protected double hpBase;
protected double hpAdd;
protected double hpMultiplier;
protected double mpBase;
protected double mpAdd;
protected double mpMultiplier;
protected double cpBase;
protected double cpAdd;
protected double cpMultiplier;
protected int minimumLevel;
protected Integer attackDamage = null;
protected AttackType attackType;
@@ -70,7 +85,7 @@ public abstract class CharacterTemplate extends ActorTemplate<L2Character> {
@Override
public L2Character createInstance() {
final L2Character character = new L2Character(this.getID(), attributes);
final L2Character character = new L2Character(this.getID());
character.setRace(getRace());
character.setCharacterClass(characterClass);
@@ -79,6 +94,11 @@ public abstract class CharacterTemplate extends ActorTemplate<L2Character> {
return character;
}
@Override
public Stats getTemplateStat() {
return null;
}
/**
* @return the race
*/
@@ -100,6 +120,90 @@ public abstract class CharacterTemplate extends ActorTemplate<L2Character> {
return spawnLocation;
}
/**
* @return the hpBase
*/
public double getHpBase() {
return hpBase;
}
/**
* @return the hpAdd
*/
public double getHpAdd() {
return hpAdd;
}
/**
* @return the hpMultiplier
*/
public double getHpMultiplier() {
return hpMultiplier;
}
/**
* @return the mpBase
*/
public double getMpBase() {
return mpBase;
}
/**
* @return the mpAdd
*/
public double getMpAdd() {
return mpAdd;
}
/**
* @return the mpMultiplier
*/
public double getMpMultiplier() {
return mpMultiplier;
}
/**
* @return the cpBase
*/
public double getCpBase() {
return cpBase;
}
/**
* @return the cpAdd
*/
public double getCpAdd() {
return cpAdd;
}
/**
* @return the cpMultiplier
*/
public double getCpMultiplier() {
return cpMultiplier;
}
/**
* @return the minimumLevel
*/
public int getMinimumLevel() {
return minimumLevel;
}
/**
* @return the attackDamage
*/
public Integer getAttackDamage() {
return attackDamage;
}
/**
* @return the attackType
*/
public AttackType getAttackType() {
return attackType;
}
/**
* @return the male collision radius
*/

View File

@@ -28,6 +28,7 @@ import com.l2jserver.model.world.Actor;
import com.l2jserver.model.world.Actor.ActorSex;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.NPC;
import com.l2jserver.model.world.actor.stat.Stats;
import com.l2jserver.service.game.character.CannotSetTargetServiceException;
import com.l2jserver.service.game.character.CharacterService;
import com.l2jserver.service.network.NetworkService;
@@ -57,6 +58,8 @@ public abstract class NPCTemplate extends ActorTemplate<NPC> implements
*/
@Inject
protected ItemTemplateIDProvider itemTemplateIdProvider;
protected Stats stats;
/**
* The NPC name
@@ -118,7 +121,7 @@ public abstract class NPCTemplate extends ActorTemplate<NPC> implements
/**
* The NPC sp
*/
protected long sp;
protected int sp;
/**
* The NPC agressive state
@@ -228,11 +231,20 @@ public abstract class NPCTemplate extends ActorTemplate<NPC> implements
public void receiveAttack(NPC npc, Calculator calculator, Actor attacker) {
// TODO add attributes to calculator!
}
@Override
public NPC createInstance() {
return new NPC(this.getID());
}
@Override
public Stats getTemplateStat() {
return null;
}
/**
* @return the name
@@ -328,7 +340,7 @@ public abstract class NPCTemplate extends ActorTemplate<NPC> implements
/**
* @return the sp
*/
public long getSp() {
public int getSp() {
return sp;
}

View File

@@ -16,21 +16,14 @@
*/
package com.l2jserver.model.template.item;
import java.util.Map;
import java.util.Map.Entry;
import com.l2jserver.model.id.template.ItemTemplateID;
import com.l2jserver.model.template.ItemTemplate;
import com.l2jserver.model.world.Item;
import com.l2jserver.model.world.actor.stat.Stats;
import com.l2jserver.model.world.actor.stat.Stats.StatType;
import com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll;
import com.l2jserver.util.calculator.Calculator;
import com.l2jserver.util.calculator.DivisionFunction;
import com.l2jserver.util.calculator.Function;
import com.l2jserver.util.calculator.MultiplicationFunction;
import com.l2jserver.util.calculator.SetFunction;
import com.l2jserver.util.calculator.SubtractFunction;
import com.l2jserver.util.calculator.SumFunction;
import com.l2jserver.util.factory.CollectionFactory;
/**
* Template for Weapon {@link Item}
@@ -59,7 +52,7 @@ public abstract class WeaponTemplate extends ItemTemplate {
/**
* The weapon's attributes
*/
protected final WeaponAttribute attribute = new WeaponAttribute();
protected final Stats stats = new Stats();
/**
* This weapon random damage
@@ -130,145 +123,8 @@ public abstract class WeaponTemplate extends ItemTemplate {
* @param calc
* the calculator
*/
public void calculator(WeaponAttributeType type, Calculator calc) {
attribute.calculator(type, calc);
}
/**
* Attribute types for weapons
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public enum WeaponAttributeType {
PHYSICAL_ATTACK, MAGICAL_ATTACK, R_CRITICAL, PHYSICAL_ATTACK_SPEED;
}
/**
* This class handles the Weapon attributes an can add operations to the
* calculator
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class WeaponAttribute {
private final Map<WeaponAttributeType, Map<Integer, Function<Double>>> operations = CollectionFactory
.newMap();
/**
* Sets the result of an calculator
*
* @param type
* the attribute type
* @param order
* the calculation order
* @param value
* the value to set
*/
public void set(WeaponAttributeType type, int order, double value) {
getMap(type).put(order, new SetFunction(value));
}
/**
* Adds <tt>value</tt> to the result of an calculator
*
* @param type
* the attribute type
* @param order
* the calculation order
* @param value
* the value to be summed
*/
public void add(WeaponAttributeType type, int order, double value) {
getMap(type).put(order, new SumFunction(value));
}
/**
* Subtracts <tt>value</tt> from the result of an calculator
*
* @param type
* the attribute type
* @param order
* the calculation order
* @param value
* the value to be subtracted
*/
public void sub(WeaponAttributeType type, int order, double value) {
getMap(type).put(order, new SubtractFunction(value));
}
/**
* Multiply <tt>value</tt> the result of an calculator
*
* @param type
* the attribute type
* @param order
* the calculation order
* @param value
* the value to be multiplied
*/
public void mult(WeaponAttributeType type, int order, double value) {
getMap(type).put(order, new MultiplicationFunction(value));
}
/**
* Divides by <tt>value</tt> the result of an calculator
*
* @param type
* the attribute type
* @param order
* the calculation order
* @param value
* the value to be divided by
*/
public void div(WeaponAttributeType type, int order, double value) {
getMap(type).put(order, new DivisionFunction(value));
}
/**
* Performs an enchant operation. Note that this is not implemented yet!
*
* @param type
* the attribute type
* @param order
* the calculation order
* @param value
* TODO
*/
public void enchant(WeaponAttributeType type, int order, double value) {
// TODO enchant operation for weapon
}
/**
* Returns the Order-Operation map for <tt>type</tt>
*
* @param type
* the type
* @return the order-operation map
*/
private Map<Integer, Function<Double>> getMap(WeaponAttributeType type) {
Map<Integer, Function<Double>> map = operations.get(type);
if (map == null) {
map = CollectionFactory.newMap();
operations.put(type, map);
}
return map;
}
/**
* Creates the calculator object for this weapon
*
* @param type
* the type
* @param calculator
* the calculator
*/
private void calculator(WeaponAttributeType type, Calculator calculator) {
final Map<Integer, Function<Double>> operations = this.operations
.get(type);
for (final Entry<Integer, Function<Double>> entry : operations
.entrySet()) {
calculator.add(entry.getKey(), entry.getValue());
}
}
public void calculator(StatType type, Calculator calc) {
stats.calculator(type, calc);
}
/**
@@ -409,7 +265,7 @@ public abstract class WeaponTemplate extends ItemTemplate {
/**
* @return the attribute
*/
public WeaponAttribute getAttribute() {
return attribute;
public Stats getAttribute() {
return stats;
}
}