do not use const, be consistent with local patterns in the file

This commit is contained in:
Bruno Alexandre Rosa 2026-04-02 00:53:30 -03:00 committed by RickyRister
parent 5756d10f76
commit 0559f6cfc2

View file

@ -1576,44 +1576,37 @@ void PlayerActions::actCardCounterTrigger()
case 11: { // set counter with dialog case 11: { // set counter with dialog
player->setDialogSemaphore(true); player->setDialogSemaphore(true);
const auto &cardCounterSettings = SettingsCache::instance().cardCounters(); // If a single card is selected, we show the old value in the dialog. Otherwise, we show "x"
const auto &counterName = cardCounterSettings.displayName(counterId); QList<QGraphicsItem *> sel = player->getGameScene()->selectedItems();
QString oldValueForDlg = "x";
if (sel.size() == 1) {
auto *card = dynamic_cast<CardItem *>(sel.first());
oldValueForDlg = QString::number(card->getCounters().value(counterId, 0));
}
const auto &selectedItems = player->getGameScene()->selectedItems(); auto &cardCounterSettings = SettingsCache::instance().cardCounters();
QString counterName = cardCounterSettings.displayName(counterId);
const QString oldValueForDlg = [&selectedItems, &counterId] {
// If a single card is selected, we show the old value in the dialog. Otherwise, we show "x"
if (selectedItems.size() == 1) {
const auto *card = dynamic_cast<CardItem *>(selectedItems.first());
return QString::number(card->getCounters().value(counterId, 0));
}
return QString{"x"};
}();
AbstractCounterDialog dialog(counterName, oldValueForDlg, player->getGame()->getTab()); AbstractCounterDialog dialog(counterName, oldValueForDlg, player->getGame()->getTab());
const int ok = dialog.exec(); int ok = dialog.exec();
if (!ok) {
return;
}
player->setDialogSemaphore(false); player->setDialogSemaphore(false);
if (player->clearCardsToDelete() || !ok) { if (player->clearCardsToDelete() || !ok) {
return; return;
} }
for (const auto &item : selectedItems) { for (const auto &item : sel) {
const auto *card = dynamic_cast<CardItem *>(item); auto *card = dynamic_cast<CardItem *>(item);
const auto oldValue = card->getCounters().value(counterId, 0); int oldValue = card->getCounters().value(counterId, 0);
Expression exp(oldValue); Expression exp(oldValue);
const auto newValue = static_cast<int>(exp.parse(dialog.textValue())); int number = static_cast<int>(exp.parse(dialog.textValue()));
auto *cmd = new Command_SetCardCounter; auto *cmd = new Command_SetCardCounter;
cmd->set_zone(card->getZone()->getName().toStdString()); cmd->set_zone(card->getZone()->getName().toStdString());
cmd->set_card_id(card->getId()); cmd->set_card_id(card->getId());
cmd->set_counter_id(counterId); cmd->set_counter_id(counterId);
cmd->set_counter_value(newValue); cmd->set_counter_value(number);
commandList.append(cmd); commandList.append(cmd);
} }
break; break;