Implementation of damage calculation.
Some checks reported errors
continuous-integration/drone/push Build was killed
Some checks reported errors
continuous-integration/drone/push Build was killed
This commit is contained in:
@@ -89,6 +89,8 @@ void CreatureLib::Battling::TurnHandler::HandleAttackForTarget(CreatureLib::Batt
|
||||
return;
|
||||
auto user = attack.GetUser();
|
||||
auto attackData = attack.GetAttack()->GetAttack();
|
||||
auto library = user->GetBattle()->GetLibrary();
|
||||
auto dmgLibrary = library->GetDamageLibrary();
|
||||
for (uint8_t hitIndex = 0; hitIndex < numHits; hitIndex++){
|
||||
if (user->IsFainted()){
|
||||
break;
|
||||
@@ -98,9 +100,13 @@ void CreatureLib::Battling::TurnHandler::HandleAttackForTarget(CreatureLib::Batt
|
||||
break;
|
||||
}
|
||||
auto hit = targetData.GetHit(hitIndex);
|
||||
//TODO: calculate data for hit
|
||||
|
||||
hit.SetEffectiveness(user->GetBattle()->GetLibrary()->GetTypeLibrary()->GetEffectiveness(hit.GetType(), target->GetTypes()));
|
||||
//HOOK: Change move type
|
||||
hit.SetEffectiveness(library->GetTypeLibrary()->GetEffectiveness(hit.GetType(), target->GetTypes()));
|
||||
//TODO: Critical calculation
|
||||
hit.SetCritical(false);
|
||||
hit.SetBasePower(dmgLibrary->GetBasePower(&attack, target, hitIndex));
|
||||
hit.SetDamage(dmgLibrary->GetDamage(&attack, target, hitIndex));
|
||||
|
||||
if (attackData->GetCategory() == Library::AttackCategory::Status){
|
||||
//HOOK: Status attack
|
||||
@@ -109,7 +115,7 @@ void CreatureLib::Battling::TurnHandler::HandleAttackForTarget(CreatureLib::Batt
|
||||
auto damage = hit.GetDamage();
|
||||
if (damage > target->GetCurrentHealth()){
|
||||
damage = target->GetCurrentHealth();
|
||||
hit.OverrideDamage(damage);
|
||||
hit.SetDamage(damage);
|
||||
}
|
||||
if (damage > 0){
|
||||
target->Damage(damage, DamageSource::AttackDamage);
|
||||
|
||||
Reference in New Issue
Block a user