don't allow players to move cards that are attached to something

This commit is contained in:
Max-Wilhelm Bruker 2013-02-03 18:23:54 +01:00
parent 1f6fbfddb3
commit 9f13254d01

View file

@ -353,15 +353,21 @@ Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges, Server_Car
continue; continue;
cardIdsToMove.insert(_cards[i]->card_id()); cardIdsToMove.insert(_cards[i]->card_id());
// Consistency checks. In case the command contains illegal moves, try to resolve the legal ones still.
int position; int position;
Server_Card *card = startzone->getCard(_cards[i]->card_id(), &position); Server_Card *card = startzone->getCard(_cards[i]->card_id(), &position);
if (!card) if (!card)
return Response::RespNameNotFound; return Response::RespNameNotFound;
if (card->getParentCard())
continue;
if (!card->getAttachedCards().isEmpty() && !targetzone->isColumnEmpty(x, y)) if (!card->getAttachedCards().isEmpty() && !targetzone->isColumnEmpty(x, y))
return Response::RespContextError; continue;
cardsToMove.append(QPair<Server_Card *, int>(card, position)); cardsToMove.append(QPair<Server_Card *, int>(card, position));
cardProperties.insert(card, _cards[i]); cardProperties.insert(card, _cards[i]);
} }
// In case all moves were filtered out, abort.
if (cardsToMove.isEmpty())
return Response::RespContextError;
MoveCardCompareFunctor cmp(startzone == targetzone ? -1 : x); MoveCardCompareFunctor cmp(startzone == targetzone ? -1 : x);
qSort(cardsToMove.begin(), cardsToMove.end(), cmp); qSort(cardsToMove.begin(), cardsToMove.end(), cmp);