Automatically attach related cards to the original card
This commit is contained in:
parent
9ca1329cac
commit
8826908923
3 changed files with 25 additions and 6 deletions
|
@ -1078,7 +1078,12 @@ void Player::actCreatePredefinedToken()
|
||||||
|
|
||||||
void Player::actCreateRelatedCard()
|
void Player::actCreateRelatedCard()
|
||||||
{
|
{
|
||||||
// get he target card name
|
// get the clicked card
|
||||||
|
CardItem * sourceCard = game->getActiveCard();
|
||||||
|
if(!sourceCard)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// get the target card name
|
||||||
QAction *action = static_cast<QAction *>(sender());
|
QAction *action = static_cast<QAction *>(sender());
|
||||||
CardInfo *cardInfo = db->getCard(action->text());
|
CardInfo *cardInfo = db->getCard(action->text());
|
||||||
|
|
||||||
|
@ -1089,8 +1094,8 @@ void Player::actCreateRelatedCard()
|
||||||
cmd.set_color(cardInfo->getColors().isEmpty() ? QString().toStdString() : cardInfo->getColors().first().toLower().toStdString());
|
cmd.set_color(cardInfo->getColors().isEmpty() ? QString().toStdString() : cardInfo->getColors().first().toLower().toStdString());
|
||||||
cmd.set_pt(cardInfo->getPowTough().toStdString());
|
cmd.set_pt(cardInfo->getPowTough().toStdString());
|
||||||
cmd.set_destroy_on_zone_change(true);
|
cmd.set_destroy_on_zone_change(true);
|
||||||
cmd.set_x(-1);
|
cmd.set_target_zone(sourceCard->getZone()->getName().toStdString());
|
||||||
cmd.set_y(0);
|
cmd.set_target_card_id(sourceCard->getId());
|
||||||
|
|
||||||
sendGameCommand(cmd);
|
sendGameCommand(cmd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,8 @@ message Command_CreateToken {
|
||||||
optional bool destroy_on_zone_change = 6;
|
optional bool destroy_on_zone_change = 6;
|
||||||
optional sint32 x = 7;
|
optional sint32 x = 7;
|
||||||
optional sint32 y = 8;
|
optional sint32 y = 8;
|
||||||
|
optional string target_zone = 9;
|
||||||
|
optional sint32 target_card_id = 10 [default = -1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1065,7 +1065,7 @@ Response::ResponseCode Server_Player::cmdAttachCard(const Command_AttachCard &cm
|
||||||
return Response::RespOk;
|
return Response::RespOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
Response::ResponseCode Server_Player::cmdCreateToken(const Command_CreateToken &cmd, ResponseContainer & /*rc*/, GameEventStorage &ges)
|
Response::ResponseCode Server_Player::cmdCreateToken(const Command_CreateToken &cmd, ResponseContainer & rc, GameEventStorage &ges)
|
||||||
{
|
{
|
||||||
if (spectator)
|
if (spectator)
|
||||||
return Response::RespFunctionNotAllowed;
|
return Response::RespFunctionNotAllowed;
|
||||||
|
@ -1110,7 +1110,19 @@ Response::ResponseCode Server_Player::cmdCreateToken(const Command_CreateToken &
|
||||||
event.set_y(y);
|
event.set_y(y);
|
||||||
ges.enqueueGameEvent(event, playerId);
|
ges.enqueueGameEvent(event, playerId);
|
||||||
|
|
||||||
return Response::RespOk;
|
// chck if the token is a replacement for an existing card
|
||||||
|
if(cmd.target_card_id() < 0)
|
||||||
|
return Response::RespOk;
|
||||||
|
|
||||||
|
Command_AttachCard cmd2;
|
||||||
|
cmd2.set_start_zone(cmd.target_zone());
|
||||||
|
cmd2.set_card_id(cmd.target_card_id());
|
||||||
|
|
||||||
|
cmd2.set_target_player_id(zone->getPlayer()->getPlayerId());
|
||||||
|
cmd2.set_target_zone(cmd.zone());
|
||||||
|
cmd2.set_target_card_id(card->getId());
|
||||||
|
|
||||||
|
return cmdAttachCard(cmd2, rc, ges);
|
||||||
}
|
}
|
||||||
|
|
||||||
Response::ResponseCode Server_Player::cmdCreateArrow(const Command_CreateArrow &cmd, ResponseContainer & /*rc*/, GameEventStorage &ges)
|
Response::ResponseCode Server_Player::cmdCreateArrow(const Command_CreateArrow &cmd, ResponseContainer & /*rc*/, GameEventStorage &ges)
|
||||||
|
|
Loading…
Reference in a new issue