/** * Gets the experience for ability usage. * * @param ability ability * @param value ability specific value * @return */ public Double getExp(Ability ability, Integer value) { Double exp = null; TwoPointFunction expFun = abilityExp.get(ability.getName()); if (expFun != null) exp = expFun.value(value); if (exp == null) return 0.0; return exp; }
/** * gets the experience for a player kill. * * @param sagaDefender saga player * @return experience */ public Double getExp(SagaLiving sagaDefender) { Double exp = playerExp.value(sagaDefender.getUsedAttributePoints()); if (exp == null) return 0.0; return exp; }
/* * (non-Javadoc) * * @see org.saga.abilities.Ability#onPlayerInteractPlayer(org.bukkit.event.player.PlayerInteractEntityEvent, org.saga.player.SagaPlayer) */ @Override public boolean triggerDefend(SagaDamageEvent event) { // Defender: if (!(event.sagaDefender instanceof SagaPlayer)) return false; // Targets item: ItemStack targetItem = event.sagaAttacker.getHandItem(); // Can be damaged: if (targetItem == null || targetItem.getType().getMaxDurability() < 1) return false; // Damage: double raw = getDefinition().getFunction(WEAPON_DAMAGE_KEY).value(getScore()); double armour = getArmourMultiplier((SagaPlayer) event.sagaDefender); short damage = TwoPointFunction.randomRound(raw * armour).shortValue(); // Damage: targetItem.setDurability((short) (targetItem.getDurability() + damage)); return true; }
/** * Completes. * * @return integrity check */ public boolean complete() { boolean integrity = true; // Set instance: instance = this; // Attributes and abilities: if (attributePointCost == null) { SagaLogger.nullField(getClass(), "attributePointCost"); attributePointCost = 500.0; } if (abilityPointCost == null) { SagaLogger.nullField(getClass(), "abilityPointCost"); abilityPointCost = 500.0; } // Experience gain: if (maxExp == null) { maxExp = 10000000000.0; SagaLogger.nullField(getClass(), "maxExp"); integrity = false; } if (expGainMultiplier == null) { expGainMultiplier = new TwoPointFunction(1.0); SagaLogger.nullField(getClass(), "expGainMultiplier"); integrity = false; } if (blockExp == null) { blockExp = new Hashtable<Material, Hashtable<Byte, Double>>(); SagaLogger.nullField(getClass(), "blockExp"); integrity = false; } if (playerExp == null) { playerExp = new TwoPointFunction(0.0); SagaLogger.nullField(getClass(), "playerExp"); integrity = false; } if (creatureExp == null) { creatureExp = new Hashtable<String, Double>(); SagaLogger.nullField(getClass(), "creatureExp"); integrity = false; } if (abilityExp == null) { abilityExp = new Hashtable<String, TwoPointFunction>(); SagaLogger.nullField(getClass(), "abilityExp"); integrity = false; } Collection<TwoPointFunction> abExpVals = abilityExp.values(); for (TwoPointFunction abExpVal : abExpVals) { abExpVal.complete(); } if (spawnerEncPointMult == null) { spawnerEncPointMult = 1.0; SagaLogger.nullField(this, "spawnerEncPointMult"); integrity = false; } if (spawnerExpMult == null) { spawnerExpMult = 1.0; SagaLogger.nullField(this, "spawnerExpMult"); integrity = false; } return integrity; }
/** * Gets the experience gain multiplier. * * @param exp exp * @return experience gain multiplier */ public Double getExpGainMultiplier(Double exp) { return expGainMultiplier.value(exp); }