mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-02 19:43:55 -07:00
preliminary AlwaysRevealTopCard support related to issue #31, server code cleanup (finally removed getGameState)
This commit is contained in:
parent
75bac4a5b9
commit
7417236c3a
28 changed files with 329 additions and 184 deletions
|
|
@ -25,6 +25,7 @@ protected:
|
|||
bool hasCardAttr;
|
||||
bool isShufflable;
|
||||
bool isView;
|
||||
bool alwaysRevealTopCard;
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
virtual void addCardImpl(CardItem *card, int x, int y) = 0;
|
||||
|
|
@ -61,6 +62,8 @@ public:
|
|||
virtual void reorganizeCards() = 0;
|
||||
virtual QPointF closestGridPoint(const QPointF &point);
|
||||
bool getIsView() const { return isView; }
|
||||
bool getAlwaysRevealTopCard() const { return alwaysRevealTopCard; }
|
||||
void setAlwaysRevealTopCard(bool _alwaysRevealTopCard) { alwaysRevealTopCard = _alwaysRevealTopCard; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -760,6 +760,17 @@ void MessageLogWidget::logRevealCards(Player *player, CardZone *zone, int cardId
|
|||
}
|
||||
}
|
||||
|
||||
void MessageLogWidget::logAlwaysRevealTopCard(Player *player, CardZone *zone, bool reveal)
|
||||
{
|
||||
QString str;
|
||||
if (reveal)
|
||||
str = tr("%1 is now keeping the top card %2 revealed.");
|
||||
else
|
||||
str = tr("%1 is not revealing the top card %2 any longer.");
|
||||
|
||||
appendHtml(str.arg(sanitizeHtml(player->getName())).arg(zone->getTranslatedName(true, CaseGenitive)));
|
||||
}
|
||||
|
||||
void MessageLogWidget::logSetActivePlayer(Player *player)
|
||||
{
|
||||
soundEngine->notification();
|
||||
|
|
@ -844,6 +855,7 @@ void MessageLogWidget::connectToPlayer(Player *player)
|
|||
connect(player, SIGNAL(logDrawCards(Player *, int)), this, SLOT(logDrawCards(Player *, int)));
|
||||
connect(player, SIGNAL(logUndoDraw(Player *, QString)), this, SLOT(logUndoDraw(Player *, QString)));
|
||||
connect(player, SIGNAL(logRevealCards(Player *, CardZone *, int, QString, Player *, bool)), this, SLOT(logRevealCards(Player *, CardZone *, int, QString, Player *, bool)));
|
||||
connect(player, SIGNAL(logAlwaysRevealTopCard(Player *, CardZone *, bool)), this, SLOT(logAlwaysRevealTopCard(Player *, CardZone *, bool)));
|
||||
}
|
||||
|
||||
MessageLogWidget::MessageLogWidget(const QString &_ownName, bool _female, QWidget *parent)
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ public slots:
|
|||
void logDumpZone(Player *player, CardZone *zone, int numberCards);
|
||||
void logStopDumpZone(Player *player, CardZone *zone);
|
||||
void logRevealCards(Player *player, CardZone *zone, int cardId, QString cardName, Player *otherPlayer, bool faceDown);
|
||||
void logAlwaysRevealTopCard(Player *player, CardZone *zone, bool reveal);
|
||||
void logSetActivePlayer(Player *player);
|
||||
void logSetActivePhase(int phase);
|
||||
void containerProcessingStarted(const GameEventContext &context);
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include <QMenu>
|
||||
#include <QDebug>
|
||||
|
||||
#include "pb/command_change_zone_properties.pb.h"
|
||||
#include "pb/command_reveal_cards.pb.h"
|
||||
#include "pb/command_shuffle.pb.h"
|
||||
#include "pb/command_attach_card.pb.h"
|
||||
|
|
@ -60,6 +61,7 @@
|
|||
#include "pb/event_attach_card.pb.h"
|
||||
#include "pb/event_draw_cards.pb.h"
|
||||
#include "pb/event_reveal_cards.pb.h"
|
||||
#include "pb/event_change_zone_properties.pb.h"
|
||||
|
||||
PlayerArea::PlayerArea(QGraphicsItem *parentItem)
|
||||
: QObject(), QGraphicsItem(parentItem)
|
||||
|
|
@ -186,6 +188,9 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_pare
|
|||
connect(aViewLibrary, SIGNAL(triggered()), this, SLOT(actViewLibrary()));
|
||||
aViewTopCards = new QAction(this);
|
||||
connect(aViewTopCards, SIGNAL(triggered()), this, SLOT(actViewTopCards()));
|
||||
aAlwaysRevealTopCard = new QAction(this);
|
||||
aAlwaysRevealTopCard->setCheckable(true);
|
||||
connect(aAlwaysRevealTopCard, SIGNAL(triggered()), this, SLOT(actAlwaysRevealTopCard()));
|
||||
}
|
||||
|
||||
aViewGraveyard = new QAction(this);
|
||||
|
|
@ -242,6 +247,7 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_pare
|
|||
libraryMenu->addSeparator();
|
||||
playerLists.append(mRevealLibrary = libraryMenu->addMenu(QString()));
|
||||
playerLists.append(mRevealTopCard = libraryMenu->addMenu(QString()));
|
||||
libraryMenu->addAction(aAlwaysRevealTopCard);
|
||||
libraryMenu->addSeparator();
|
||||
libraryMenu->addAction(aMoveTopCardsToGrave);
|
||||
libraryMenu->addAction(aMoveTopCardsToExile);
|
||||
|
|
@ -571,6 +577,7 @@ void Player::retranslateUi()
|
|||
aViewTopCards->setText(tr("View &top cards of library..."));
|
||||
mRevealLibrary->setTitle(tr("Reveal &library to"));
|
||||
mRevealTopCard->setTitle(tr("Reveal t&op card to"));
|
||||
aAlwaysRevealTopCard->setText(tr("&Always reveal top card"));
|
||||
aViewSideboard->setText(tr("&View sideboard"));
|
||||
aDrawCard->setText(tr("&Draw card"));
|
||||
aDrawCards->setText(tr("D&raw cards..."));
|
||||
|
|
@ -731,6 +738,15 @@ void Player::actViewTopCards()
|
|||
}
|
||||
}
|
||||
|
||||
void Player::actAlwaysRevealTopCard()
|
||||
{
|
||||
Command_ChangeZoneProperties cmd;
|
||||
cmd.set_zone_name("deck");
|
||||
cmd.set_always_reveal_top_card(aAlwaysRevealTopCard->isChecked());
|
||||
|
||||
sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
void Player::actViewGraveyard()
|
||||
{
|
||||
static_cast<GameScene *>(scene())->toggleZoneView(this, "grave", -1);
|
||||
|
|
@ -1291,6 +1307,18 @@ void Player::eventRevealCards(const Event_RevealCards &event)
|
|||
}
|
||||
}
|
||||
|
||||
void Player::eventChangeZoneProperties(const Event_ChangeZoneProperties &event)
|
||||
{
|
||||
CardZone *zone = zones.value(QString::fromStdString(event.zone_name()));
|
||||
if (!zone)
|
||||
return;
|
||||
|
||||
if (event.has_always_reveal_top_card()) {
|
||||
zone->setAlwaysRevealTopCard(event.always_reveal_top_card());
|
||||
emit logAlwaysRevealTopCard(this, zone, event.always_reveal_top_card());
|
||||
}
|
||||
}
|
||||
|
||||
void Player::processGameEvent(GameEvent::GameEventType type, const GameEvent &event, const GameEventContext &context)
|
||||
{
|
||||
switch (type) {
|
||||
|
|
@ -1313,6 +1341,7 @@ void Player::processGameEvent(GameEvent::GameEventType type, const GameEvent &ev
|
|||
case GameEvent::ATTACH_CARD: eventAttachCard(event.GetExtension(Event_AttachCard::ext)); break;
|
||||
case GameEvent::DRAW_CARDS: eventDrawCards(event.GetExtension(Event_DrawCards::ext)); break;
|
||||
case GameEvent::REVEAL_CARDS: eventRevealCards(event.GetExtension(Event_RevealCards::ext)); break;
|
||||
case GameEvent::CHANGE_ZONE_PROPERTIES: eventChangeZoneProperties(event.GetExtension(Event_ChangeZoneProperties::ext)); break;
|
||||
default: {
|
||||
qDebug() << "unhandled game event";
|
||||
}
|
||||
|
|
@ -1363,6 +1392,9 @@ void Player::processPlayerInfo(const ServerInfo_Player &info)
|
|||
zone->addCard(card, false, cardInfo.x(), cardInfo.y());
|
||||
}
|
||||
}
|
||||
if (zoneInfo.has_always_reveal_top_card())
|
||||
zone->setAlwaysRevealTopCard(zoneInfo.always_reveal_top_card());
|
||||
|
||||
zone->reorganizeCards();
|
||||
}
|
||||
|
||||
|
|
@ -1370,10 +1402,6 @@ void Player::processPlayerInfo(const ServerInfo_Player &info)
|
|||
for (int i = 0; i < counterListSize; ++i)
|
||||
addCounter(info.counter_list(i));
|
||||
|
||||
const int arrowListSize = info.arrow_list_size();
|
||||
for (int i = 0; i < arrowListSize; ++i)
|
||||
addArrow(info.arrow_list(i));
|
||||
|
||||
setConceded(info.properties().conceded());
|
||||
}
|
||||
|
||||
|
|
@ -1399,6 +1427,10 @@ void Player::processCardAttachment(const ServerInfo_Player &info)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
const int arrowListSize = info.arrow_list_size();
|
||||
for (int i = 0; i < arrowListSize; ++i)
|
||||
addArrow(info.arrow_list(i));
|
||||
}
|
||||
|
||||
void Player::playCard(CardItem *c, bool faceDown, bool tapped)
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ class Event_DestroyCard;
|
|||
class Event_AttachCard;
|
||||
class Event_DrawCards;
|
||||
class Event_RevealCards;
|
||||
class Event_ChangeZoneProperties;
|
||||
class PendingCommand;
|
||||
|
||||
class PlayerArea : public QObject, public QGraphicsItem {
|
||||
|
|
@ -98,6 +99,7 @@ signals:
|
|||
void logDumpZone(Player *player, CardZone *zone, int numberCards);
|
||||
void logStopDumpZone(Player *player, CardZone *zone);
|
||||
void logRevealCards(Player *player, CardZone *zone, int cardId, QString cardName, Player *otherPlayer, bool faceDown);
|
||||
void logAlwaysRevealTopCard(Player *player, CardZone *zone, bool reveal);
|
||||
|
||||
void sizeChanged();
|
||||
void gameConceded();
|
||||
|
|
@ -117,6 +119,7 @@ public slots:
|
|||
|
||||
void actViewLibrary();
|
||||
void actViewTopCards();
|
||||
void actAlwaysRevealTopCard();
|
||||
void actViewGraveyard();
|
||||
void actViewRfg();
|
||||
void actViewSideboard();
|
||||
|
|
@ -156,7 +159,7 @@ private:
|
|||
QAction *aMoveHandToTopLibrary, *aMoveHandToBottomLibrary, *aMoveHandToGrave, *aMoveHandToRfg,
|
||||
*aMoveGraveToTopLibrary, *aMoveGraveToBottomLibrary, *aMoveGraveToHand, *aMoveGraveToRfg,
|
||||
*aMoveRfgToTopLibrary, *aMoveRfgToBottomLibrary, *aMoveRfgToHand, *aMoveRfgToGrave,
|
||||
*aViewLibrary, *aViewTopCards, *aMoveTopCardsToGrave, *aMoveTopCardsToExile, *aMoveTopCardToBottom,
|
||||
*aViewLibrary, *aViewTopCards, *aAlwaysRevealTopCard, *aMoveTopCardsToGrave, *aMoveTopCardsToExile, *aMoveTopCardToBottom,
|
||||
*aViewGraveyard, *aViewRfg, *aViewSideboard,
|
||||
*aDrawCard, *aDrawCards, *aUndoDraw, *aMulligan, *aShuffle,
|
||||
*aUntapAll, *aRollDie, *aCreateToken, *aCreateAnotherToken,
|
||||
|
|
@ -221,6 +224,7 @@ private:
|
|||
void eventAttachCard(const Event_AttachCard &event);
|
||||
void eventDrawCards(const Event_DrawCards &event);
|
||||
void eventRevealCards(const Event_RevealCards &event);
|
||||
void eventChangeZoneProperties(const Event_ChangeZoneProperties &event);
|
||||
public:
|
||||
static const int counterAreaWidth = 55;
|
||||
enum CardMenuActionType { cmTap, cmUntap, cmDoesntUntap, cmFlip, cmPeek, cmClone, cmMoveToTopLibrary, cmMoveToBottomLibrary, cmMoveToGraveyard, cmMoveToExile };
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
#include "userlist.h"
|
||||
#include "userinfobox.h"
|
||||
#include "abstractclient.h"
|
||||
#include <QDebug>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
|
|
@ -107,7 +106,6 @@ void TabUserLists::processUserLeftEvent(const Event_UserLeft &event)
|
|||
|
||||
void TabUserLists::buddyListReceived(const QList<ServerInfo_User> &_buddyList)
|
||||
{
|
||||
qDebug() << "BUDDY LIST" << _buddyList.size();
|
||||
for (int i = 0; i < _buddyList.size(); ++i)
|
||||
buddyList->processUserInfo(_buddyList[i], false);
|
||||
buddyList->sortItems();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue