complete server-side AlwaysRevealTopCard support, related to issue #31
This commit is contained in:
parent
005a4363d3
commit
840b577f42
2 changed files with 40 additions and 3 deletions
|
@ -13,7 +13,6 @@
|
||||||
ZoneViewZone::ZoneViewZone(Player *_p, CardZone *_origZone, int _numberCards, bool _revealZone, bool _writeableRevealZone, QGraphicsItem *parent)
|
ZoneViewZone::ZoneViewZone(Player *_p, CardZone *_origZone, int _numberCards, bool _revealZone, bool _writeableRevealZone, QGraphicsItem *parent)
|
||||||
: SelectZone(_p, _origZone->getName(), false, false, true, parent, true), bRect(QRectF()), minRows(0), numberCards(_numberCards), origZone(_origZone), revealZone(_revealZone), writeableRevealZone(_writeableRevealZone), sortByName(false), sortByType(false)
|
: SelectZone(_p, _origZone->getName(), false, false, true, parent, true), bRect(QRectF()), minRows(0), numberCards(_numberCards), origZone(_origZone), revealZone(_revealZone), writeableRevealZone(_writeableRevealZone), sortByName(false), sortByType(false)
|
||||||
{
|
{
|
||||||
qDebug() << "revealZone=" << revealZone << "writeable=" << writeableRevealZone;
|
|
||||||
if (!(revealZone && !writeableRevealZone))
|
if (!(revealZone && !writeableRevealZone))
|
||||||
origZone->setView(this);
|
origZone->setView(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -306,6 +306,15 @@ Response::ResponseCode Server_Player::drawCards(GameEventStorage &ges, int numbe
|
||||||
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 (deckZone->getAlwaysRevealTopCard() && !deckZone->cards.isEmpty()) {
|
||||||
|
Event_RevealCards revealEvent;
|
||||||
|
revealEvent.set_zone_name(deckZone->getName().toStdString());
|
||||||
|
revealEvent.set_card_id(0);
|
||||||
|
deckZone->cards.first()->getInfo(revealEvent.add_cards());
|
||||||
|
|
||||||
|
ges.enqueueGameEvent(revealEvent, playerId);
|
||||||
|
}
|
||||||
|
|
||||||
return Response::RespOk;
|
return Response::RespOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,6 +420,7 @@ Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges, Server_Car
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int publicNewX;
|
||||||
if (card->getDestroyOnZoneChange() && (startzone->getName() != targetzone->getName())) {
|
if (card->getDestroyOnZoneChange() && (startzone->getName() != targetzone->getName())) {
|
||||||
Event_DestroyCard event;
|
Event_DestroyCard event;
|
||||||
event.set_zone_name(startzone->getName().toStdString());
|
event.set_zone_name(startzone->getName().toStdString());
|
||||||
|
@ -459,13 +469,14 @@ Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges, Server_Car
|
||||||
if (startzone->getType() == ServerInfo_Zone::HiddenZone)
|
if (startzone->getType() == ServerInfo_Zone::HiddenZone)
|
||||||
privatePosition = position;
|
privatePosition = position;
|
||||||
|
|
||||||
|
publicNewX = newX;
|
||||||
|
|
||||||
Event_MoveCard eventOthers;
|
Event_MoveCard eventOthers;
|
||||||
eventOthers.set_start_player_id(startzone->getPlayer()->getPlayerId());
|
eventOthers.set_start_player_id(startzone->getPlayer()->getPlayerId());
|
||||||
eventOthers.set_start_zone(startzone->getName().toStdString());
|
eventOthers.set_start_zone(startzone->getName().toStdString());
|
||||||
eventOthers.set_target_player_id(targetzone->getPlayer()->getPlayerId());
|
eventOthers.set_target_player_id(targetzone->getPlayer()->getPlayerId());
|
||||||
if (startzone != targetzone)
|
if (startzone != targetzone)
|
||||||
eventOthers.set_target_zone(targetzone->getName().toStdString());
|
eventOthers.set_target_zone(targetzone->getName().toStdString());
|
||||||
eventOthers.set_x(newX);
|
|
||||||
eventOthers.set_y(y);
|
eventOthers.set_y(y);
|
||||||
eventOthers.set_face_down(faceDown);
|
eventOthers.set_face_down(faceDown);
|
||||||
|
|
||||||
|
@ -475,6 +486,7 @@ Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges, Server_Car
|
||||||
eventPrivate.set_card_name(privateCardName.toStdString());
|
eventPrivate.set_card_name(privateCardName.toStdString());
|
||||||
eventPrivate.set_position(privatePosition);
|
eventPrivate.set_position(privatePosition);
|
||||||
eventPrivate.set_new_card_id(privateNewCardId);
|
eventPrivate.set_new_card_id(privateNewCardId);
|
||||||
|
eventPrivate.set_x(newX);
|
||||||
|
|
||||||
// Other players do not get to see the start and/or target position of the card if the respective
|
// Other players do not get to see the start and/or target position of the card if the respective
|
||||||
// part of the zone is being looked at. The information is not needed anyway because in hidden zones,
|
// part of the zone is being looked at. The information is not needed anyway because in hidden zones,
|
||||||
|
@ -485,8 +497,9 @@ Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges, Server_Car
|
||||||
)
|
)
|
||||||
position = -1;
|
position = -1;
|
||||||
if ((targetzone->getType() == ServerInfo_Zone::HiddenZone) && ((targetzone->getCardsBeingLookedAt() > newX) || (targetzone->getCardsBeingLookedAt() == -1)))
|
if ((targetzone->getType() == ServerInfo_Zone::HiddenZone) && ((targetzone->getCardsBeingLookedAt() > newX) || (targetzone->getCardsBeingLookedAt() == -1)))
|
||||||
newX = -1;
|
publicNewX = -1;
|
||||||
|
|
||||||
|
eventOthers.set_x(publicNewX);
|
||||||
eventOthers.set_position(position);
|
eventOthers.set_position(position);
|
||||||
if ((startzone->getType() == ServerInfo_Zone::PublicZone) || (targetzone->getType() == ServerInfo_Zone::PublicZone)) {
|
if ((startzone->getType() == ServerInfo_Zone::PublicZone) || (targetzone->getType() == ServerInfo_Zone::PublicZone)) {
|
||||||
eventOthers.set_card_id(oldCardId);
|
eventOthers.set_card_id(oldCardId);
|
||||||
|
@ -504,6 +517,22 @@ Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges, Server_Car
|
||||||
if (!ptString.isEmpty() && !faceDown)
|
if (!ptString.isEmpty() && !faceDown)
|
||||||
setCardAttrHelper(ges, targetzone->getName(), card->getId(), AttrPT, ptString);
|
setCardAttrHelper(ges, targetzone->getName(), card->getId(), AttrPT, ptString);
|
||||||
}
|
}
|
||||||
|
if (startzone->getAlwaysRevealTopCard() && !startzone->cards.isEmpty() && (originalPosition == 0)) {
|
||||||
|
Event_RevealCards revealEvent;
|
||||||
|
revealEvent.set_zone_name(startzone->getName().toStdString());
|
||||||
|
revealEvent.set_card_id(0);
|
||||||
|
startzone->cards.first()->getInfo(revealEvent.add_cards());
|
||||||
|
|
||||||
|
ges.enqueueGameEvent(revealEvent, playerId);
|
||||||
|
}
|
||||||
|
if (targetzone->getAlwaysRevealTopCard() && !targetzone->cards.isEmpty() && (newX == 0)) {
|
||||||
|
Event_RevealCards revealEvent;
|
||||||
|
revealEvent.set_zone_name(targetzone->getName().toStdString());
|
||||||
|
revealEvent.set_card_id(0);
|
||||||
|
targetzone->cards.first()->getInfo(revealEvent.add_cards());
|
||||||
|
|
||||||
|
ges.enqueueGameEvent(revealEvent, playerId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (undoingDraw)
|
if (undoingDraw)
|
||||||
ges.setGameEventContext(Context_UndoDraw());
|
ges.setGameEventContext(Context_UndoDraw());
|
||||||
|
@ -1552,6 +1581,15 @@ Response::ResponseCode Server_Player::cmdChangeZoneProperties(const Command_Chan
|
||||||
event.set_always_reveal_top_card(cmd.always_reveal_top_card());
|
event.set_always_reveal_top_card(cmd.always_reveal_top_card());
|
||||||
|
|
||||||
ges.enqueueGameEvent(event, playerId);
|
ges.enqueueGameEvent(event, playerId);
|
||||||
|
|
||||||
|
if (!zone->cards.isEmpty()) {
|
||||||
|
Event_RevealCards revealEvent;
|
||||||
|
revealEvent.set_zone_name(zone->getName().toStdString());
|
||||||
|
revealEvent.set_card_id(0);
|
||||||
|
zone->cards.first()->getInfo(revealEvent.add_cards());
|
||||||
|
|
||||||
|
ges.enqueueGameEvent(revealEvent, playerId);
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
return Response::RespContextError;
|
return Response::RespContextError;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue