From 4f798286afbcc6ac0c64daeed3e9610d2618f3e3 Mon Sep 17 00:00:00 2001 From: ZeldaZach Date: Fri, 27 Dec 2024 18:23:09 -0500 Subject: [PATCH] Establish Card Ownership Tag --- common/server_player.cpp | 17 +++++++++++++++-- common/server_player.h | 3 ++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/common/server_player.cpp b/common/server_player.cpp index 9b64428d8..389b09fc7 100644 --- a/common/server_player.cpp +++ b/common/server_player.cpp @@ -82,6 +82,7 @@ #include "trice_limits.h" #include +#include #include struct MoveCardStruct @@ -644,6 +645,17 @@ Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges, AttrPT, ptString); } + // If card is transferring to a different player, leave an annotation of who actually "owns" the card + const auto &priorAnnotation = card->getAnnotation(); + if (startzone->getPlayer() != targetzone->getPlayer() && !priorAnnotation.contains("Owner:")) { + const auto &ownerAnnotation = + "Owner: " + QString::fromStdString(startzone->getPlayer()->getUserInfo()->name()); + const auto &newAnnotation = + priorAnnotation.isEmpty() ? ownerAnnotation : ownerAnnotation + "\n\n" + priorAnnotation; + setCardAttrHelper(ges, targetzone->getPlayer()->getPlayerId(), targetzone->getName(), card->getId(), + AttrAnnotation, newAnnotation, card); + } + if (originalPosition == 0) { revealTopStart = true; } @@ -694,7 +706,8 @@ Response::ResponseCode Server_Player::setCardAttrHelper(GameEventStorage &ges, const QString &zoneName, int cardId, CardAttribute attribute, - const QString &attrValue) + const QString &attrValue, + Server_Card *unzonedCard) { Server_CardZone *zone = getZones().value(zoneName); if (!zone) { @@ -714,7 +727,7 @@ Response::ResponseCode Server_Player::setCardAttrHelper(GameEventStorage &ges, } } } else { - Server_Card *card = zone->getCard(cardId); + Server_Card *card = unzonedCard == nullptr ? zone->getCard(cardId) : unzonedCard; if (!card) { return Response::RespNameNotFound; } diff --git a/common/server_player.h b/common/server_player.h index e6b91f5e5..20cb2aea1 100644 --- a/common/server_player.h +++ b/common/server_player.h @@ -186,7 +186,8 @@ public: const QString &zone, int cardId, CardAttribute attribute, - const QString &attrValue); + const QString &attrValue, + Server_Card *unzonedCard = nullptr); Response::ResponseCode cmdLeaveGame(const Command_LeaveGame &cmd, ResponseContainer &rc, GameEventStorage &ges); Response::ResponseCode