mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-12 04:50:01 -08:00
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:
parent
6fab4410d0
commit
4a3cb564ca
10 changed files with 127 additions and 255 deletions
|
|
@ -32,7 +32,6 @@
|
|||
#include <QMetaType>
|
||||
#include <QPoint>
|
||||
#include <QPointF>
|
||||
#include <QPointer>
|
||||
#include <QSharedPointer>
|
||||
#include <QTimer>
|
||||
#include <QVariant>
|
||||
|
|
@ -48,7 +47,6 @@
|
|||
#include <libcockatrice/deck_list/loaded_deck.h>
|
||||
#include <libcockatrice/interfaces/interface_card_preference_provider.h>
|
||||
#include <libcockatrice/interfaces/interface_interface_settings_provider.h>
|
||||
#include <libcockatrice/network/client/abstract/abstract_client.h>
|
||||
#include <libcockatrice/protocol/pb/command_attach_card.pb.h>
|
||||
#include <libcockatrice/protocol/pb/command_change_zone_properties.pb.h>
|
||||
#include <libcockatrice/protocol/pb/command_create_arrow.pb.h>
|
||||
|
|
@ -68,8 +66,6 @@
|
|||
#include <libcockatrice/protocol/pb/command_shuffle.pb.h>
|
||||
#include <libcockatrice/protocol/pb/command_undo_draw.pb.h>
|
||||
#include <libcockatrice/protocol/pb/context_move_card.pb.h>
|
||||
#include <libcockatrice/protocol/pb/response.pb.h>
|
||||
#include <libcockatrice/protocol/pending_command.h>
|
||||
#include <libcockatrice/utility/clamped_arithmetic.h>
|
||||
#include <libcockatrice/utility/color.h>
|
||||
#include <libcockatrice/utility/counter_limits.h>
|
||||
|
|
@ -1762,23 +1758,13 @@ void PlayerActions::actRevealRandomHandCard(int revealToPlayerId)
|
|||
|
||||
void PlayerActions::actRevealRandomHandCards(int revealToPlayerId, int amount)
|
||||
{
|
||||
QPointer<AbstractClient> client = player->getGame()->getClientForPlayer(player->getPlayerInfo()->getId());
|
||||
if (!client) {
|
||||
return;
|
||||
}
|
||||
Command_RevealRandomCards cmd;
|
||||
if (revealToPlayerId != -1) {
|
||||
cmd.set_player_id(revealToPlayerId);
|
||||
}
|
||||
cmd.set_zone_name(ZoneNames::HAND);
|
||||
cmd.set_number_of_cards(amount);
|
||||
auto *pending = prepareGameCommand(cmd);
|
||||
connect(pending, &PendingCommand::finished, this, [this, client](const Response &response) {
|
||||
if (client && response.response_code() != Response::RespOk) {
|
||||
emit randomHandRevealFailed(response.response_code() == Response::RespInvalidCommand);
|
||||
}
|
||||
});
|
||||
sendGameCommand(pending);
|
||||
sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
void PlayerActions::actRevealLibrary(int revealToPlayerId)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue