Merge branch 'master' into cmake_qt5

Conflicts:
	cockatrice/src/main.cpp
This commit is contained in:
Daenyth 2014-06-28 09:13:10 -04:00
commit 09d6d26fb2
22 changed files with 156 additions and 93 deletions

View file

@ -180,6 +180,7 @@ bool InnerDecklistNode::compare(AbstractDecklistNode *other) const
case 2:
return comparePrice(other);
}
return 0;
}
bool InnerDecklistNode::compareNumber(AbstractDecklistNode *other) const
@ -226,6 +227,7 @@ bool AbstractDecklistCardNode::compare(AbstractDecklistNode *other) const
case ByPrice:
return compareTotalPrice(other);
}
return 0;
}
bool AbstractDecklistCardNode::compareNumber(AbstractDecklistNode *other) const
@ -351,6 +353,7 @@ DeckList::DeckList()
root = new InnerDecklistNode;
}
// TODO: http://qt-project.org/doc/qt-4.8/qobject.html#no-copy-constructor-or-assignment-operator
DeckList::DeckList(const DeckList &other)
: name(other.name),
comments(other.comments),
@ -630,12 +633,27 @@ QStringList DeckList::getCardList() const
return result.toList();
}
int DeckList::getSideboardSize() const
{
int size = 0;
for (int i = 0; i < root->size(); ++i) {
InnerDecklistNode *node = dynamic_cast<InnerDecklistNode *>(root->at(i));
if (node->getName() != "side")
continue;
for (int j = 0; j < node->size(); j++) {
DecklistCardNode *card = dynamic_cast<DecklistCardNode *>(node->at(j));
size += card->getNumber();
}
}
return size;
}
DecklistCardNode *DeckList::addCard(const QString &cardName, const QString &zoneName)
{
InnerDecklistNode *zoneNode = dynamic_cast<InnerDecklistNode *>(root->findChild(zoneName));
if (!zoneNode)
zoneNode = new InnerDecklistNode(zoneName, root);
DecklistCardNode *node = new DecklistCardNode(cardName, 1, zoneNode);
updateDeckHash();
return node;

View file

@ -160,7 +160,9 @@ public:
void cleanList();
bool isEmpty() const { return root->isEmpty() && name.isEmpty() && comments.isEmpty() && sideboardPlans.isEmpty(); }
QStringList getCardList() const;
int getSideboardSize() const;
QString getDeckHash() const { return deckHash; }
void updateDeckHash();

View file

@ -1,8 +1,9 @@
import "game_event_context.proto";
message Context_DeckSelect {
extend GameEventContext {
optional Context_DeckSelect ext = 1002;
}
optional string deck_hash = 1;
extend GameEventContext {
optional Context_DeckSelect ext = 1002;
}
optional string deck_hash = 1;
optional int32 sideboard_size = 2 [default = -1];
}

View file

@ -657,6 +657,7 @@ Response::ResponseCode Server_Player::cmdDeckSelect(const Command_DeckSelect &cm
Context_DeckSelect context;
context.set_deck_hash(deck->getDeckHash().toStdString());
context.set_sideboard_size(deck->getSideboardSize());
ges.setGameEventContext(context);
Response_DeckDownload *re = new Response_DeckDownload;

View file

@ -64,7 +64,7 @@ void GameEventStorage::sendToGame(Server_Game *game)
}
ResponseContainer::ResponseContainer(int _cmdId)
: responseExtension(0), cmdId(_cmdId)
: cmdId(_cmdId), responseExtension(0)
{
}