mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-26 08:33:54 -07:00
move_card improvement, unfinished
This commit is contained in:
parent
565384d083
commit
536c77f760
18 changed files with 129 additions and 55 deletions
|
|
@ -350,3 +350,8 @@ PendingCommand *Client::dumpZone(int player, const QString &zone, int numberCard
|
|||
{
|
||||
return cmd(QString("dump_zone|%1|%2|%3").arg(player).arg(zone).arg(numberCards));
|
||||
}
|
||||
|
||||
PendingCommand *Client::stopDumpZone(int player, const QString &zone)
|
||||
{
|
||||
return cmd(QString("stop_dump_zone|%1|%2").arg(player).arg(zone));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ public:
|
|||
PendingCommand *setActivePlayer(int player);
|
||||
PendingCommand *setActivePhase(int phase);
|
||||
PendingCommand *dumpZone(int player, const QString &zone, int numberCards);
|
||||
PendingCommand *stopDumpZone(int player, const QString &zone);
|
||||
public slots:
|
||||
void submitDeck(const QStringList &deck);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ Player *Game::addPlayer(int playerId, const QString &playerName, QPointF base, b
|
|||
Player *newPlayer = new Player(playerName, playerId, base, local, db, client, scene, this);
|
||||
|
||||
connect(newPlayer, SIGNAL(sigShowCardMenu(QPoint)), this, SLOT(showCardMenu(QPoint)));
|
||||
connect(newPlayer, SIGNAL(logMoveCard(Player *, QString, QString, QString)), this, SIGNAL(logMoveCard(Player *, QString, QString, QString)));
|
||||
connect(newPlayer, SIGNAL(logMoveCard(Player *, QString, QString, int, QString, int)), this, SIGNAL(logMoveCard(Player *, QString, QString, int, QString, int)));
|
||||
connect(newPlayer, SIGNAL(logCreateToken(Player *, QString)), this, SIGNAL(logCreateToken(Player *, QString)));
|
||||
connect(newPlayer, SIGNAL(logSetCardCounters(Player *, QString, int, int)), this, SIGNAL(logSetCardCounters(Player *, QString, int, int)));
|
||||
connect(newPlayer, SIGNAL(logSetTapped(Player *, QString, bool)), this, SIGNAL(logSetTapped(Player *, QString, bool)));
|
||||
|
|
@ -245,6 +245,11 @@ void Game::gameEvent(const ServerEventData &msg)
|
|||
emit logDumpZone(p, data[1], players.findPlayer(data[0].toInt())->getName(), data[2].toInt());
|
||||
break;
|
||||
}
|
||||
case eventStopDumpZone: {
|
||||
QStringList data = msg.getEventData();
|
||||
emit logStopDumpZone(p, data[1], players.findPlayer(data[0].toInt())->getName());
|
||||
break;
|
||||
}
|
||||
case eventMoveCard: {
|
||||
if (msg.getPlayerId() == localPlayer->getId())
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -70,13 +70,14 @@ signals:
|
|||
void logShuffle(Player *player);
|
||||
void logRollDice(Player *player, int sides, int roll);
|
||||
void logDraw(Player *player, int number);
|
||||
void logMoveCard(Player *player, QString cardName, QString startZone, QString targetZone);
|
||||
void logMoveCard(Player *player, QString cardName, QString startZone, int oldX, QString targetZone, int newX);
|
||||
void logCreateToken(Player *player, QString cardName);
|
||||
void logSetCardCounters(Player *player, QString cardName, int value, int oldValue);
|
||||
void logSetTapped(Player *player, QString cardName, bool tapped);
|
||||
void logSetCounter(Player *player, QString counterName, int value, int oldValue);
|
||||
void logSetDoesntUntap(Player *player, QString cardName, bool doesntUntap);
|
||||
void logDumpZone(Player *player, QString zoneName, QString zoneOwner, int numberCards);
|
||||
void logStopDumpZone(Player *player, QString zoneName, QString zoneOwner);
|
||||
public:
|
||||
Game(CardDatabase *_db, Client *_client, QGraphicsScene *_scene, QMenu *_actionsMenu, QMenu *_cardMenu, int playerId, const QString &playerName, QObject *parent = 0);
|
||||
~Game();
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ void MessageLogWidget::logDraw(Player *player, int number)
|
|||
append(tr("%1 draws %2 cards").arg(sanitizeHtml(player->getName())).arg(number));
|
||||
}
|
||||
|
||||
void MessageLogWidget::logMoveCard(Player *player, QString cardName, QString startZone, QString targetZone)
|
||||
void MessageLogWidget::logMoveCard(Player *player, QString cardName, QString startZone, int oldX, QString targetZone, int newX)
|
||||
{
|
||||
if ((startZone == "table") && (targetZone == "table"))
|
||||
return;
|
||||
|
|
@ -176,6 +176,10 @@ void MessageLogWidget::logDumpZone(Player *player, QString zoneName, QString zon
|
|||
append(tr("%1 is looking at %2's %3").arg(sanitizeHtml(player->getName())).arg(zoneOwner).arg(zoneName));
|
||||
}
|
||||
|
||||
void MessageLogWidget::logStopDumpZone(Player *player, QString zoneName, QString zoneOwner)
|
||||
{
|
||||
append(tr("%1 stops looking at %2's %3").arg(sanitizeHtml(player->getName())).arg(zoneOwner).arg(zoneName));
|
||||
}
|
||||
|
||||
void MessageLogWidget::connectToGame(Game *game)
|
||||
{
|
||||
|
|
@ -188,13 +192,14 @@ void MessageLogWidget::connectToGame(Game *game)
|
|||
connect(game, SIGNAL(logShuffle(Player *)), this, SLOT(logShuffle(Player *)));
|
||||
connect(game, SIGNAL(logRollDice(Player *, int, int)), this, SLOT(logRollDice(Player *, int, int)));
|
||||
connect(game, SIGNAL(logDraw(Player *, int)), this, SLOT(logDraw(Player *, int)));
|
||||
connect(game, SIGNAL(logMoveCard(Player *, QString, QString, QString)), this, SLOT(logMoveCard(Player *, QString, QString, QString)));
|
||||
connect(game, SIGNAL(logMoveCard(Player *, QString, QString, int, QString, int)), this, SLOT(logMoveCard(Player *, QString, QString, int, QString, int)));
|
||||
connect(game, SIGNAL(logCreateToken(Player *, QString)), this, SLOT(logCreateToken(Player *, QString)));
|
||||
connect(game, SIGNAL(logSetCardCounters(Player *, QString, int, int)), this, SLOT(logSetCardCounters(Player *, QString, int, int)));
|
||||
connect(game, SIGNAL(logSetTapped(Player *, QString, bool)), this, SLOT(logSetTapped(Player *, QString, bool)));
|
||||
connect(game, SIGNAL(logSetCounter(Player *, QString, int, int)), this, SLOT(logSetCounter(Player *, QString, int, int)));
|
||||
connect(game, SIGNAL(logSetDoesntUntap(Player *, QString, bool)), this, SLOT(logSetDoesntUntap(Player *, QString, bool)));
|
||||
connect(game, SIGNAL(logDumpZone(Player *, QString, QString, int)), this, SLOT(logDumpZone(Player *, QString, QString, int)));
|
||||
connect(game, SIGNAL(logStopDumpZone(Player *, QString, QString)), this, SLOT(logStopDumpZone(Player *, QString, QString)));
|
||||
}
|
||||
|
||||
MessageLogWidget::MessageLogWidget(QWidget *parent)
|
||||
|
|
|
|||
|
|
@ -28,13 +28,14 @@ private slots:
|
|||
void logShuffle(Player *player);
|
||||
void logRollDice(Player *player, int sides, int roll);
|
||||
void logDraw(Player *player, int number);
|
||||
void logMoveCard(Player *player, QString cardName, QString startZone, QString targetZone);
|
||||
void logMoveCard(Player *player, QString cardName, QString startZone, int oldX, QString targetZone, int newX);
|
||||
void logCreateToken(Player *player, QString cardName);
|
||||
void logSetCardCounters(Player *player, QString cardName, int value, int oldValue);
|
||||
void logSetTapped(Player *player, QString cardName, bool tapped);
|
||||
void logSetCounter(Player *player, QString counterName, int value, int oldValue);
|
||||
void logSetDoesntUntap(Player *player, QString cardName, bool doesntUntap);
|
||||
void logDumpZone(Player *player, QString zoneName, QString zoneOwner, int numberCards);
|
||||
void logStopDumpZone(Player *player, QString zoneName, QString zoneOwner);
|
||||
public:
|
||||
void connectToGame(Game *game);
|
||||
MessageLogWidget(QWidget *parent = 0);
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
#include "carddragitem.h"
|
||||
#include "zoneviewzone.h"
|
||||
|
||||
PileZone::PileZone(Player *_p, const QString &_name, bool _contentsKnown, QGraphicsItem *parent)
|
||||
: CardZone(_p, _name, false, false, _contentsKnown, parent)
|
||||
PileZone::PileZone(Player *_p, const QString &_name, bool _isShufflable, bool _contentsKnown, QGraphicsItem *parent)
|
||||
: CardZone(_p, _name, false, _isShufflable, _contentsKnown, parent)
|
||||
{
|
||||
setCacheMode(DeviceCoordinateCache); // Do not move this line to the parent constructor!
|
||||
setAcceptsHoverEvents(true);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
class PileZone : public CardZone {
|
||||
public:
|
||||
PileZone(Player *_p, const QString &_name, bool _contentsKnown, QGraphicsItem *parent = 0);
|
||||
PileZone(Player *_p, const QString &_name, bool _isShufflable, bool _contentsKnown, QGraphicsItem *parent = 0);
|
||||
QRectF boundingRect() const;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
void reorganizeCards();
|
||||
|
|
|
|||
|
|
@ -220,6 +220,12 @@ void Player::gameEvent(const ServerEventData &event)
|
|||
bool facedown = data[7].toInt();
|
||||
// XXX Mehr Fehlerbehandlung
|
||||
|
||||
int logPosition = position;
|
||||
int logX = x;
|
||||
if (position == -1)
|
||||
position = 0;
|
||||
if (x == -1)
|
||||
x = 0;
|
||||
CardItem *card = startZone->takeCard(position, cardId, cardName);
|
||||
if (!card) // XXX
|
||||
qDebug("moveCard: card not found");
|
||||
|
|
@ -230,7 +236,7 @@ void Player::gameEvent(const ServerEventData &event)
|
|||
|
||||
// The log event has to be sent before the card is added to the target zone
|
||||
// because the addCard function can modify the card object.
|
||||
emit logMoveCard(this, card->getName(), startZone->getName(), targetZone->getName());
|
||||
emit logMoveCard(this, card->getName(), startZone->getName(), logPosition, targetZone->getName(), logX);
|
||||
|
||||
targetZone->addCard(card, true, x, y);
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ signals:
|
|||
void toggleZoneView(Player *player, QString zoneName, int number);
|
||||
void sigShowCardMenu(QPoint p);
|
||||
// Log events
|
||||
void logMoveCard(Player *player, QString cardName, QString startZone, QString targetZone);
|
||||
void logMoveCard(Player *player, QString cardName, QString startZone, int oldX, QString targetZone, int newX);
|
||||
void logCreateToken(Player *player, QString cardName);
|
||||
void logSetCardCounters(Player *player, QString cardName, int value, int oldValue);
|
||||
void logSetTapped(Player *player, QString cardName, bool tapped);
|
||||
|
|
|
|||
|
|
@ -13,18 +13,18 @@ PlayerArea::PlayerArea(Player *_player, QGraphicsItem *parent)
|
|||
|
||||
QPointF base = QPointF(55, 50);
|
||||
|
||||
PileZone *deck = new PileZone(_player, "deck", false, this);
|
||||
PileZone *deck = new PileZone(_player, "deck", true, false, this);
|
||||
deck->setPos(base);
|
||||
|
||||
qreal h = deck->boundingRect().height() + 20;
|
||||
|
||||
PileZone *grave = new PileZone(_player, "grave", true, this);
|
||||
PileZone *grave = new PileZone(_player, "grave", false, true, this);
|
||||
grave->setPos(base + QPointF(0, h));
|
||||
|
||||
PileZone *rfg = new PileZone(_player, "rfg", true, this);
|
||||
PileZone *rfg = new PileZone(_player, "rfg", false, true, this);
|
||||
rfg->setPos(base + QPointF(0, 2 * h));
|
||||
|
||||
PileZone *sb = new PileZone(_player, "sb", true, this);
|
||||
PileZone *sb = new PileZone(_player, "sb", false, true, this);
|
||||
sb->setVisible(false);
|
||||
|
||||
base = QPointF(deck->boundingRect().width() + 60, 0);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// Message structure for server events:
|
||||
// {"private","public"}|PlayerId|PlayerName|EventType|EventData
|
||||
|
||||
const int event_count = 20;
|
||||
const int event_count = 21;
|
||||
const event_string event_strings[event_count] = {
|
||||
{eventPlayerId, "player_id"},
|
||||
{eventSay, "say"},
|
||||
|
|
@ -24,7 +24,8 @@ const event_string event_strings[event_count] = {
|
|||
{eventDelCounter, "del_counter"},
|
||||
{eventSetActivePlayer, "set_active_player"},
|
||||
{eventSetActivePhase, "set_active_phase"},
|
||||
{eventDumpZone, "dump_zone"}
|
||||
{eventDumpZone, "dump_zone"},
|
||||
{eventStopDumpZone, "stop_dump_zone"}
|
||||
};
|
||||
|
||||
ServerEventData::ServerEventData(const QString &line)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include <QStringList>
|
||||
|
||||
|
||||
enum ServerEventType {
|
||||
eventInvalid,
|
||||
eventPlayerId,
|
||||
|
|
@ -25,7 +24,8 @@ enum ServerEventType {
|
|||
eventDelCounter,
|
||||
eventSetActivePlayer,
|
||||
eventSetActivePhase,
|
||||
eventDumpZone
|
||||
eventDumpZone,
|
||||
eventStopDumpZone
|
||||
};
|
||||
|
||||
struct event_string {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ ZoneViewWidget::ZoneViewWidget(CardDatabase *_db, Player *_player, CardZone *_or
|
|||
|
||||
qreal y = 10;
|
||||
if (_origZone->getIsShufflable() && (numberCards == 0)) {
|
||||
qDebug(QString("ZoneViewWidget: bla!").toLatin1());
|
||||
shuffleCheckBox = new QCheckBox("shuffle when closing");
|
||||
shuffleCheckBox->setChecked(true);
|
||||
QGraphicsProxyWidget *shuffleProxy = new QGraphicsProxyWidget(this);
|
||||
|
|
@ -65,6 +66,7 @@ void ZoneViewWidget::zoneDumpReceived(int commandId, QList<ServerZoneCard *> car
|
|||
|
||||
void ZoneViewWidget::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
player->client->stopDumpZone(player->getId(), zone->getName());
|
||||
if (shuffleCheckBox)
|
||||
if (shuffleCheckBox->isChecked())
|
||||
player->client->shuffle();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue