mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-15 03:28:49 -07:00
phases + small message log fix
This commit is contained in:
parent
5f110af562
commit
05f63bb631
6 changed files with 235 additions and 170 deletions
|
|
@ -14,7 +14,7 @@
|
|||
#include "counter.h"
|
||||
|
||||
Game::Game(CardDatabase *_db, Client *_client, QGraphicsScene *_scene, QMenu *_actionsMenu, QMenu *_cardMenu, int playerId, const QString &playerName, QObject *parent)
|
||||
: QObject(parent), actionsMenu(_actionsMenu), cardMenu(_cardMenu), db(_db), client(_client), scene(_scene), started(false)
|
||||
: QObject(parent), actionsMenu(_actionsMenu), cardMenu(_cardMenu), db(_db), client(_client), scene(_scene), started(false), currentPhase(-1)
|
||||
{
|
||||
QRectF sr = scene->sceneRect();
|
||||
localPlayer = addPlayer(playerId, playerName, QPointF(0, sr.y() + sr.height() / 2 + 2), true);
|
||||
|
|
@ -53,6 +53,16 @@ Game::Game(CardDatabase *_db, Client *_client, QGraphicsScene *_scene, QMenu *_a
|
|||
aCreateToken->setShortcut(tr("Ctrl+T"));
|
||||
connect(aCreateToken, SIGNAL(triggered()), this, SLOT(actCreateToken()));
|
||||
|
||||
aNextPhase = new QAction(tr("Next &phase"), this);
|
||||
aNextPhase->setShortcut(tr("Ctrl+Space"));
|
||||
connect(aNextPhase, SIGNAL(triggered()), this, SLOT(actNextPhase()));
|
||||
aNextTurn = new QAction(tr("Next &turn"), this);
|
||||
aNextTurn->setShortcut(tr("Ctrl+Enter"));
|
||||
connect(aNextTurn, SIGNAL(triggered()), this, SLOT(actNextTurn()));
|
||||
|
||||
actionsMenu->addAction(aNextPhase);
|
||||
actionsMenu->addAction(aNextTurn);
|
||||
actionsMenu->addSeparator();
|
||||
actionsMenu->addAction(aUntapAll);
|
||||
actionsMenu->addSeparator();
|
||||
actionsMenu->addAction(aDecLife);
|
||||
|
|
@ -240,6 +250,7 @@ void Game::gameEvent(const ServerEventData &msg)
|
|||
case eventSetActivePhase: {
|
||||
QStringList data = msg.getEventData();
|
||||
int phase = data[0].toInt();
|
||||
currentPhase = phase;
|
||||
emit setActivePhase(phase);
|
||||
break;
|
||||
}
|
||||
|
|
@ -284,6 +295,19 @@ void Game::gameEvent(const ServerEventData &msg)
|
|||
}
|
||||
}
|
||||
|
||||
void Game::actNextPhase()
|
||||
{
|
||||
int phase = currentPhase;
|
||||
if (++phase >= phaseCount)
|
||||
phase = 0;
|
||||
client->setActivePhase(phase);
|
||||
}
|
||||
|
||||
void Game::actNextTurn()
|
||||
{
|
||||
client->nextTurn();
|
||||
}
|
||||
|
||||
void Game::actUntapAll()
|
||||
{
|
||||
client->setCardAttr("table", -1, "tapped", "false");
|
||||
|
|
|
|||
|
|
@ -15,9 +15,11 @@ class CardItem;
|
|||
class Game : public QObject {
|
||||
Q_OBJECT
|
||||
private:
|
||||
static const int phaseCount = 11;
|
||||
|
||||
QMenu *actionsMenu, *sayMenu, *cardMenu;
|
||||
QAction *aTap, *aUntap, *aDoesntUntap, *aFlip, *aAddCounter, *aRemoveCounter, *aSetCounters,
|
||||
*aUntapAll, *aDecLife, *aIncLife, *aSetLife, *aShuffle, *aDraw, *aDrawCards, *aRollDice, *aCreateToken;
|
||||
*aNextPhase, *aNextTurn, *aUntapAll, *aDecLife, *aIncLife, *aSetLife, *aShuffle, *aDraw, *aDrawCards, *aRollDice, *aCreateToken;
|
||||
DlgStartGame *dlgStartGame;
|
||||
|
||||
CardDatabase *db;
|
||||
|
|
@ -26,9 +28,12 @@ private:
|
|||
PlayerList players;
|
||||
Player *localPlayer;
|
||||
bool started;
|
||||
int currentPhase;
|
||||
Player *addPlayer(int playerId, const QString &playerName, QPointF base, bool local);
|
||||
void initSayMenu();
|
||||
private slots:
|
||||
void actNextPhase();
|
||||
void actNextTurn();
|
||||
void actUntapAll();
|
||||
void actIncLife();
|
||||
void actDecLife();
|
||||
|
|
|
|||
|
|
@ -97,9 +97,6 @@ void MessageLogWidget::logDraw(Player *player, int number)
|
|||
|
||||
void MessageLogWidget::logMoveCard(Player *player, QString cardName, CardZone *startZone, int oldX, CardZone *targetZone, int newX)
|
||||
{
|
||||
if (cardName.isEmpty())
|
||||
cardName = tr("a card");
|
||||
|
||||
QString startName = startZone->getName();
|
||||
QString targetName = targetZone->getName();
|
||||
if (((startName == "table") && (targetName == "table")) || ((startName == "hand") && (targetName == "hand")))
|
||||
|
|
@ -144,7 +141,7 @@ void MessageLogWidget::logMoveCard(Player *player, QString cardName, CardZone *s
|
|||
} else if (targetName == "sb")
|
||||
finalStr = tr("%1 moves %2 %3 to sideboard");
|
||||
|
||||
append(finalStr.arg(sanitizeHtml(player->getName())).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(cardName))).arg(fromStr).arg(newX));
|
||||
append(finalStr.arg(sanitizeHtml(player->getName())).arg(cardName.isEmpty() ? tr("a card") : QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(cardName))).arg(fromStr).arg(newX));
|
||||
}
|
||||
|
||||
void MessageLogWidget::logCreateToken(Player *player, QString cardName)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
PhaseButton::PhaseButton(QIcon icon)
|
||||
: QPushButton(icon, QString()), active(false)
|
||||
{
|
||||
|
||||
setFixedSize(50, 50);
|
||||
}
|
||||
|
||||
void PhaseButton::update()
|
||||
|
|
@ -23,18 +23,16 @@ void PhaseButton::paintEvent(QPaintEvent *event)
|
|||
int height = size().height();
|
||||
int width = size().width();
|
||||
|
||||
QPen pen;
|
||||
pen.setColor(QColor::fromRgb(180, 0, 0, 200));
|
||||
painter.setPen(pen);
|
||||
painter.setPen(QPen(Qt::transparent));
|
||||
|
||||
QRadialGradient grad(QPointF(0.5, 0.5), 0.5);
|
||||
grad.setCoordinateMode(QGradient::ObjectBoundingMode);
|
||||
grad.setColorAt(0, QColor(180, 0, 0, 0));
|
||||
grad.setColorAt(0.8, QColor(180, 0, 0, 0));
|
||||
grad.setColorAt(1, QColor(180, 0, 0, 200));
|
||||
grad.setColorAt(1, QColor(180, 0, 0, 255));
|
||||
painter.setBrush(QBrush(grad));
|
||||
|
||||
painter.drawRect(3, 3, width - 7, height - 7);
|
||||
painter.drawRect(2, 2, width - 4, height - 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -70,6 +68,7 @@ PhasesToolbar::PhasesToolbar(QWidget *parent)
|
|||
|
||||
QPushButton *nextTurnButton = new QPushButton(QIcon(":/resources/icon_nextturn.svg"), QString());
|
||||
nextTurnButton->setIconSize(QSize(36, 36));
|
||||
nextTurnButton->setFixedSize(50, 50);
|
||||
connect(nextTurnButton, SIGNAL(clicked()), this, SIGNAL(signalNextTurn()));
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue