This commit is contained in:
Fabio Bas 2017-04-25 18:58:01 +02:00
parent a46c7156dd
commit 0fd77346df
3 changed files with 8 additions and 7 deletions

View file

@ -729,6 +729,7 @@ void TabGame::processGameEventContainer(const GameEventContainer &cont, Abstract
const int eventListSize = cont.event_list_size(); const int eventListSize = cont.event_list_size();
for (int i = 0; i < eventListSize; ++i) { for (int i = 0; i < eventListSize; ++i) {
const GameEvent &event = cont.event_list(i); const GameEvent &event = cont.event_list(i);
qDebug() << "[REPLAY]" << QString::fromStdString(event.ShortDebugString());
const int playerId = event.player_id(); const int playerId = event.player_id();
const GameEvent::GameEventType eventType = static_cast<GameEvent::GameEventType>(getPbExtension(event)); const GameEvent::GameEventType eventType = static_cast<GameEvent::GameEventType>(getPbExtension(event));
if (spectators.contains(playerId)) { if (spectators.contains(playerId)) {

View file

@ -523,12 +523,12 @@ Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges, Server_Car
ges.enqueueGameEvent(eventPrivate, playerId, GameEventStorageItem::SendToPrivate, playerId); ges.enqueueGameEvent(eventPrivate, playerId, GameEventStorageItem::SendToPrivate, playerId);
ges.enqueueGameEvent(eventOthers, playerId, GameEventStorageItem::SendToOthers); ges.enqueueGameEvent(eventOthers, playerId, GameEventStorageItem::SendToOthers);
if (thisCardProperties->tapped()) if (thisCardProperties->tapped())
setCardAttrHelper(ges, targetzone->getName(), card->getId(), AttrTapped, "1"); setCardAttrHelper(ges, targetzone->getPlayer()->getPlayerId(), targetzone->getName(), card->getId(), AttrTapped, "1");
QString ptString = QString::fromStdString(thisCardProperties->pt()); QString ptString = QString::fromStdString(thisCardProperties->pt());
if (!ptString.isEmpty() && !faceDown) if (!ptString.isEmpty() && !faceDown)
setCardAttrHelper(ges, targetzone->getName(), card->getId(), AttrPT, ptString); setCardAttrHelper(ges, targetzone->getPlayer()->getPlayerId(), targetzone->getName(), card->getId(), AttrPT, ptString);
} }
if (startzone->getAlwaysRevealTopCard() && !startzone->getCards().isEmpty() && (originalPosition == 0)) { if (startzone->getAlwaysRevealTopCard() && !startzone->getCards().isEmpty() && (originalPosition == 0)) {
Event_RevealCards revealEvent; Event_RevealCards revealEvent;
@ -578,7 +578,7 @@ void Server_Player::unattachCard(GameEventStorage &ges, Server_Card *card)
parentCard->getZone()->updateCardCoordinates(parentCard, parentCard->getX(), parentCard->getY()); parentCard->getZone()->updateCardCoordinates(parentCard, parentCard->getX(), parentCard->getY());
} }
Response::ResponseCode Server_Player::setCardAttrHelper(GameEventStorage &ges, const QString &zoneName, int cardId, CardAttribute attribute, const QString &attrValue) Response::ResponseCode Server_Player::setCardAttrHelper(GameEventStorage &ges, int targetPlayerId, const QString &zoneName, int cardId, CardAttribute attribute, const QString &attrValue)
{ {
Server_CardZone *zone = getZones().value(zoneName); Server_CardZone *zone = getZones().value(zoneName);
if (!zone) if (!zone)
@ -609,7 +609,7 @@ Response::ResponseCode Server_Player::setCardAttrHelper(GameEventStorage &ges, c
event.set_card_id(cardId); event.set_card_id(cardId);
event.set_attribute(attribute); event.set_attribute(attribute);
event.set_attr_value(result.toStdString()); event.set_attr_value(result.toStdString());
ges.enqueueGameEvent(event, playerId); ges.enqueueGameEvent(event, targetPlayerId);
return Response::RespOk; return Response::RespOk;
} }
@ -1224,7 +1224,7 @@ Response::ResponseCode Server_Player::cmdSetCardAttr(const Command_SetCardAttr &
if (conceded) if (conceded)
return Response::RespContextError; return Response::RespContextError;
return setCardAttrHelper(ges, QString::fromStdString(cmd.zone()), cmd.card_id(), cmd.attribute(), QString::fromStdString(cmd.attr_value())); return setCardAttrHelper(ges, playerId, QString::fromStdString(cmd.zone()), cmd.card_id(), cmd.attribute(), QString::fromStdString(cmd.attr_value()));
} }
Response::ResponseCode Server_Player::cmdSetCardCounter(const Command_SetCardCounter &cmd, ResponseContainer & /*rc*/, GameEventStorage &ges) Response::ResponseCode Server_Player::cmdSetCardCounter(const Command_SetCardCounter &cmd, ResponseContainer & /*rc*/, GameEventStorage &ges)

View file

@ -121,7 +121,7 @@ public:
Response::ResponseCode drawCards(GameEventStorage &ges, int number); Response::ResponseCode drawCards(GameEventStorage &ges, int number);
Response::ResponseCode moveCard(GameEventStorage &ges, Server_CardZone *startzone, const QList<const CardToMove *> &_cards, Server_CardZone *targetzone, int x, int y, bool fixFreeSpaces = true, bool undoingDraw = false); Response::ResponseCode moveCard(GameEventStorage &ges, Server_CardZone *startzone, const QList<const CardToMove *> &_cards, Server_CardZone *targetzone, int x, int y, bool fixFreeSpaces = true, bool undoingDraw = false);
void unattachCard(GameEventStorage &ges, Server_Card *card); void unattachCard(GameEventStorage &ges, Server_Card *card);
Response::ResponseCode setCardAttrHelper(GameEventStorage &ges, const QString &zone, int cardId, CardAttribute attribute, const QString &attrValue); Response::ResponseCode setCardAttrHelper(GameEventStorage &ges, int targetPlayerId, const QString &zone, int cardId, CardAttribute attribute, const QString &attrValue);
Response::ResponseCode cmdLeaveGame(const Command_LeaveGame &cmd, ResponseContainer &rc, GameEventStorage &ges); Response::ResponseCode cmdLeaveGame(const Command_LeaveGame &cmd, ResponseContainer &rc, GameEventStorage &ges);
Response::ResponseCode cmdKickFromGame(const Command_KickFromGame &cmd, ResponseContainer &rc, GameEventStorage &ges); Response::ResponseCode cmdKickFromGame(const Command_KickFromGame &cmd, ResponseContainer &rc, GameEventStorage &ges);