mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-01 19:13:55 -07:00
moved carddraw from game to player; qt 4.4 compilation fix; minor behaviour change
This commit is contained in:
parent
557aed2ed7
commit
0d84de2384
8 changed files with 315 additions and 260 deletions
|
|
@ -37,15 +37,6 @@ Game::Game(CardDatabase *_db, Client *_client, QGraphicsScene *_scene, QMenu *_a
|
|||
aSetLife->setShortcut(tr("Ctrl+L"));
|
||||
connect(aSetLife, SIGNAL(triggered()), this, SLOT(actSetLife()));
|
||||
|
||||
aShuffle = new QAction(tr("&Shuffle"), this);
|
||||
aShuffle->setShortcut(tr("Ctrl+S"));
|
||||
connect(aShuffle, SIGNAL(triggered()), this, SLOT(actShuffle()));
|
||||
aDraw = new QAction(tr("&Draw a card"), this);
|
||||
aDraw->setShortcut(tr("Ctrl+D"));
|
||||
connect(aDraw, SIGNAL(triggered()), this, SLOT(actDrawCard()));
|
||||
aDrawCards = new QAction(tr("D&raw cards..."), this);
|
||||
connect(aDrawCards, SIGNAL(triggered()), this, SLOT(actDrawCards()));
|
||||
aDrawCards->setShortcut(tr("Ctrl+E"));
|
||||
aRollDice = new QAction(tr("R&oll dice..."), this);
|
||||
aRollDice->setShortcut(tr("Ctrl+I"));
|
||||
connect(aRollDice, SIGNAL(triggered()), this, SLOT(actRollDice()));
|
||||
|
|
@ -70,9 +61,6 @@ Game::Game(CardDatabase *_db, Client *_client, QGraphicsScene *_scene, QMenu *_a
|
|||
actionsMenu->addAction(aIncLife);
|
||||
actionsMenu->addAction(aSetLife);
|
||||
actionsMenu->addSeparator();
|
||||
actionsMenu->addAction(aShuffle);
|
||||
actionsMenu->addAction(aDraw);
|
||||
actionsMenu->addAction(aDrawCards);
|
||||
actionsMenu->addAction(aRollDice);
|
||||
actionsMenu->addSeparator();
|
||||
actionsMenu->addAction(aCreateToken);
|
||||
|
|
@ -354,11 +342,6 @@ void Game::actSetLife()
|
|||
client->setCounter("life", life);
|
||||
}
|
||||
|
||||
void Game::actShuffle()
|
||||
{
|
||||
client->shuffle();
|
||||
}
|
||||
|
||||
void Game::actRollDice()
|
||||
{
|
||||
bool ok;
|
||||
|
|
@ -367,18 +350,6 @@ void Game::actRollDice()
|
|||
client->rollDice(sides);
|
||||
}
|
||||
|
||||
void Game::actDrawCard()
|
||||
{
|
||||
client->drawCards(1);
|
||||
}
|
||||
|
||||
void Game::actDrawCards()
|
||||
{
|
||||
int number = QInputDialog::getInteger(0, tr("Draw cards"), tr("Number:"));
|
||||
if (number)
|
||||
client->drawCards(number);
|
||||
}
|
||||
|
||||
void Game::actCreateToken()
|
||||
{
|
||||
QString cardname = QInputDialog::getText(0, tr("Create token"), tr("Name:"));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef GAME_H
|
||||
#define GAME_H
|
||||
|
||||
#include <QHash>
|
||||
#include "playerlist.h"
|
||||
|
||||
class ServerPlayer;
|
||||
|
|
@ -23,7 +24,7 @@ private:
|
|||
QMenu *actionsMenu, *sayMenu, *cardMenu, *moveMenu;
|
||||
QAction *aTap, *aUntap, *aDoesntUntap, *aFlip, *aAddCounter, *aRemoveCounter, *aSetCounters,
|
||||
*aMoveToTopLibrary, *aMoveToBottomLibrary, *aMoveToGraveyard, *aMoveToExile,
|
||||
*aNextPhase, *aNextTurn, *aUntapAll, *aDecLife, *aIncLife, *aSetLife, *aShuffle, *aDraw, *aDrawCards, *aRollDice, *aCreateToken;
|
||||
*aNextPhase, *aNextTurn, *aUntapAll, *aDecLife, *aIncLife, *aSetLife, *aRollDice, *aCreateToken;
|
||||
DlgStartGame *dlgStartGame;
|
||||
|
||||
CardDatabase *db;
|
||||
|
|
@ -44,9 +45,6 @@ private slots:
|
|||
void actIncLife();
|
||||
void actDecLife();
|
||||
void actSetLife();
|
||||
void actShuffle();
|
||||
void actDrawCard();
|
||||
void actDrawCards();
|
||||
void actRollDice();
|
||||
void actCreateToken();
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include <QLibraryInfo>
|
||||
#include <QDateTime>
|
||||
#include <QSettings>
|
||||
#include <QIcon>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "window_main.h"
|
||||
|
|
|
|||
|
|
@ -16,17 +16,18 @@ Player::Player(const QString &_name, int _id, QPointF _base, bool _local, CardDa
|
|||
area->setPos(_base);
|
||||
_scene->addItem(area);
|
||||
|
||||
aMoveHandToTopLibrary = new QAction(tr("Move to &top of library"), this);
|
||||
connect(aMoveHandToTopLibrary, SIGNAL(triggered()), this, SLOT(actMoveHandToTopLibrary()));
|
||||
aMoveHandToBottomLibrary = new QAction(tr("Move to &bottom of library"), this);
|
||||
connect(aMoveHandToBottomLibrary, SIGNAL(triggered()), this, SLOT(actMoveHandToBottomLibrary()));
|
||||
if (local) {
|
||||
aMoveHandToTopLibrary = new QAction(tr("Move to &top of library"), this);
|
||||
connect(aMoveHandToTopLibrary, SIGNAL(triggered()), this, SLOT(actMoveHandToTopLibrary()));
|
||||
aMoveHandToBottomLibrary = new QAction(tr("Move to &bottom of library"), this);
|
||||
connect(aMoveHandToBottomLibrary, SIGNAL(triggered()), this, SLOT(actMoveHandToBottomLibrary()));
|
||||
|
||||
aViewLibrary = new QAction(tr("&View library"), this);
|
||||
if (local)
|
||||
aViewLibrary = new QAction(tr("&View library"), this);
|
||||
aViewLibrary->setShortcut(tr("F3"));
|
||||
connect(aViewLibrary, SIGNAL(triggered()), this, SLOT(actViewLibrary()));
|
||||
aViewTopCards = new QAction(tr("View &top cards of library..."), this);
|
||||
connect(aViewTopCards, SIGNAL(triggered()), this, SLOT(actViewTopCards()));
|
||||
connect(aViewLibrary, SIGNAL(triggered()), this, SLOT(actViewLibrary()));
|
||||
aViewTopCards = new QAction(tr("View &top cards of library..."), this);
|
||||
connect(aViewTopCards, SIGNAL(triggered()), this, SLOT(actViewTopCards()));
|
||||
}
|
||||
|
||||
aViewGraveyard = new QAction(tr("&View graveyard"), this);
|
||||
if (local)
|
||||
|
|
@ -36,20 +37,37 @@ Player::Player(const QString &_name, int _id, QPointF _base, bool _local, CardDa
|
|||
aViewRfg = new QAction(tr("&View removed cards"), this);
|
||||
connect(aViewRfg, SIGNAL(triggered()), this, SLOT(actViewRfg()));
|
||||
|
||||
aViewSideboard = new QAction(tr("&View sideboard"), this);
|
||||
connect(aViewSideboard, SIGNAL(triggered()), this, SLOT(actViewSideboard()));
|
||||
if (local) {
|
||||
aViewSideboard = new QAction(tr("&View sideboard"), this);
|
||||
connect(aViewSideboard, SIGNAL(triggered()), this, SLOT(actViewSideboard()));
|
||||
|
||||
aDrawCard = new QAction(tr("&Draw card"), this);
|
||||
connect(aDrawCard, SIGNAL(triggered()), this, SLOT(actDrawCard()));
|
||||
aDrawCard->setShortcut(tr("Ctrl+D"));
|
||||
aDrawCards = new QAction(tr("D&raw cards..."), this);
|
||||
connect(aDrawCards, SIGNAL(triggered()), this, SLOT(actDrawCards()));
|
||||
aDrawCards->setShortcut(tr("Ctrl+E"));
|
||||
aShuffle = new QAction(tr("&Shuffle"), this);
|
||||
connect(aShuffle, SIGNAL(triggered()), this, SLOT(actShuffle()));
|
||||
aShuffle->setShortcut(tr("Ctrl+S"));
|
||||
}
|
||||
|
||||
playerMenu = new QMenu(tr("Player \"%1\"").arg(name));
|
||||
|
||||
QMenu *handMenu = playerMenu->addMenu(tr("&Hand"));
|
||||
handMenu->addAction(aMoveHandToTopLibrary);
|
||||
handMenu->addAction(aMoveHandToBottomLibrary);
|
||||
zones.findZone("hand")->setMenu(handMenu);
|
||||
if (local) {
|
||||
QMenu *handMenu = playerMenu->addMenu(tr("&Hand"));
|
||||
handMenu->addAction(aMoveHandToTopLibrary);
|
||||
handMenu->addAction(aMoveHandToBottomLibrary);
|
||||
zones.findZone("hand")->setMenu(handMenu);
|
||||
|
||||
QMenu *libraryMenu = playerMenu->addMenu(tr("&Library"));
|
||||
libraryMenu->addAction(aViewLibrary);
|
||||
libraryMenu->addAction(aViewTopCards);
|
||||
zones.findZone("deck")->setMenu(libraryMenu, aViewLibrary);
|
||||
QMenu *libraryMenu = playerMenu->addMenu(tr("&Library"));
|
||||
libraryMenu->addAction(aDrawCard);
|
||||
libraryMenu->addAction(aDrawCards);
|
||||
libraryMenu->addSeparator();
|
||||
libraryMenu->addAction(aViewLibrary);
|
||||
libraryMenu->addAction(aViewTopCards);
|
||||
zones.findZone("deck")->setMenu(libraryMenu, aDrawCard);
|
||||
}
|
||||
|
||||
QMenu *graveMenu = playerMenu->addMenu(tr("&Graveyard"));
|
||||
graveMenu->addAction(aViewGraveyard);
|
||||
|
|
@ -59,9 +77,11 @@ Player::Player(const QString &_name, int _id, QPointF _base, bool _local, CardDa
|
|||
rfgMenu->addAction(aViewRfg);
|
||||
zones.findZone("rfg")->setMenu(rfgMenu, aViewRfg);
|
||||
|
||||
QMenu *sbMenu = playerMenu->addMenu(tr("&Sideboard"));
|
||||
sbMenu->addAction(aViewSideboard);
|
||||
zones.findZone("sb")->setMenu(sbMenu, aViewSideboard);
|
||||
if (local) {
|
||||
QMenu *sbMenu = playerMenu->addMenu(tr("&Sideboard"));
|
||||
sbMenu->addAction(aViewSideboard);
|
||||
zones.findZone("sb")->setMenu(sbMenu, aViewSideboard);
|
||||
}
|
||||
}
|
||||
|
||||
Player::~Player()
|
||||
|
|
@ -114,6 +134,23 @@ void Player::actViewSideboard()
|
|||
emit toggleZoneView(this, "sb", -1);
|
||||
}
|
||||
|
||||
void Player::actShuffle()
|
||||
{
|
||||
client->shuffle();
|
||||
}
|
||||
|
||||
void Player::actDrawCard()
|
||||
{
|
||||
client->drawCards(1);
|
||||
}
|
||||
|
||||
void Player::actDrawCards()
|
||||
{
|
||||
int number = QInputDialog::getInteger(0, tr("Draw cards"), tr("Number:"));
|
||||
if (number)
|
||||
client->drawCards(number);
|
||||
}
|
||||
|
||||
void Player::addZone(CardZone *z)
|
||||
{
|
||||
zones << z;
|
||||
|
|
|
|||
|
|
@ -33,18 +33,20 @@ private slots:
|
|||
void actMoveHandToTopLibrary();
|
||||
void actMoveHandToBottomLibrary();
|
||||
|
||||
void actShuffle();
|
||||
void actDrawCard();
|
||||
void actDrawCards();
|
||||
|
||||
void actViewLibrary();
|
||||
void actViewTopCards();
|
||||
|
||||
void actViewGraveyard();
|
||||
|
||||
void actViewRfg();
|
||||
|
||||
void actViewSideboard();
|
||||
private:
|
||||
QMenu *playerMenu;
|
||||
QAction *aMoveHandToTopLibrary, *aMoveHandToBottomLibrary,
|
||||
*aViewLibrary, *aViewTopCards, *aViewGraveyard, *aViewRfg, *aViewSideboard;
|
||||
*aViewLibrary, *aViewTopCards, *aViewGraveyard, *aViewRfg, *aViewSideboard,
|
||||
*aDrawCard, *aDrawCards, *aShuffle;
|
||||
|
||||
int defaultNumberTopCards;
|
||||
QString name;
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ void MainWindow::statusChanged(ProtocolStatus _status)
|
|||
aDisconnect->setEnabled(false);
|
||||
aRestartGame->setEnabled(false);
|
||||
aLeaveGame->setEnabled(false);
|
||||
phasesToolbar->setActivePhase(-1);
|
||||
phasesToolbar->setEnabled(false);
|
||||
emit logDisconnected();
|
||||
break;
|
||||
|
|
@ -82,10 +83,12 @@ void MainWindow::statusChanged(ProtocolStatus _status)
|
|||
}
|
||||
aRestartGame->setEnabled(false);
|
||||
aLeaveGame->setEnabled(false);
|
||||
phasesToolbar->setActivePhase(-1);
|
||||
phasesToolbar->setEnabled(false);
|
||||
|
||||
GameSelector *gameSelector = new GameSelector(client);
|
||||
viewLayout->insertWidget(0, gameSelector);
|
||||
break;
|
||||
}
|
||||
case StatusPlaying:
|
||||
phasesToolbar->setEnabled(true);
|
||||
|
|
@ -186,6 +189,8 @@ void MainWindow::serverTimeout()
|
|||
|
||||
void MainWindow::retranslateUi()
|
||||
{
|
||||
setWindowTitle(tr("Cockatrice"));
|
||||
|
||||
aConnect->setText(tr("&Connect..."));
|
||||
aDisconnect->setText(tr("&Disconnect"));
|
||||
aRestartGame->setText(tr("&Restart game..."));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue