/** * Apply CharState part of a skill * * @param source * @param target */ public void useSkillCharState(Charact source, Charact target) { if (this.charState != null) { if (!target.isImmune()) { if (successTest(source)) { target.getCharStates().add(this.charState); } } } }
/** * Result of a ability dice throw * * @param source * @return */ public boolean successTest(Charact source) { // jet dé boolean successTest = false; switch (this.assocStat) { case 0: successTest = source.getAbilityScores().abilityTestStrength(); break; case 1: successTest = source.getAbilityScores().abilityTestDexterity(); break; case 2: successTest = source.getAbilityScores().abilityTestIntel(); break; } this.success = successTest; return successTest; }
/** * 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); } }