if(pAttacker->combatLimit() == (pDefender->maxHitPoints() ))
{
float CombatRatioThresholds[9];
for (int i = 0; i < 9; i++) //setup the array
{
CombatRatioThresholds[i] = ((float)(pDefender->attackXPValue()))/((float)(10-i));//max XP per combat assumed to be 10
//szTempBuffer.Format(L"combatratio[%d] = %.2f",
// i,CombatRatioThresholds[i]);
// szString.append(NEWLINE);szString.append(szTempBuffer.GetCString());
}
for (int i = 8; i >= 0; i--) // find which range we are in
{
if(CombatRatio>CombatRatioThresholds[i])
{
if (i==8)
{
szTempBuffer.Format(L"(%.2f:%dXP), (R=" SETCOLR L"%.2f" ENDCOLR L":%dXP)",
CombatRatioThresholds[i],10-i,TEXT_COLOR("COLOR_CYAN"),CombatRatio,iExperience);
szString.append(NEWLINE);szString.append(szTempBuffer.GetCString());
}
else // normal situation
{
szTempBuffer.Format(L"(%.2f:%dXP), (R=" SETCOLR L"%.2f" ENDCOLR L":%dXP), (>%.2f:%dXP)",
CombatRatioThresholds[i],10-i,TEXT_COLOR("COLOR_CYAN"),CombatRatio,iExperience,CombatRatioThresholds[i+1],10-(i+2));
szString.append(NEWLINE);szString.append(szTempBuffer.GetCString());
}
break;
}
else//very rare (ratio less than or equal to 0.4)
{
if (i==0)
{
//i should be 0
szTempBuffer.Format(L"(R=" SETCOLR L"%.2f" ENDCOLR L":%dXP), (>%.2f:%dXP)",
TEXT_COLOR("COLOR_POSITIVE_TEXT"),CombatRatio,iExperience,CombatRatioThresholds[i],10-(i+1));
szString.append(NEWLINE);szString.append(szTempBuffer.GetCString());
break;
}//if
}// else if
}//for
}//if