mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-12 17:14:52 -07:00
[Game] Refactor: move proliferate action code to PlayerActions (#6926)
This commit is contained in:
parent
81a2712b92
commit
09d817770e
5 changed files with 39 additions and 38 deletions
|
|
@ -304,42 +304,6 @@ CounterState *PlayerLogic::getLifeCounter() const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void PlayerLogic::incrementAllCardCounters()
|
||||
{
|
||||
auto cardsToUpdate = getGameScene()->selectedCards();
|
||||
if (cardsToUpdate.isEmpty()) {
|
||||
// If no cards selected, update all cards on table
|
||||
cardsToUpdate = static_cast<QList<CardItem *>>(getTableZone()->getCards());
|
||||
}
|
||||
|
||||
QList<const ::google::protobuf::Message *> commandList;
|
||||
|
||||
for (const auto *card : cardsToUpdate) {
|
||||
const auto &cardCounters = card->getCounters();
|
||||
|
||||
QMapIterator<int, int> counterIterator(cardCounters);
|
||||
while (counterIterator.hasNext()) {
|
||||
counterIterator.next();
|
||||
int counterId = counterIterator.key();
|
||||
int currentValue = counterIterator.value();
|
||||
if (currentValue >= MAX_COUNTERS_ON_CARD) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto cmd = std::make_unique<Command_SetCardCounter>();
|
||||
cmd->set_zone(card->getZone()->getName().toStdString());
|
||||
cmd->set_card_id(card->getId());
|
||||
cmd->set_counter_id(counterId);
|
||||
cmd->set_counter_value(currentValue + 1);
|
||||
commandList.append(cmd.release());
|
||||
}
|
||||
}
|
||||
|
||||
if (!commandList.isEmpty()) {
|
||||
playerActions->sendGameCommand(playerActions->prepareGameCommand(commandList));
|
||||
}
|
||||
}
|
||||
|
||||
bool PlayerLogic::clearCardsToDelete()
|
||||
{
|
||||
if (cardsToDelete.isEmpty()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue