Have servatrice inform players of sideboard size

Ref #142
This commit is contained in:
Daenyth 2014-06-28 00:36:08 -04:00
parent c0bd7db658
commit 4c2a553f03
7 changed files with 38 additions and 12 deletions

View file

@ -633,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;