/** * Apply raw damage part of a skill * * @param source * @param target */ public void useSkillDamage(Charact source, Charact target) { if (successTest(source)) { int weaponDamage = 0; Weapon weapon = source.getWeapon(); Dice dice = new Dice(); if (weapon != null) { for (int i = 0; i < weapon.getNbDice(); i++) { weaponDamage += dice.roll(weapon.getDamageDice()); } } int skillDamage = 0; if (this.diceValue > 0) { // damage for (int i = 0; i < this.nbDices; i++) { skillDamage += dice.roll(this.diceValue); } } else { // heal for (int i = 0; i < this.nbDices; i++) { skillDamage -= dice.roll(-this.diceValue); } } int damage = skillDamage + weaponDamage; this.totalDamageWithoutArmor = damage; int armor = target.getTotalArmor(); // test negative damage if (damage > 0) // heals not affected by armor { if (damage - armor < 0) this.totalDamage = 0; else this.totalDamage = damage - armor; } target.setHp(target.getHp() - totalDamage); source.setMp(source.getMp() - this.mpCost); } }