public static int getFinalSpellDamage(SpellDamageVO vo) { int baseValue = vo.damage; int baseBonus = vo.damageBaseOutgoing; int basePercentage = vo.damagePercentage; int baseExtraValue = vo.damageExtraOutgoing; float finalValue = (float)baseValue + baseBonus; if (finalValue <= 0) { return 0; } else { if (basePercentage <= -100) { return 0; } else { finalValue = finalValue * (1 + 1.0f * basePercentage / 100f); } finalValue += baseExtraValue; } return (int)finalValue; }
public void execute() { // 计算伤害 // todo :以后改为工厂模式通用接口 HurtVO vo = new HurtVO(); vo.attacker = this.attacker; vo.victim = this.victim; vo.damageReason = this.damageReason; // 物理伤害 PhysicsDamageVO phyVO = new PhysicsDamageVO(); phyVO.damage = this.physicalDamage; phyVO.damageBaseOutgoing = attacker.physicalDamageBaseOutgoing + victim.physicalDamageBaseOutgoing; phyVO.damagePercentage = attacker.physicalDamagePercentage + victim.physicalDamagePercentage; phyVO.damageExtraOutgoing = attacker.physicalDamageExtraOutgoing + victim.physicalDamageExtraOutgoing; vo.phycicsDamage = BattleFieldsUtils.getFinalPhysicsDamage(phyVO); // 魔法伤害 SpellDamageVO spellVO = new SpellDamageVO(); spellVO.damage = this.spellDamage; spellVO.damageBaseOutgoing = attacker.spellDamageBaseOutgoing + victim.spellDamageBaseOutgoing; spellVO.damagePercentage = attacker.spellDamagePercentage + victim.spellDamagePercentage; spellVO.damageExtraOutgoing = attacker.spellDamageExtraOutgoing + victim.spellDamageExtraOutgoing; vo.spellDamage = BattleFieldsUtils.getFinalSpellDamage(spellVO); // 生命流失 HpRemovalVO hpRemovalVO = new HpRemovalVO(); hpRemovalVO.damage = this.hpRemoval; vo.hpRemoval = BattleFieldsUtils.getFinalHpRemoval(hpRemovalVO); // hurt this.victim.hurt(vo); }
public void execute() { // 攻击方的buff加成属性 CalcDamageAttackerProperties attackerProps = new CalcDamageAttackerProperties(); attackerProps.attacker = this.attacker; attackerProps.victim = this.victim; attackerProps.damageReason = this.damageReason; attackerProps.physicalDamage = this.physicalDamage; attackerProps.spellDamage = this.spellDamage; attackerProps.hpRemoval = this.hpRemoval; this.attacker.applyEffects(attackerProps); // 受伤害方的buff加成属性 CalcDamageVictimProperties victimProps = new CalcDamageVictimProperties(); victimProps.attacker = this.attacker; victimProps.victim = this.victim; victimProps.damageReason = this.damageReason; victimProps.physicalDamage = this.physicalDamage; victimProps.spellDamage = this.spellDamage; victimProps.hpRemoval = this.hpRemoval; this.victim.applyEffects(attackerProps); // 计算伤害 // todo :以后改为工厂模式通用接口 HurtVO vo = new HurtVO(); vo.attacker = this.attacker; vo.victim = this.victim; vo.damageReason = this.damageReason; // 物理伤害 PhysicsDamageVO phyVO = new PhysicsDamageVO(); phyVO.damage = this.physicalDamage; phyVO.damageBaseOutgoing = attackerProps.physicalDamageBaseOutgoing + victimProps.physicalDamageBaseOutgoing; phyVO.damagePercentage = attackerProps.physicalDamagePercentage + victimProps.physicalDamagePercentage; phyVO.damageExtraOutgoing = attackerProps.physicalDamageExtraOutgoing + victimProps.physicalDamageExtraOutgoing; vo.phycicsDamage = BattleFieldsUtils.getFinalPhysicsDamage(phyVO); // 魔法伤害 SpellDamageVO spellVO = new SpellDamageVO(); spellVO.damage = this.spellDamage; spellVO.damageBaseOutgoing = attackerProps.spellDamageBaseOutgoing + victimProps.spellDamageBaseOutgoing; spellVO.damagePercentage = attackerProps.spellDamagePercentage + victimProps.spellDamagePercentage; spellVO.damageExtraOutgoing = attackerProps.spellDamageExtraOutgoing + victimProps.spellDamageExtraOutgoing; vo.spellDamage = BattleFieldsUtils.getFinalSpellDamage(spellVO); // 生命流失 HpRemovalVO hpRemovalVO = new HpRemovalVO(); hpRemovalVO.damage = this.hpRemoval; vo.hpRemoval = BattleFieldsUtils.getFinalHpRemoval(hpRemovalVO); // hurt this.victim.hurt(vo); }