mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-08 02:53:25 -08:00
[Refactor] Build player counter commands in game/ instead of AbstractCounter
This commit is contained in:
parent
fa14179445
commit
0f5b1a032a
3 changed files with 28 additions and 14 deletions
|
|
@ -60,6 +60,7 @@
|
||||||
#include <libcockatrice/protocol/pb/command_roll_die.pb.h>
|
#include <libcockatrice/protocol/pb/command_roll_die.pb.h>
|
||||||
#include <libcockatrice/protocol/pb/command_set_card_attr.pb.h>
|
#include <libcockatrice/protocol/pb/command_set_card_attr.pb.h>
|
||||||
#include <libcockatrice/protocol/pb/command_set_card_counter.pb.h>
|
#include <libcockatrice/protocol/pb/command_set_card_counter.pb.h>
|
||||||
|
#include <libcockatrice/protocol/pb/command_set_counter.pb.h>
|
||||||
#include <libcockatrice/protocol/pb/command_shuffle.pb.h>
|
#include <libcockatrice/protocol/pb/command_shuffle.pb.h>
|
||||||
#include <libcockatrice/protocol/pb/command_undo_draw.pb.h>
|
#include <libcockatrice/protocol/pb/command_undo_draw.pb.h>
|
||||||
#include <libcockatrice/settings/card_override_settings.h>
|
#include <libcockatrice/settings/card_override_settings.h>
|
||||||
|
|
@ -1450,6 +1451,24 @@ void PlayerActions::actFlowT(QList<CardItem *> selectedCards)
|
||||||
actIncPT(selectedCards, -1, 1);
|
actIncPT(selectedCards, -1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlayerActions::actIncrementCounter(int counterId, int delta)
|
||||||
|
{
|
||||||
|
Command_IncCounter cmd;
|
||||||
|
cmd.set_counter_id(counterId);
|
||||||
|
cmd.set_delta(delta);
|
||||||
|
|
||||||
|
sendGameCommand(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlayerActions::actSetCounter(int counterId, int value)
|
||||||
|
{
|
||||||
|
Command_SetCounter cmd;
|
||||||
|
cmd.set_counter_id(counterId);
|
||||||
|
cmd.set_value(value);
|
||||||
|
|
||||||
|
sendGameCommand(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
void PlayerActions::actReduceLifeByPower(QList<CardItem *> selectedCards)
|
void PlayerActions::actReduceLifeByPower(QList<CardItem *> selectedCards)
|
||||||
{
|
{
|
||||||
// find life counter
|
// find life counter
|
||||||
|
|
|
||||||
|
|
@ -239,6 +239,12 @@ public slots:
|
||||||
void actFlowP(QList<CardItem *> selectedCards);
|
void actFlowP(QList<CardItem *> selectedCards);
|
||||||
void actFlowT(QList<CardItem *> selectedCards);
|
void actFlowT(QList<CardItem *> selectedCards);
|
||||||
|
|
||||||
|
/** @brief Adjusts a player counter by a signed delta. */
|
||||||
|
void actIncrementCounter(int counterId, int delta);
|
||||||
|
|
||||||
|
/** @brief Sets a player counter to an absolute value. */
|
||||||
|
void actSetCounter(int counterId, int value);
|
||||||
|
|
||||||
void actReduceLifeByPower(QList<CardItem *> selectedCards);
|
void actReduceLifeByPower(QList<CardItem *> selectedCards);
|
||||||
|
|
||||||
void actRequestSetAnnotationDialog(QList<CardItem *> selectedCards);
|
void actRequestSetAnnotationDialog(QList<CardItem *> selectedCards);
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,6 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <libcockatrice/protocol/pb/command_inc_counter.pb.h>
|
|
||||||
#include <libcockatrice/protocol/pb/command_set_counter.pb.h>
|
|
||||||
#include <libcockatrice/utility/expression.h>
|
#include <libcockatrice/utility/expression.h>
|
||||||
#include <qnamespace.h>
|
#include <qnamespace.h>
|
||||||
|
|
||||||
|
|
@ -151,10 +149,7 @@ void AbstractCounter::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
menu->exec(event->screenPos());
|
menu->exec(event->screenPos());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Command_IncCounter cmd;
|
player->getPlayerActions()->actIncrementCounter(id, event->button() == Qt::LeftButton ? 1 : -1);
|
||||||
cmd.set_counter_id(id);
|
|
||||||
cmd.set_delta(event->button() == Qt::LeftButton ? 1 : -1);
|
|
||||||
player->getPlayerActions()->sendGameCommand(cmd);
|
|
||||||
}
|
}
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
@ -172,10 +167,7 @@ void AbstractCounter::hoverLeaveEvent(QGraphicsSceneHoverEvent *)
|
||||||
|
|
||||||
void AbstractCounter::incrementCounter()
|
void AbstractCounter::incrementCounter()
|
||||||
{
|
{
|
||||||
Command_IncCounter cmd;
|
player->getPlayerActions()->actIncrementCounter(id, static_cast<QAction *>(sender())->data().toInt());
|
||||||
cmd.set_counter_id(id);
|
|
||||||
cmd.set_delta(static_cast<QAction *>(sender())->data().toInt());
|
|
||||||
player->getPlayerActions()->sendGameCommand(cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractCounter::setCounter()
|
void AbstractCounter::setCounter()
|
||||||
|
|
@ -199,10 +191,7 @@ void AbstractCounter::setCounter()
|
||||||
}
|
}
|
||||||
|
|
||||||
Expression exp(value);
|
Expression exp(value);
|
||||||
Command_SetCounter cmd;
|
player->getPlayerActions()->actSetCounter(id, static_cast<int>(exp.parse(dlg.textValue())));
|
||||||
cmd.set_counter_id(id);
|
|
||||||
cmd.set_value(static_cast<int>(exp.parse(dlg.textValue())));
|
|
||||||
player->getPlayerActions()->sendGameCommand(cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractCounterDialog::AbstractCounterDialog(const QString &name, const QString &value, QWidget *parent)
|
AbstractCounterDialog::AbstractCounterDialog(const QString &name, const QString &value, QWidget *parent)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue