mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Merge pull request #3931 from IvanSavenko/retaliation_preview
[1.5.1] Retaliation preview
This commit is contained in:
commit
58d1c93c1b
@ -252,6 +252,13 @@
|
||||
"vcmi.battleWindow.damageEstimation.damage.1" : "%d damage",
|
||||
"vcmi.battleWindow.damageEstimation.kills" : "%d will perish",
|
||||
"vcmi.battleWindow.damageEstimation.kills.1" : "%d will perish",
|
||||
|
||||
"vcmi.battleWindow.damageRetaliation.will" : "Will retaliate ",
|
||||
"vcmi.battleWindow.damageRetaliation.may" : "May retaliate ",
|
||||
"vcmi.battleWindow.damageRetaliation.never" : "Will not retaliate.",
|
||||
"vcmi.battleWindow.damageRetaliation.damage" : "(%DAMAGE).",
|
||||
"vcmi.battleWindow.damageRetaliation.damageKills" : "(%DAMAGE, %KILLS).",
|
||||
|
||||
"vcmi.battleWindow.killed" : "Killed",
|
||||
"vcmi.battleWindow.accurateShot.resultDescription.0" : "%d %s were killed by accurate shots!",
|
||||
"vcmi.battleWindow.accurateShot.resultDescription.1" : "%d %s was killed with an accurate shot!",
|
||||
|
@ -241,11 +241,19 @@
|
||||
"vcmi.battleWindow.damageEstimation.rangedKills" : "Стріляти в %CREATURE (%SHOTS, %DAMAGE, %KILLS).",
|
||||
"vcmi.battleWindow.damageEstimation.shots" : "%d пострілів залишилось",
|
||||
"vcmi.battleWindow.damageEstimation.shots.1" : "%d постріл залишився",
|
||||
"vcmi.battleWindow.damageEstimation.damage" : "%d одиниць пошкоджень",
|
||||
"vcmi.battleWindow.damageEstimation.damage.1" : "%d одиниця пошкодження",
|
||||
"vcmi.battleWindow.damageEstimation.damage" : "%d пошкоджень",
|
||||
"vcmi.battleWindow.damageEstimation.damage.1" : "%d пошкодження",
|
||||
"vcmi.battleWindow.damageEstimation.kills" : "%d загинуть",
|
||||
"vcmi.battleWindow.damageEstimation.kills.1" : "%d загине",
|
||||
|
||||
"vcmi.battleWindow.damageRetaliation.will" : "Буде відповідати ",
|
||||
"vcmi.battleWindow.damageRetaliation.may" : "Може відповісти ",
|
||||
"vcmi.battleWindow.damageRetaliation.never" : "Не буде відповідати.",
|
||||
"vcmi.battleWindow.damageRetaliation.damage" : "(%DAMAGE).",
|
||||
"vcmi.battleWindow.damageRetaliation.damageKills" : "(%DAMAGE, %KILLS).",
|
||||
|
||||
"vcmi.battleWindow.killed" : "Загинуло",
|
||||
|
||||
"vcmi.battleWindow.accurateShot.resultDescription.0" : "%d %s було вбито влучними пострілами!",
|
||||
"vcmi.battleWindow.accurateShot.resultDescription.1" : "%d %s було вбито влучним пострілом!",
|
||||
"vcmi.battleWindow.accurateShot.resultDescription.2" : "%d %s було вбито влучними пострілами!",
|
||||
|
@ -114,6 +114,22 @@ static std::string formatRangedAttack(const DamageEstimation & estimation, const
|
||||
return formatAttack(estimation, creatureName, baseTextID, shotsLeft);
|
||||
}
|
||||
|
||||
static std::string formatRetaliation(const DamageEstimation & estimation, bool mayBeKilled)
|
||||
{
|
||||
if (estimation.damage.max == 0)
|
||||
return CGI->generaltexth->translate("vcmi.battleWindow.damageRetaliation.never");
|
||||
|
||||
std::string baseTextID = estimation.kills.max == 0 ?
|
||||
"vcmi.battleWindow.damageRetaliation.damage" :
|
||||
"vcmi.battleWindow.damageRetaliation.damageKills";
|
||||
|
||||
std::string prefixTextID = mayBeKilled ?
|
||||
"vcmi.battleWindow.damageRetaliation.may" :
|
||||
"vcmi.battleWindow.damageRetaliation.will";
|
||||
|
||||
return CGI->generaltexth->translate(prefixTextID) + formatAttack(estimation, "", baseTextID, 0);
|
||||
}
|
||||
|
||||
BattleActionsController::BattleActionsController(BattleInterface & owner):
|
||||
owner(owner),
|
||||
selectedStack(nullptr),
|
||||
@ -484,21 +500,23 @@ std::string BattleActionsController::actionGetStatusMessage(PossiblePlayerBattle
|
||||
case PossiblePlayerBattleAction::ATTACK_AND_RETURN: //TODO: allow to disable return
|
||||
{
|
||||
BattleHex attackFromHex = owner.fieldController->fromWhichHexAttack(targetHex);
|
||||
DamageEstimation estimation = owner.getBattle()->battleEstimateDamage(owner.stacksController->getActiveStack(), targetStack, attackFromHex);
|
||||
DamageEstimation retaliation;
|
||||
DamageEstimation estimation = owner.getBattle()->battleEstimateDamage(owner.stacksController->getActiveStack(), targetStack, attackFromHex, &retaliation);
|
||||
estimation.kills.max = std::min<int64_t>(estimation.kills.max, targetStack->getCount());
|
||||
estimation.kills.min = std::min<int64_t>(estimation.kills.min, targetStack->getCount());
|
||||
bool enemyMayBeKilled = estimation.kills.max == targetStack->getCount();
|
||||
|
||||
return formatMeleeAttack(estimation, targetStack->getName());
|
||||
return formatMeleeAttack(estimation, targetStack->getName()) + "\n" + formatRetaliation(retaliation, enemyMayBeKilled);
|
||||
}
|
||||
|
||||
case PossiblePlayerBattleAction::SHOOT:
|
||||
{
|
||||
const auto * shooter = owner.stacksController->getActiveStack();
|
||||
|
||||
DamageEstimation estimation = owner.getBattle()->battleEstimateDamage(shooter, targetStack, shooter->getPosition());
|
||||
DamageEstimation retaliation;
|
||||
DamageEstimation estimation = owner.getBattle()->battleEstimateDamage(shooter, targetStack, shooter->getPosition(), &retaliation);
|
||||
estimation.kills.max = std::min<int64_t>(estimation.kills.max, targetStack->getCount());
|
||||
estimation.kills.min = std::min<int64_t>(estimation.kills.min, targetStack->getCount());
|
||||
|
||||
return formatRangedAttack(estimation, targetStack->getName(), shooter->shots.available());
|
||||
}
|
||||
|
||||
|
@ -760,7 +760,7 @@ DamageEstimation CBattleInfoCallback::battleEstimateDamage(const BattleAttackInf
|
||||
|
||||
DamageEstimation ret = calculateDmgRange(bai);
|
||||
|
||||
if(retaliationDmg)
|
||||
if(retaliationDmg && bai.defender->ableToRetaliate())
|
||||
{
|
||||
if(bai.shooting)
|
||||
{
|
||||
@ -782,7 +782,7 @@ DamageEstimation CBattleInfoCallback::battleEstimateDamage(const BattleAttackInf
|
||||
};
|
||||
|
||||
DamageEstimation retaliationMin = estimateRetaliation(ret.damage.min);
|
||||
DamageEstimation retaliationMax = estimateRetaliation(ret.damage.min);
|
||||
DamageEstimation retaliationMax = estimateRetaliation(ret.damage.max);
|
||||
|
||||
retaliationDmg->damage.min = std::min(retaliationMin.damage.min, retaliationMax.damage.min);
|
||||
retaliationDmg->damage.max = std::max(retaliationMin.damage.max, retaliationMax.damage.max);
|
||||
|
Loading…
Reference in New Issue
Block a user