Simplify random reveal to follow existing command patterns

Forward server dispatch through cmdRevealRandomCards and use ordinary PlayerActions command sending. Remove the bespoke server-version error UI and long-lived-object guards.

Reduce the test from 246 to 150 lines with two focused cases using the current RoleInfo player API, preserving distinct-card, private-event and rejected-count coverage.
This commit is contained in:
Bryce! 2026-11-05 07:32:46 -05:00
parent 6fab4410d0
commit 4a3cb564ca
10 changed files with 127 additions and 255 deletions

View file

@ -406,6 +406,13 @@ Response::ResponseCode Server_AbstractParticipant::cmdRevealCards(const Command_
return Response::RespFunctionNotAllowed;
}
Response::ResponseCode Server_AbstractParticipant::cmdRevealRandomCards(const Command_RevealRandomCards & /*cmd*/,
ResponseContainer & /*rc*/,
GameEventStorage & /*ges*/)
{
return Response::RespFunctionNotAllowed;
}
Response::ResponseCode Server_AbstractParticipant::cmdChangeZoneProperties(const Command_ChangeZoneProperties & /*cmd*/,
ResponseContainer & /*rc*/,
GameEventStorage & /*ges*/)
@ -545,20 +552,9 @@ Server_AbstractParticipant::processGameCommand(const GameCommand &command, Respo
case GameCommand::REVEAL_CARDS:
return cmdRevealCards(command.GetExtension(Command_RevealCards::ext), rc, ges);
break;
case GameCommand::REVEAL_RANDOM_CARDS: {
const auto &random = command.GetExtension(Command_RevealRandomCards::ext);
if (random.number_of_cards() <= 0) {
return Response::RespInvalidData;
}
// Reuse the existing player/judge authorization and private reveal delivery.
Command_RevealCards reveal;
reveal.set_zone_name(random.zone_name());
reveal.add_card_id(-2);
if (random.has_player_id()) {
reveal.set_player_id(random.player_id());
}
return cmdRevealCards(reveal, rc, ges, random.number_of_cards());
}
case GameCommand::REVEAL_RANDOM_CARDS:
return cmdRevealRandomCards(command.GetExtension(Command_RevealRandomCards::ext), rc, ges);
break;
case GameCommand::MOVE_CARD:
return cmdMoveCard(command.GetExtension(Command_MoveCard::ext), rc, ges);
break;

View file

@ -46,6 +46,7 @@ class Command_NextTurn;
class Command_SetActivePhase;
class Command_DumpZone;
class Command_RevealCards;
class Command_RevealRandomCards;
class Command_ReverseTurn;
class Command_MoveCard;
class Command_SetSideboardPlan;
@ -176,6 +177,8 @@ public:
virtual Response::ResponseCode
cmdRevealCards(const Command_RevealCards &cmd, ResponseContainer &rc, GameEventStorage &ges, int randomCount = 1);
virtual Response::ResponseCode
cmdRevealRandomCards(const Command_RevealRandomCards &cmd, ResponseContainer &rc, GameEventStorage &ges);
virtual Response::ResponseCode
cmdReverseTurn(const Command_ReverseTurn & /*cmd*/, ResponseContainer & /*rc*/, GameEventStorage &ges);
virtual Response::ResponseCode
cmdSetPlayerOrder(const Command_SetPlayerOrder &cmd, ResponseContainer &rc, GameEventStorage &ges);

View file

@ -1494,6 +1494,22 @@ Server_AbstractPlayer::cmdDumpZone(const Command_DumpZone &cmd, ResponseContaine
return Response::RespOk;
}
Response::ResponseCode Server_AbstractPlayer::cmdRevealRandomCards(const Command_RevealRandomCards &cmd,
ResponseContainer &rc,
GameEventStorage &ges)
{
if (cmd.number_of_cards() <= 0) {
return Response::RespInvalidData;
}
Command_RevealCards reveal;
reveal.set_zone_name(cmd.zone_name());
reveal.add_card_id(-2);
if (cmd.has_player_id()) {
reveal.set_player_id(cmd.player_id());
}
return cmdRevealCards(reveal, rc, ges, cmd.number_of_cards());
}
Response::ResponseCode Server_AbstractPlayer::cmdRevealCards(const Command_RevealCards &cmd,
ResponseContainer & /*rc*/,
GameEventStorage &ges,

View file

@ -165,6 +165,8 @@ public:
ResponseContainer &rc,
GameEventStorage &ges,
int randomCount = 1) override;
Response::ResponseCode
cmdRevealRandomCards(const Command_RevealRandomCards &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
virtual Response::ResponseCode cmdChangeZoneProperties(const Command_ChangeZoneProperties &cmd,
ResponseContainer &rc,
GameEventStorage &ges) override;