mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-15 19:47:46 -07:00
added deck hashing
This commit is contained in:
parent
963e8f0d90
commit
0bb4ef8bb8
31 changed files with 4867 additions and 4831 deletions
|
|
@ -72,6 +72,7 @@
|
||||||
<file>resources/countries/fi.svg</file>
|
<file>resources/countries/fi.svg</file>
|
||||||
<file>resources/countries/fr.svg</file>
|
<file>resources/countries/fr.svg</file>
|
||||||
<file>resources/countries/gr.svg</file>
|
<file>resources/countries/gr.svg</file>
|
||||||
|
<file>resources/countries/gt.svg</file>
|
||||||
<file>resources/countries/hu.svg</file>
|
<file>resources/countries/hu.svg</file>
|
||||||
<file>resources/countries/ie.svg</file>
|
<file>resources/countries/ie.svg</file>
|
||||||
<file>resources/countries/il.svg</file>
|
<file>resources/countries/il.svg</file>
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ DeckListModel::DeckListModel(QObject *parent)
|
||||||
{
|
{
|
||||||
deckList = new DeckList;
|
deckList = new DeckList;
|
||||||
connect(deckList, SIGNAL(deckLoaded()), this, SLOT(rebuildTree()));
|
connect(deckList, SIGNAL(deckLoaded()), this, SLOT(rebuildTree()));
|
||||||
|
connect(deckList, SIGNAL(deckHashChanged()), this, SIGNAL(deckHashChanged()));
|
||||||
root = new InnerDecklistNode;
|
root = new InnerDecklistNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -194,6 +195,7 @@ bool DeckListModel::setData(const QModelIndex &index, const QVariant &value, int
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
emitRecursiveUpdates(index);
|
emitRecursiveUpdates(index);
|
||||||
|
deckList->updateDeckHash();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -310,6 +312,8 @@ void DeckListModel::setDeckList(DeckList *_deck)
|
||||||
{
|
{
|
||||||
delete deckList;
|
delete deckList;
|
||||||
deckList = _deck;
|
deckList = _deck;
|
||||||
|
connect(deckList, SIGNAL(deckLoaded()), this, SLOT(rebuildTree()));
|
||||||
|
connect(deckList, SIGNAL(deckHashChanged()), this, SIGNAL(deckHashChanged()));
|
||||||
rebuildTree();
|
rebuildTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@ private slots:
|
||||||
void rebuildTree();
|
void rebuildTree();
|
||||||
public slots:
|
public slots:
|
||||||
void printDeckList(QPrinter *printer);
|
void printDeckList(QPrinter *printer);
|
||||||
|
signals:
|
||||||
|
void deckHashChanged();
|
||||||
public:
|
public:
|
||||||
DeckListModel(QObject *parent = 0);
|
DeckListModel(QObject *parent = 0);
|
||||||
~DeckListModel();
|
~DeckListModel();
|
||||||
|
|
|
||||||
|
|
@ -58,19 +58,12 @@ void MessageLogWidget::logLeaveSpectator(QString name)
|
||||||
appendHtml(tr("%1 is not watching the game any more.").arg(sanitizeHtml(name)));
|
appendHtml(tr("%1 is not watching the game any more.").arg(sanitizeHtml(name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageLogWidget::logDeckSelect(Player *player, int deckId)
|
void MessageLogWidget::logDeckSelect(Player *player, QString deckHash)
|
||||||
{
|
{
|
||||||
if (deckId == -1) {
|
if (isFemale(player))
|
||||||
if (isFemale(player))
|
appendHtml(tr("%1 has loaded a deck (%2).", "female").arg(sanitizeHtml(player->getName())).arg(deckHash));
|
||||||
appendHtml(tr("%1 has loaded a local deck.", "female").arg(sanitizeHtml(player->getName())));
|
else
|
||||||
else
|
appendHtml(tr("%1 has loaded a deck (%2).", "male").arg(sanitizeHtml(player->getName())).arg(deckHash));
|
||||||
appendHtml(tr("%1 has loaded a local deck.", "male").arg(sanitizeHtml(player->getName())));
|
|
||||||
} else {
|
|
||||||
if (isFemale(player))
|
|
||||||
appendHtml(tr("%1 has loaded deck #%2.", "female").arg(sanitizeHtml(player->getName())).arg(deckId));
|
|
||||||
else
|
|
||||||
appendHtml(tr("%1 has loaded deck #%2.", "male").arg(sanitizeHtml(player->getName())).arg(deckId));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageLogWidget::logReadyStart(Player *player)
|
void MessageLogWidget::logReadyStart(Player *player)
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ public slots:
|
||||||
void logGameClosed();
|
void logGameClosed();
|
||||||
void logJoinSpectator(QString name);
|
void logJoinSpectator(QString name);
|
||||||
void logLeaveSpectator(QString name);
|
void logLeaveSpectator(QString name);
|
||||||
void logDeckSelect(Player *player, int deckId);
|
void logDeckSelect(Player *player, QString deckHash);
|
||||||
void logReadyStart(Player *player);
|
void logReadyStart(Player *player);
|
||||||
void logNotReadyStart(Player *player);
|
void logNotReadyStart(Player *player);
|
||||||
void logConcede(Player *player);
|
void logConcede(Player *player);
|
||||||
|
|
|
||||||
|
|
@ -98,15 +98,7 @@ void PlayerListWidget::updatePlayerProperties(ServerInfo_PlayerProperties *prop)
|
||||||
player->setIcon(4, QIcon(CountryPixmapGenerator::generatePixmap(12, prop->getUserInfo()->getCountry())));
|
player->setIcon(4, QIcon(CountryPixmapGenerator::generatePixmap(12, prop->getUserInfo()->getCountry())));
|
||||||
player->setData(4, Qt::UserRole, prop->getUserInfo()->getName());
|
player->setData(4, Qt::UserRole, prop->getUserInfo()->getName());
|
||||||
player->setData(4, Qt::UserRole + 1, prop->getPlayerId());
|
player->setData(4, Qt::UserRole + 1, prop->getPlayerId());
|
||||||
|
player->setText(5, prop->getDeckHash());
|
||||||
QString deckText;
|
|
||||||
if (!prop->getSpectator())
|
|
||||||
switch (prop->getDeckId()) {
|
|
||||||
case -2: deckText = QString(); break;
|
|
||||||
case -1: deckText = tr("local deck"); break;
|
|
||||||
default: deckText = tr("deck #%1").arg(prop->getDeckId());
|
|
||||||
}
|
|
||||||
player->setText(5, deckText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerListWidget::removePlayer(int playerId)
|
void PlayerListWidget::removePlayer(int playerId)
|
||||||
|
|
|
||||||
|
|
@ -620,7 +620,7 @@ void TabGame::eventPlayerPropertiesChanged(Event_PlayerPropertiesChanged *event,
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ItemId_Context_DeckSelect: messageLog->logDeckSelect(player, static_cast<Context_DeckSelect *>(context)->getDeckId()); break;
|
case ItemId_Context_DeckSelect: messageLog->logDeckSelect(player, static_cast<Context_DeckSelect *>(context)->getDeckHash()); break;
|
||||||
default: ;
|
default: ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,7 @@ WndDeckEditor::WndDeckEditor(QWidget *parent)
|
||||||
middleFrame->addLayout(verticalToolBarLayout);
|
middleFrame->addLayout(verticalToolBarLayout);
|
||||||
|
|
||||||
deckModel = new DeckListModel(this);
|
deckModel = new DeckListModel(this);
|
||||||
|
connect(deckModel, SIGNAL(deckHashChanged()), this, SLOT(updateHash()));
|
||||||
deckView = new QTreeView();
|
deckView = new QTreeView();
|
||||||
deckView->setModel(deckModel);
|
deckView->setModel(deckModel);
|
||||||
deckView->setUniformRowHeights(true);
|
deckView->setUniformRowHeights(true);
|
||||||
|
|
@ -114,6 +115,8 @@ WndDeckEditor::WndDeckEditor(QWidget *parent)
|
||||||
commentsEdit->setMaximumHeight(70);
|
commentsEdit->setMaximumHeight(70);
|
||||||
commentsLabel->setBuddy(commentsEdit);
|
commentsLabel->setBuddy(commentsEdit);
|
||||||
connect(commentsEdit, SIGNAL(textChanged()), this, SLOT(updateComments()));
|
connect(commentsEdit, SIGNAL(textChanged()), this, SLOT(updateComments()));
|
||||||
|
QLabel *hashLabel1 = new QLabel(tr("Hash:"));
|
||||||
|
hashLabel = new QLabel;
|
||||||
|
|
||||||
QGridLayout *grid = new QGridLayout;
|
QGridLayout *grid = new QGridLayout;
|
||||||
grid->addWidget(nameLabel, 0, 0);
|
grid->addWidget(nameLabel, 0, 0);
|
||||||
|
|
@ -122,6 +125,9 @@ WndDeckEditor::WndDeckEditor(QWidget *parent)
|
||||||
grid->addWidget(commentsLabel, 1, 0);
|
grid->addWidget(commentsLabel, 1, 0);
|
||||||
grid->addWidget(commentsEdit, 1, 1);
|
grid->addWidget(commentsEdit, 1, 1);
|
||||||
|
|
||||||
|
grid->addWidget(hashLabel1, 2, 0);
|
||||||
|
grid->addWidget(hashLabel, 2, 1);
|
||||||
|
|
||||||
// Update price
|
// Update price
|
||||||
aUpdatePrices = new QAction(tr("&Update prices"), this);
|
aUpdatePrices = new QAction(tr("&Update prices"), this);
|
||||||
aUpdatePrices->setShortcut(tr("Ctrl+U"));
|
aUpdatePrices->setShortcut(tr("Ctrl+U"));
|
||||||
|
|
@ -140,10 +146,9 @@ WndDeckEditor::WndDeckEditor(QWidget *parent)
|
||||||
deckToolbarLayout->addWidget(deckToolBar);
|
deckToolbarLayout->addWidget(deckToolBar);
|
||||||
deckToolbarLayout->addStretch();
|
deckToolbarLayout->addStretch();
|
||||||
|
|
||||||
|
|
||||||
QVBoxLayout *rightFrame = new QVBoxLayout;
|
QVBoxLayout *rightFrame = new QVBoxLayout;
|
||||||
rightFrame->addLayout(grid);
|
rightFrame->addLayout(grid);
|
||||||
rightFrame->addWidget(deckView);
|
rightFrame->addWidget(deckView, 10);
|
||||||
rightFrame->addLayout(deckToolbarLayout);
|
rightFrame->addLayout(deckToolbarLayout);
|
||||||
|
|
||||||
QHBoxLayout *mainLayout = new QHBoxLayout;
|
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||||
|
|
@ -230,6 +235,7 @@ WndDeckEditor::WndDeckEditor(QWidget *parent)
|
||||||
verticalToolBar->addAction(aRemoveCard);
|
verticalToolBar->addAction(aRemoveCard);
|
||||||
verticalToolBar->addAction(aIncrement);
|
verticalToolBar->addAction(aIncrement);
|
||||||
verticalToolBar->addAction(aDecrement);
|
verticalToolBar->addAction(aDecrement);
|
||||||
|
verticalToolBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||||
|
|
||||||
dlgCardSearch = new DlgCardSearch(this);
|
dlgCardSearch = new DlgCardSearch(this);
|
||||||
|
|
||||||
|
|
@ -273,6 +279,11 @@ void WndDeckEditor::updateSearch(const QString &search)
|
||||||
databaseView->selectionModel()->setCurrentIndex(databaseDisplayModel->index(0, 0), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
|
databaseView->selectionModel()->setCurrentIndex(databaseDisplayModel->index(0, 0), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WndDeckEditor::updateHash()
|
||||||
|
{
|
||||||
|
hashLabel->setText(deckModel->getDeckList()->getDeckHash());
|
||||||
|
}
|
||||||
|
|
||||||
bool WndDeckEditor::confirmClose()
|
bool WndDeckEditor::confirmClose()
|
||||||
{
|
{
|
||||||
if (isWindowModified()) {
|
if (isWindowModified()) {
|
||||||
|
|
@ -305,6 +316,7 @@ void WndDeckEditor::actNewDeck()
|
||||||
nameEdit->setText(QString());
|
nameEdit->setText(QString());
|
||||||
commentsEdit->setText(QString());
|
commentsEdit->setText(QString());
|
||||||
lastFileName = QString();
|
lastFileName = QString();
|
||||||
|
setWindowModified(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WndDeckEditor::actLoadDeck()
|
void WndDeckEditor::actLoadDeck()
|
||||||
|
|
@ -506,6 +518,7 @@ void WndDeckEditor::setDeck(DeckList *_deck, const QString &_lastFileName, DeckL
|
||||||
lastFileFormat = _lastFileFormat;
|
lastFileFormat = _lastFileFormat;
|
||||||
nameEdit->setText(_deck->getName());
|
nameEdit->setText(_deck->getName());
|
||||||
commentsEdit->setText(_deck->getComments());
|
commentsEdit->setText(_deck->getComments());
|
||||||
|
updateHash();
|
||||||
deckModel->sort(1);
|
deckModel->sort(1);
|
||||||
deckView->expandAll();
|
deckView->expandAll();
|
||||||
setWindowModified(false);
|
setWindowModified(false);
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ class QTableView;
|
||||||
class CardInfoWidget;
|
class CardInfoWidget;
|
||||||
class QTextEdit;
|
class QTextEdit;
|
||||||
class DlgCardSearch;
|
class DlgCardSearch;
|
||||||
|
class QLabel;
|
||||||
|
|
||||||
class SearchLineEdit : public QLineEdit {
|
class SearchLineEdit : public QLineEdit {
|
||||||
private:
|
private:
|
||||||
|
|
@ -30,6 +31,7 @@ class WndDeckEditor : public QMainWindow {
|
||||||
private slots:
|
private slots:
|
||||||
void updateName(const QString &name);
|
void updateName(const QString &name);
|
||||||
void updateComments();
|
void updateComments();
|
||||||
|
void updateHash();
|
||||||
void updateCardInfoLeft(const QModelIndex ¤t, const QModelIndex &previous);
|
void updateCardInfoLeft(const QModelIndex ¤t, const QModelIndex &previous);
|
||||||
void updateCardInfoRight(const QModelIndex ¤t, const QModelIndex &previous);
|
void updateCardInfoRight(const QModelIndex ¤t, const QModelIndex &previous);
|
||||||
void updateSearch(const QString &search);
|
void updateSearch(const QString &search);
|
||||||
|
|
@ -72,6 +74,7 @@ private:
|
||||||
SearchLineEdit *searchEdit;
|
SearchLineEdit *searchEdit;
|
||||||
QLineEdit *nameEdit;
|
QLineEdit *nameEdit;
|
||||||
QTextEdit *commentsEdit;
|
QTextEdit *commentsEdit;
|
||||||
|
QLabel *hashLabel;
|
||||||
DlgCardSearch *dlgCardSearch;
|
DlgCardSearch *dlgCardSearch;
|
||||||
|
|
||||||
QMenu *deckMenu, *dbMenu;
|
QMenu *deckMenu, *dbMenu;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -3,6 +3,7 @@
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
#include <QXmlStreamWriter>
|
#include <QXmlStreamWriter>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
#include <QCryptographicHash>
|
||||||
#include "decklist.h"
|
#include "decklist.h"
|
||||||
|
|
||||||
MoveCardToZone::MoveCardToZone(const QString &_cardName, const QString &_startZone, const QString &_targetZone)
|
MoveCardToZone::MoveCardToZone(const QString &_cardName, const QString &_startZone, const QString &_targetZone)
|
||||||
|
|
@ -263,6 +264,7 @@ DeckList::DeckList(DeckList *other)
|
||||||
newMoveList.append(new MoveCardToZone(oldMoveList[i]));
|
newMoveList.append(new MoveCardToZone(oldMoveList[i]));
|
||||||
sideboardPlans.insert(spIterator.key(), new SideboardPlan(spIterator.key(), newMoveList));
|
sideboardPlans.insert(spIterator.key(), new SideboardPlan(spIterator.key(), newMoveList));
|
||||||
}
|
}
|
||||||
|
updateDeckHash();
|
||||||
}
|
}
|
||||||
|
|
||||||
DeckList::~DeckList()
|
DeckList::~DeckList()
|
||||||
|
|
@ -453,8 +455,10 @@ bool DeckList::loadFromFile(const QString &fileName, FileFormat fmt)
|
||||||
case PlainTextFormat: result = loadFromFile_Plain(&file); break;
|
case PlainTextFormat: result = loadFromFile_Plain(&file); break;
|
||||||
case CockatriceFormat: result = loadFromFile_Native(&file); break;
|
case CockatriceFormat: result = loadFromFile_Native(&file); break;
|
||||||
}
|
}
|
||||||
if (result)
|
if (result) {
|
||||||
|
updateDeckHash();
|
||||||
emit deckLoaded();
|
emit deckLoaded();
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -486,6 +490,7 @@ void DeckList::cleanList()
|
||||||
root->clearTree();
|
root->clearTree();
|
||||||
setName();
|
setName();
|
||||||
setComments();
|
setComments();
|
||||||
|
updateDeckHash();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeckList::getCardListHelper(InnerDecklistNode *item, QSet<QString> &result) const
|
void DeckList::getCardListHelper(InnerDecklistNode *item, QSet<QString> &result) const
|
||||||
|
|
@ -512,28 +517,55 @@ DecklistCardNode *DeckList::addCard(const QString &cardName, const QString &zone
|
||||||
if (!zoneNode)
|
if (!zoneNode)
|
||||||
zoneNode = new InnerDecklistNode(zoneName, root);
|
zoneNode = new InnerDecklistNode(zoneName, root);
|
||||||
|
|
||||||
return new DecklistCardNode(cardName, 1, zoneNode);
|
DecklistCardNode *node = new DecklistCardNode(cardName, 1, zoneNode);
|
||||||
|
updateDeckHash();
|
||||||
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeckList::deleteNode(AbstractDecklistNode *node, InnerDecklistNode *rootNode)
|
bool DeckList::deleteNode(AbstractDecklistNode *node, InnerDecklistNode *rootNode)
|
||||||
{
|
{
|
||||||
if (node == root)
|
if (node == root)
|
||||||
return true;
|
return true;
|
||||||
if (!rootNode)
|
bool updateHash = false;
|
||||||
|
if (!rootNode) {
|
||||||
rootNode = root;
|
rootNode = root;
|
||||||
|
updateHash = true;
|
||||||
|
}
|
||||||
|
|
||||||
int index = rootNode->indexOf(node);
|
int index = rootNode->indexOf(node);
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
delete rootNode->takeAt(index);
|
delete rootNode->takeAt(index);
|
||||||
if (!rootNode->size())
|
if (!rootNode->size())
|
||||||
deleteNode(rootNode, rootNode->getParent());
|
deleteNode(rootNode, rootNode->getParent());
|
||||||
|
if (updateHash)
|
||||||
|
updateDeckHash();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < rootNode->size(); i++) {
|
for (int i = 0; i < rootNode->size(); i++) {
|
||||||
InnerDecklistNode *inner = dynamic_cast<InnerDecklistNode *>(rootNode->at(i));
|
InnerDecklistNode *inner = dynamic_cast<InnerDecklistNode *>(rootNode->at(i));
|
||||||
if (inner)
|
if (inner)
|
||||||
if (deleteNode(node, inner))
|
if (deleteNode(node, inner)) {
|
||||||
|
if (updateHash)
|
||||||
|
updateDeckHash();
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeckList::updateDeckHash()
|
||||||
|
{
|
||||||
|
QStringList cardList;
|
||||||
|
for (int i = 0; i < root->size(); i++) {
|
||||||
|
InnerDecklistNode *node = dynamic_cast<InnerDecklistNode *>(root->at(i));
|
||||||
|
for (int j = 0; j < node->size(); j++) {
|
||||||
|
DecklistCardNode *card = dynamic_cast<DecklistCardNode *>(node->at(j));
|
||||||
|
for (int k = 0; k < card->getNumber(); ++k)
|
||||||
|
cardList.append((node->getName() == "side" ? "SB:" : "") + card->getName().toLower());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cardList.sort();
|
||||||
|
deckHash = QCryptographicHash::hash(cardList.join(";").toUtf8(), QCryptographicHash::Sha1).toBase64().left(10);
|
||||||
|
|
||||||
|
emit deckHashChanged();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ public:
|
||||||
private:
|
private:
|
||||||
QString name, comments;
|
QString name, comments;
|
||||||
QString lastFileName;
|
QString lastFileName;
|
||||||
|
QString deckHash;
|
||||||
FileFormat lastFileFormat;
|
FileFormat lastFileFormat;
|
||||||
QMap<QString, SideboardPlan *> sideboardPlans;
|
QMap<QString, SideboardPlan *> sideboardPlans;
|
||||||
InnerDecklistNode *root;
|
InnerDecklistNode *root;
|
||||||
|
|
@ -127,6 +128,7 @@ private:
|
||||||
void getCardListHelper(InnerDecklistNode *node, QSet<QString> &result) const;
|
void getCardListHelper(InnerDecklistNode *node, QSet<QString> &result) const;
|
||||||
signals:
|
signals:
|
||||||
void deckLoaded();
|
void deckLoaded();
|
||||||
|
void deckHashChanged();
|
||||||
public slots:
|
public slots:
|
||||||
void setName(const QString &_name = QString()) { name = _name; }
|
void setName(const QString &_name = QString()) { name = _name; }
|
||||||
void setComments(const QString &_comments = QString()) { comments = _comments; }
|
void setComments(const QString &_comments = QString()) { comments = _comments; }
|
||||||
|
|
@ -161,6 +163,9 @@ public:
|
||||||
bool isEmpty() const { return root->isEmpty() && name.isEmpty() && comments.isEmpty() && sideboardPlans.isEmpty(); }
|
bool isEmpty() const { return root->isEmpty() && name.isEmpty() && comments.isEmpty() && sideboardPlans.isEmpty(); }
|
||||||
QStringList getCardList() const;
|
QStringList getCardList() const;
|
||||||
|
|
||||||
|
QString getDeckHash() const { return deckHash; }
|
||||||
|
void updateDeckHash();
|
||||||
|
|
||||||
InnerDecklistNode *getRoot() const { return root; }
|
InnerDecklistNode *getRoot() const { return root; }
|
||||||
DecklistCardNode *addCard(const QString &cardName, const QString &zoneName);
|
DecklistCardNode *addCard(const QString &cardName, const QString &zoneName);
|
||||||
bool deleteNode(AbstractDecklistNode *node, InnerDecklistNode *rootNode = 0);
|
bool deleteNode(AbstractDecklistNode *node, InnerDecklistNode *rootNode = 0);
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,7 @@ ServerInfo_Arrow::ServerInfo_Arrow(int _id, int _startPlayerId, const QString &_
|
||||||
insertItem(new SerializableItem_Color("color", _color));
|
insertItem(new SerializableItem_Color("color", _color));
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerInfo_PlayerProperties::ServerInfo_PlayerProperties(int _playerId, ServerInfo_User *_userInfo, bool _spectator, bool _conceded, bool _readyStart, int _deckId)
|
ServerInfo_PlayerProperties::ServerInfo_PlayerProperties(int _playerId, ServerInfo_User *_userInfo, bool _spectator, bool _conceded, bool _readyStart, const QString &_deckHash)
|
||||||
: SerializableItem_Map("player_properties")
|
: SerializableItem_Map("player_properties")
|
||||||
{
|
{
|
||||||
insertItem(new SerializableItem_Int("player_id", _playerId));
|
insertItem(new SerializableItem_Int("player_id", _playerId));
|
||||||
|
|
@ -217,7 +217,7 @@ ServerInfo_PlayerProperties::ServerInfo_PlayerProperties(int _playerId, ServerIn
|
||||||
insertItem(new SerializableItem_Bool("spectator", _spectator));
|
insertItem(new SerializableItem_Bool("spectator", _spectator));
|
||||||
insertItem(new SerializableItem_Bool("conceded", _conceded));
|
insertItem(new SerializableItem_Bool("conceded", _conceded));
|
||||||
insertItem(new SerializableItem_Bool("ready_start", _readyStart));
|
insertItem(new SerializableItem_Bool("ready_start", _readyStart));
|
||||||
insertItem(new SerializableItem_Int("deck_id", _deckId));
|
insertItem(new SerializableItem_String("deck_hash", _deckHash));
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerInfo_Player::ServerInfo_Player(ServerInfo_PlayerProperties *_properties, DeckList *_deck, const QList<ServerInfo_Zone *> &_zoneList, const QList<ServerInfo_Counter *> &_counterList, const QList<ServerInfo_Arrow *> &_arrowList)
|
ServerInfo_Player::ServerInfo_Player(ServerInfo_PlayerProperties *_properties, DeckList *_deck, const QList<ServerInfo_Zone *> &_zoneList, const QList<ServerInfo_Counter *> &_counterList, const QList<ServerInfo_Arrow *> &_arrowList)
|
||||||
|
|
|
||||||
|
|
@ -189,14 +189,14 @@ public:
|
||||||
|
|
||||||
class ServerInfo_PlayerProperties : public SerializableItem_Map {
|
class ServerInfo_PlayerProperties : public SerializableItem_Map {
|
||||||
public:
|
public:
|
||||||
ServerInfo_PlayerProperties(int _playerId = -1, ServerInfo_User *_userInfo = 0, bool _spectator = false, bool _conceded = false, bool _readyStart = false, int _deckId = -1);
|
ServerInfo_PlayerProperties(int _playerId = -1, ServerInfo_User *_userInfo = 0, bool _spectator = false, bool _conceded = false, bool _readyStart = false, const QString &_deckHash = QString());
|
||||||
static SerializableItem *newItem() { return new ServerInfo_PlayerProperties; }
|
static SerializableItem *newItem() { return new ServerInfo_PlayerProperties; }
|
||||||
int getPlayerId() const { return static_cast<SerializableItem_Int *>(itemMap.value("player_id"))->getData(); }
|
int getPlayerId() const { return static_cast<SerializableItem_Int *>(itemMap.value("player_id"))->getData(); }
|
||||||
ServerInfo_User *getUserInfo() const { return static_cast<ServerInfo_User *>(itemMap.value("user")); }
|
ServerInfo_User *getUserInfo() const { return static_cast<ServerInfo_User *>(itemMap.value("user")); }
|
||||||
bool getSpectator() const { return static_cast<SerializableItem_Bool *>(itemMap.value("spectator"))->getData(); }
|
bool getSpectator() const { return static_cast<SerializableItem_Bool *>(itemMap.value("spectator"))->getData(); }
|
||||||
bool getConceded() const { return static_cast<SerializableItem_Bool *>(itemMap.value("conceded"))->getData(); }
|
bool getConceded() const { return static_cast<SerializableItem_Bool *>(itemMap.value("conceded"))->getData(); }
|
||||||
bool getReadyStart() const { return static_cast<SerializableItem_Bool *>(itemMap.value("ready_start"))->getData(); }
|
bool getReadyStart() const { return static_cast<SerializableItem_Bool *>(itemMap.value("ready_start"))->getData(); }
|
||||||
int getDeckId() const { return static_cast<SerializableItem_Int *>(itemMap.value("deck_id"))->getData(); }
|
QString getDeckHash() const { return static_cast<SerializableItem_String *>(itemMap.value("deck_hash"))->getData(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class ServerInfo_Player : public SerializableItem_Map {
|
class ServerInfo_Player : public SerializableItem_Map {
|
||||||
|
|
|
||||||
|
|
@ -461,10 +461,10 @@ Context_Concede::Context_Concede()
|
||||||
: GameEventContext("concede")
|
: GameEventContext("concede")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
Context_DeckSelect::Context_DeckSelect(int _deckId)
|
Context_DeckSelect::Context_DeckSelect(const QString &_deckHash)
|
||||||
: GameEventContext("deck_select")
|
: GameEventContext("deck_select")
|
||||||
{
|
{
|
||||||
insertItem(new SerializableItem_Int("deck_id", _deckId));
|
insertItem(new SerializableItem_String("deck_hash", _deckHash));
|
||||||
}
|
}
|
||||||
Context_UndoDraw::Context_UndoDraw()
|
Context_UndoDraw::Context_UndoDraw()
|
||||||
: GameEventContext("undo_draw")
|
: GameEventContext("undo_draw")
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@
|
||||||
5:room_say:s,player_name:s,message
|
5:room_say:s,player_name:s,message
|
||||||
6:ready_start
|
6:ready_start
|
||||||
6:concede
|
6:concede
|
||||||
6:deck_select:i,deck_id
|
6:deck_select:s,deck_hash
|
||||||
6:undo_draw
|
6:undo_draw
|
||||||
6:move_card
|
6:move_card
|
||||||
6:mulligan:i,number
|
6:mulligan:i,number
|
||||||
|
|
|
||||||
|
|
@ -697,8 +697,8 @@ public:
|
||||||
class Context_DeckSelect : public GameEventContext {
|
class Context_DeckSelect : public GameEventContext {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Context_DeckSelect(int _deckId = -1);
|
Context_DeckSelect(const QString &_deckHash = QString());
|
||||||
int getDeckId() const { return static_cast<SerializableItem_Int *>(itemMap.value("deck_id"))->getData(); };
|
QString getDeckHash() const { return static_cast<SerializableItem_String *>(itemMap.value("deck_hash"))->getData(); };
|
||||||
static SerializableItem *newItem() { return new Context_DeckSelect; }
|
static SerializableItem *newItem() { return new Context_DeckSelect; }
|
||||||
int getItemId() const { return ItemId_Context_DeckSelect; }
|
int getItemId() const { return ItemId_Context_DeckSelect; }
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
Server_Player::Server_Player(Server_Game *_game, int _playerId, ServerInfo_User *_userInfo, bool _spectator, Server_ProtocolHandler *_handler)
|
Server_Player::Server_Player(Server_Game *_game, int _playerId, ServerInfo_User *_userInfo, bool _spectator, Server_ProtocolHandler *_handler)
|
||||||
: game(_game), handler(_handler), userInfo(new ServerInfo_User(_userInfo)), deck(0), playerId(_playerId), spectator(_spectator), nextCardId(0), readyStart(false), conceded(false), deckId(-2)
|
: game(_game), handler(_handler), userInfo(new ServerInfo_User(_userInfo)), deck(0), playerId(_playerId), spectator(_spectator), nextCardId(0), readyStart(false), conceded(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -187,16 +187,15 @@ ServerInfo_PlayerProperties *Server_Player::getProperties()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&game->gameMutex);
|
QMutexLocker locker(&game->gameMutex);
|
||||||
|
|
||||||
return new ServerInfo_PlayerProperties(playerId, new ServerInfo_User(userInfo), spectator, conceded, readyStart, deckId);
|
return new ServerInfo_PlayerProperties(playerId, new ServerInfo_User(userInfo), spectator, conceded, readyStart, deck ? deck->getDeckHash() : QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server_Player::setDeck(DeckList *_deck, int _deckId)
|
void Server_Player::setDeck(DeckList *_deck)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&game->gameMutex);
|
QMutexLocker locker(&game->gameMutex);
|
||||||
|
|
||||||
delete deck;
|
delete deck;
|
||||||
deck = _deck;
|
deck = _deck;
|
||||||
deckId = _deckId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server_Player::addZone(Server_CardZone *zone)
|
void Server_Player::addZone(Server_CardZone *zone)
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ private:
|
||||||
int nextCardId;
|
int nextCardId;
|
||||||
bool readyStart;
|
bool readyStart;
|
||||||
bool conceded;
|
bool conceded;
|
||||||
int deckId;
|
|
||||||
public:
|
public:
|
||||||
Server_Player(Server_Game *_game, int _playerId, ServerInfo_User *_userInfo, bool _spectator, Server_ProtocolHandler *_handler);
|
Server_Player(Server_Game *_game, int _playerId, ServerInfo_User *_userInfo, bool _spectator, Server_ProtocolHandler *_handler);
|
||||||
~Server_Player();
|
~Server_Player();
|
||||||
|
|
@ -57,9 +56,8 @@ public:
|
||||||
bool getSpectator() const { return spectator; }
|
bool getSpectator() const { return spectator; }
|
||||||
bool getConceded() const { return conceded; }
|
bool getConceded() const { return conceded; }
|
||||||
void setConceded(bool _conceded) { conceded = _conceded; }
|
void setConceded(bool _conceded) { conceded = _conceded; }
|
||||||
int getDeckId() const { return deckId; }
|
|
||||||
ServerInfo_User *getUserInfo() const { return userInfo; }
|
ServerInfo_User *getUserInfo() const { return userInfo; }
|
||||||
void setDeck(DeckList *_deck, int _deckId);
|
void setDeck(DeckList *_deck);
|
||||||
DeckList *getDeck() const { return deck; }
|
DeckList *getDeck() const { return deck; }
|
||||||
Server_Game *getGame() const { return game; }
|
Server_Game *getGame() const { return game; }
|
||||||
const QMap<QString, Server_CardZone *> &getZones() const { return zones; }
|
const QMap<QString, Server_CardZone *> &getZones() const { return zones; }
|
||||||
|
|
|
||||||
|
|
@ -595,9 +595,9 @@ ResponseCode Server_ProtocolHandler::cmdDeckSelect(Command_DeckSelect *cmd, Comm
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player->setDeck(deck, cmd->getDeckId());
|
player->setDeck(deck);
|
||||||
|
|
||||||
game->sendGameEvent(new Event_PlayerPropertiesChanged(player->getPlayerId(), player->getProperties()), new Context_DeckSelect(cmd->getDeckId()));
|
game->sendGameEvent(new Event_PlayerPropertiesChanged(player->getPlayerId(), player->getProperties()), new Context_DeckSelect(deck->getDeckHash()));
|
||||||
|
|
||||||
cont->setResponse(new Response_DeckDownload(cont->getCmdId(), RespOk, new DeckList(deck)));
|
cont->setResponse(new Response_DeckDownload(cont->getCmdId(), RespOk, new DeckList(deck)));
|
||||||
return RespNothing;
|
return RespNothing;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue