mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-13 01:24:46 -07:00
parent
c0bd7db658
commit
4c2a553f03
7 changed files with 38 additions and 12 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue