mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-22 06:43:54 -07:00
[Game] Implement action to automatically take damage from creatures (#6869)
* [Game] Implement action to automatically take damage from creatures * cleanup
This commit is contained in:
parent
67f6ab66f0
commit
762e742be0
7 changed files with 58 additions and 0 deletions
|
|
@ -19,6 +19,7 @@
|
|||
#include <libcockatrice/protocol/pb/command_draw_cards.pb.h>
|
||||
#include <libcockatrice/protocol/pb/command_flip_card.pb.h>
|
||||
#include <libcockatrice/protocol/pb/command_game_say.pb.h>
|
||||
#include <libcockatrice/protocol/pb/command_inc_counter.pb.h>
|
||||
#include <libcockatrice/protocol/pb/command_move_card.pb.h>
|
||||
#include <libcockatrice/protocol/pb/command_mulligan.pb.h>
|
||||
#include <libcockatrice/protocol/pb/command_reveal_cards.pb.h>
|
||||
|
|
@ -1378,6 +1379,32 @@ void PlayerActions::actFlowT()
|
|||
actIncPT(-1, 1);
|
||||
}
|
||||
|
||||
void PlayerActions::actReduceLifeByPower()
|
||||
{
|
||||
// find life counter
|
||||
auto lifeCounter = player->getLifeCounter();
|
||||
if (!lifeCounter) {
|
||||
return;
|
||||
}
|
||||
|
||||
// calculate total power
|
||||
auto cards = player->getGameScene()->selectedCards();
|
||||
int total = 0;
|
||||
for (auto card : cards) {
|
||||
QVariantList parsed = CardItem::parsePT(card->getPT());
|
||||
if (!parsed.isEmpty()) {
|
||||
int power = parsed.first().toInt(); // toInt will default to 0 if it's not an int
|
||||
total += qMax(power, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// send cmd
|
||||
Command_IncCounter cmd;
|
||||
cmd.set_counter_id(lifeCounter->getId());
|
||||
cmd.set_delta(-total);
|
||||
sendGameCommand(prepareGameCommand(cmd));
|
||||
}
|
||||
|
||||
void AnnotationDialog::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if (event->key() == Qt::Key_Return && event->modifiers() & Qt::ControlModifier) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue