reasonable defaults

This commit is contained in:
Max-Wilhelm Bruker 2011-12-19 00:03:05 +01:00
parent f115342e47
commit c5509db251
20 changed files with 50 additions and 60 deletions

View file

@ -357,33 +357,26 @@ void Player::playerListActionTriggered()
{
QAction *action = static_cast<QAction *>(sender());
QMenu *menu = static_cast<QMenu *>(action->parentWidget());
int otherPlayerId = action->data().toInt();
if (menu == mRevealLibrary) {
Command_RevealCards cmd;
cmd.set_zone_name("deck");
cmd.set_card_id(-1);
Command_RevealCards cmd;
const int otherPlayerId = action->data().toInt();
if (otherPlayerId != -1)
cmd.set_player_id(otherPlayerId);
sendGameCommand(cmd);
} else if (menu == mRevealTopCard) {
Command_RevealCards cmd;
if (menu == mRevealLibrary)
cmd.set_zone_name("deck");
else if (menu == mRevealTopCard) {
cmd.set_zone_name("deck");
cmd.set_card_id(0);
cmd.set_player_id(otherPlayerId);
sendGameCommand(cmd);
} else if (menu == mRevealHand) {
Command_RevealCards cmd;
} else if (menu == mRevealHand)
cmd.set_zone_name("hand");
cmd.set_card_id(-1);
cmd.set_player_id(otherPlayerId);
sendGameCommand(cmd);
} else if (menu == mRevealRandomHandCard) {
Command_RevealCards cmd;
else if (menu == mRevealRandomHandCard) {
cmd.set_zone_name("hand");
cmd.set_card_id(-2);
cmd.set_player_id(otherPlayerId);
sendGameCommand(cmd);
}
} else
return;
sendGameCommand(cmd);
}
void Player::rearrangeZones()

View file

@ -4,10 +4,10 @@ message Command_AttachCard {
optional Command_AttachCard ext = 1009;
}
optional string start_zone = 1;
optional sint32 card_id = 2;
optional sint32 target_player_id = 3;
optional sint32 card_id = 2 [default = -1];
optional sint32 target_player_id = 3 [default = -1];
optional string target_zone = 4;
optional sint32 target_card_id = 5;
optional sint32 target_card_id = 5 [default = -1];
}

View file

@ -5,13 +5,11 @@ message Command_CreateArrow {
extend GameCommand {
optional Command_CreateArrow ext = 1011;
}
optional sint32 start_player_id = 1;
optional sint32 start_player_id = 1 [default = -1];
optional string start_zone = 2;
optional sint32 start_card_id = 3;
optional sint32 target_player_id = 4;
optional sint32 start_card_id = 3 [default = -1];
optional sint32 target_player_id = 4 [default = -1];
optional string target_zone = 5;
optional sint32 target_card_id = 6;
optional sint32 target_card_id = 6 [default = -1];
optional color arrow_color = 7;
}

View file

@ -4,5 +4,5 @@ message Command_DeckDel {
extend SessionCommand {
optional Command_DeckDel ext = 1011;
}
optional uint32 deck_id = 1;
optional sint32 deck_id = 1 [default = -1];
}

View file

@ -4,6 +4,6 @@ message Command_DeckDownload {
extend SessionCommand {
optional Command_DeckDownload ext = 1012;
}
optional uint32 deck_id = 1;
optional sint32 deck_id = 1 [default = -1];
}

View file

@ -4,5 +4,5 @@ message Command_DeckSelect {
optional Command_DeckSelect ext = 1029;
}
optional string deck = 1;
optional sint32 deck_id = 2;
optional sint32 deck_id = 2 [default = -1];
}

View file

@ -3,5 +3,5 @@ message Command_DelCounter {
extend GameCommand {
optional Command_DelCounter ext = 1021;
}
optional sint32 counter_id = 1;
optional sint32 counter_id = 1 [default = -1];
}

View file

@ -3,5 +3,5 @@ message Command_DeleteArrow {
extend GameCommand {
optional Command_DeleteArrow ext = 1012;
}
optional sint32 arrow_id = 1;
optional sint32 arrow_id = 1 [default = -1];
}

View file

@ -3,7 +3,7 @@ message Command_DumpZone {
extend GameCommand {
optional Command_DumpZone ext = 1024;
}
optional sint32 player_id = 1;
optional sint32 player_id = 1 [default = -1];
optional string zone_name = 2;
optional sint32 number_cards = 3;
}

View file

@ -4,7 +4,7 @@ message Command_FlipCard {
optional Command_FlipCard ext = 1008;
}
optional string zone = 1;
optional sint32 card_id = 2;
optional sint32 card_id = 2 [default = -1];
optional bool face_down = 3;
}

View file

@ -4,7 +4,7 @@ message Command_IncCardCounter {
optional Command_IncCardCounter ext = 1015;
}
optional string zone = 1;
optional sint32 card_id = 2;
optional sint32 counter_id = 3;
optional sint32 card_id = 2 [default = -1];
optional sint32 counter_id = 3 [default = -1];
optional sint32 counter_delta = 4;
}

View file

@ -3,6 +3,6 @@ message Command_IncCounter {
extend GameCommand {
optional Command_IncCounter ext = 1018;
}
optional sint32 counter_id = 1;
optional sint32 counter_id = 1 [default = -1];
optional sint32 delta = 2;
}

View file

@ -2,7 +2,7 @@ import "game_commands.proto";
message Command_KickFromGame {
extend GameCommand {
optional Command_KickFromGame ext = 1000;
}
optional sint32 player_id = 1;
}
optional sint32 player_id = 1 [default = -1];
}

View file

@ -1,6 +1,6 @@
import "game_commands.proto";
message CardToMove {
optional sint32 card_id = 1;
optional sint32 card_id = 1 [default = -1];
optional bool face_down = 2;
optional string pt = 3;
optional bool tapped = 4;
@ -16,9 +16,9 @@ message Command_MoveCard {
}
optional string start_zone = 1;
optional ListOfCardsToMove cards_to_move = 2;
optional sint32 target_player_id = 3;
optional sint32 target_player_id = 3 [default = -1];
optional string target_zone = 4;
optional sint32 x = 5;
optional sint32 y = 6;
optional sint32 x = 5 [default = -1];
optional sint32 y = 6 [default = -1];
}

View file

@ -4,6 +4,6 @@ message Command_RevealCards {
optional Command_RevealCards ext = 1026;
}
optional string zone_name = 1;
optional sint32 card_id = 2;
optional sint32 player_id = 3;
optional sint32 card_id = 2 [default = -1];
optional sint32 player_id = 3 [default = -1];
}

View file

@ -4,7 +4,7 @@ message Command_SetCardAttr {
optional Command_SetCardAttr ext = 1013;
}
optional string zone = 1;
optional sint32 card_id = 2;
optional sint32 card_id = 2 [default = -1];
optional string attr_name = 3;
optional string attr_value = 4;
}

View file

@ -4,7 +4,7 @@ message Command_SetCardCounter {
optional Command_SetCardCounter ext = 1014;
}
optional string zone = 1;
optional sint32 card_id = 2;
optional sint32 counter_id = 3;
optional sint32 card_id = 2 [default = -1];
optional sint32 counter_id = 3 [default = -1];
optional sint32 counter_value = 4;
}

View file

@ -3,6 +3,6 @@ message Command_SetCounter {
extend GameCommand {
optional Command_SetCounter ext = 1020;
}
optional sint32 counter_id = 1;
optional sint32 counter_id = 1 [default = -1];
optional sint32 value = 2;
}

View file

@ -41,7 +41,7 @@ message Command_JoinGame {
extend RoomCommand {
optional Command_JoinGame ext = 1003;
}
optional uint32 game_id = 1;
optional sint32 game_id = 1 [default = -1];
optional string password = 2;
optional bool spectator = 3;
optional bool override_restrictions = 4;

View file

@ -949,13 +949,11 @@ ResponseCode Server_ProtocolHandler::cmdAttachCard(const Command_AttachCard &cmd
if (!card)
return RespNameNotFound;
int playerId = cmd.target_player_id();
Server_Player *targetPlayer = 0;
Server_CardZone *targetzone = 0;
Server_Card *targetCard = 0;
qDebug() << "playerId="<<playerId;
if (playerId != -1) {
if (cmd.has_target_player_id()) {
targetPlayer = game->getPlayer(cmd.target_player_id());
if (!targetPlayer)
return RespNameNotFound;
@ -968,7 +966,8 @@ ResponseCode Server_ProtocolHandler::cmdAttachCard(const Command_AttachCard &cmd
// Possibly a flag will have to be introduced for this sometime.
if (!targetzone->hasCoords())
return RespContextError;
targetCard = targetzone->getCard(cmd.target_card_id());
if (cmd.has_target_card_id())
targetCard = targetzone->getCard(cmd.target_card_id());
if (targetCard)
if (targetCard->getParentCard())
return RespContextError;
@ -1391,7 +1390,7 @@ ResponseCode Server_ProtocolHandler::cmdRevealCards(const Command_RevealCards &c
return RespContextError;
Server_Player *otherPlayer = 0;
if (cmd.player_id() != -1) {
if (cmd.has_player_id()) {
otherPlayer = game->getPlayer(cmd.player_id());
if (!otherPlayer)
return RespNameNotFound;
@ -1401,7 +1400,7 @@ ResponseCode Server_ProtocolHandler::cmdRevealCards(const Command_RevealCards &c
return RespNameNotFound;
QList<Server_Card *> cardsToReveal;
if (cmd.card_id() == -1)
if (!cmd.has_card_id())
cardsToReveal = zone->cards;
else if (cmd.card_id() == -2) {
if (zone->cards.isEmpty())
@ -1435,12 +1434,12 @@ ResponseCode Server_ProtocolHandler::cmdRevealCards(const Command_RevealCards &c
attachCardId = card->getParentCard()->getId();
}
if (cmd.player_id() != -1)
if (cmd.has_player_id())
respCardListPrivate.append(new ServerInfo_Card(card->getId(), card->getName(), card->getX(), card->getY(), card->getFaceDown(), card->getTapped(), card->getAttacking(), card->getColor(), card->getPT(), card->getAnnotation(), card->getDestroyOnZoneChange(), card->getDoesntUntap(), cardCounterListPrivate, attachPlayerId, attachZone, attachCardId));
respCardListOmniscient.append(new ServerInfo_Card(card->getId(), card->getName(), card->getX(), card->getY(), card->getFaceDown(), card->getTapped(), card->getAttacking(), card->getColor(), card->getPT(), card->getAnnotation(), card->getDestroyOnZoneChange(), card->getDoesntUntap(), cardCounterListOmniscient, attachPlayerId, attachZone, attachCardId));
}
if (cmd.player_id() == -1)
if (!cmd.has_player_id())
bla->enqueueGameEventPublic(new Event_RevealCards(player->getPlayerId(), zone->getName(), cmd.card_id(), -1, respCardListOmniscient), game->getGameId());
else {
bla->enqueueGameEventPublic(new Event_RevealCards(player->getPlayerId(), zone->getName(), cmd.card_id(), otherPlayer->getPlayerId()), game->getGameId());