Have various game events respect the new UUID attribute on instantiation.

This commit is contained in:
Lukas Brübach 2024-11-07 08:47:04 +01:00
parent 90c4b223dd
commit c9690d790c
12 changed files with 58 additions and 26 deletions

View file

@ -155,6 +155,16 @@ AbstractDecklistNode *InnerDecklistNode::findChild(const QString &_name)
return nullptr;
}
AbstractDecklistNode *InnerDecklistNode::findChild(const QString &_name, const QString &_uuid)
{
for (int i = 0; i < size(); i++) {
if (at(i)->getName() == _name && at(i)->getCardUuid() == _uuid) {
return at(i);
}
}
return nullptr;
}
int InnerDecklistNode::height() const
{
return at(0)->height() + 1;

View file

@ -128,6 +128,7 @@ public:
void clearTree();
AbstractDecklistNode *findChild(const QString &_name);
AbstractDecklistNode *findChild(const QString &_name, const QString &_uuid);
int height() const override;
int recursiveCount(bool countTotalCards = false) const;
bool compare(AbstractDecklistNode *other) const override;

View file

@ -130,6 +130,7 @@ void Server_Card::getInfo(ServerInfo_Card *info)
QString displayedName = facedown ? QString() : name;
info->set_id(id);
info->set_uuid(uuid.toStdString());
info->set_name(displayedName.toStdString());
info->set_x(coord_x);
info->set_y(coord_y);

View file

@ -209,7 +209,8 @@ void Server_Player::setupZones()
continue;
}
for (int k = 0; k < currentCard->getNumber(); ++k) {
z->insertCard(new Server_Card(currentCard->getName(), nextCardId++, 0, 0, z), -1, 0);
z->insertCard(
new Server_Card(currentCard->getName(), currentCard->getCardUuid(), nextCardId++, 0, 0, z), -1, 0);
}
}
}
@ -338,6 +339,7 @@ Response::ResponseCode Server_Player::drawCards(GameEventStorage &ges, int numbe
ServerInfo_Card *cardInfo = eventPrivate.add_cards();
cardInfo->set_id(card->getId());
cardInfo->set_name(card->getName().toStdString());
cardInfo->set_uuid(card->getUUID().toStdString());
}
ges.enqueueGameEvent(eventPrivate, playerId, GameEventStorageItem::SendToPrivate, playerId);
@ -1406,7 +1408,7 @@ Server_Player::cmdCreateToken(const Command_CreateToken &cmd, ResponseContainer
yCoord = 0;
}
auto *card = new Server_Card(cardName, newCardId(), xCoord, yCoord);
auto *card = new Server_Card(cardName, QString(), newCardId(), xCoord, yCoord);
card->moveToThread(thread());
card->setPT(nameFromStdString(cmd.pt()));
card->setColor(nameFromStdString(cmd.color()));
@ -1941,6 +1943,7 @@ Server_Player::cmdDumpZone(const Command_DumpZone &cmd, ResponseContainer &rc, G
Server_Card *card = cards[i];
QString displayedName = card->getFaceDown() ? QString() : card->getName();
ServerInfo_Card *cardInfo = zoneInfo->add_card_list();
cardInfo->set_uuid(card->getUUID().toStdString());
cardInfo->set_name(displayedName.toStdString());
if (zone->getType() == ServerInfo_Zone::HiddenZone) {
cardInfo->set_id(i);
@ -2058,6 +2061,7 @@ Server_Player::cmdRevealCards(const Command_RevealCards &cmd, ResponseContainer
ServerInfo_Card *cardInfo = eventPrivate.add_cards();
cardInfo->set_id(card->getId());
cardInfo->set_uuid(card->getUUID().toStdString());
cardInfo->set_name(card->getName().toStdString());
cardInfo->set_x(card->getX());
cardInfo->set_y(card->getY());