mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-06 05:23:56 -07:00
[Server][Game] Make undo draw failure visible in chat
This commit is contained in:
parent
5219cffa6b
commit
b4da05e75f
8 changed files with 35 additions and 0 deletions
|
|
@ -806,6 +806,12 @@ void MessageLogWidget::logUndoDraw(PlayerLogic *player, QString cardName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessageLogWidget::logUndoDrawFailed(PlayerLogic *player)
|
||||||
|
{
|
||||||
|
appendHtmlServerMessage(
|
||||||
|
tr("%1 failed to undo their last draw.").arg(sanitizeHtml(player->getPlayerInfo()->getName())));
|
||||||
|
}
|
||||||
|
|
||||||
void MessageLogWidget::setContextJudgeName(QString name)
|
void MessageLogWidget::setContextJudgeName(QString name)
|
||||||
{
|
{
|
||||||
messagePrefix = QString("<span style=\"color:black\">");
|
messagePrefix = QString("<span style=\"color:black\">");
|
||||||
|
|
@ -839,6 +845,7 @@ void MessageLogWidget::connectToPlayerEventHandler(PlayerEventHandler *playerEve
|
||||||
connect(playerEventHandler, &PlayerEventHandler::logDumpZone, this, &MessageLogWidget::logDumpZone);
|
connect(playerEventHandler, &PlayerEventHandler::logDumpZone, this, &MessageLogWidget::logDumpZone);
|
||||||
connect(playerEventHandler, &PlayerEventHandler::logDrawCards, this, &MessageLogWidget::logDrawCards);
|
connect(playerEventHandler, &PlayerEventHandler::logDrawCards, this, &MessageLogWidget::logDrawCards);
|
||||||
connect(playerEventHandler, &PlayerEventHandler::logUndoDraw, this, &MessageLogWidget::logUndoDraw);
|
connect(playerEventHandler, &PlayerEventHandler::logUndoDraw, this, &MessageLogWidget::logUndoDraw);
|
||||||
|
connect(playerEventHandler, &PlayerEventHandler::logUndoDrawFailed, this, &MessageLogWidget::logUndoDrawFailed);
|
||||||
connect(playerEventHandler, &PlayerEventHandler::logRevealCards, this, &MessageLogWidget::logRevealCards);
|
connect(playerEventHandler, &PlayerEventHandler::logRevealCards, this, &MessageLogWidget::logRevealCards);
|
||||||
connect(playerEventHandler, &PlayerEventHandler::logAlwaysRevealTopCard, this,
|
connect(playerEventHandler, &PlayerEventHandler::logAlwaysRevealTopCard, this,
|
||||||
&MessageLogWidget::logAlwaysRevealTopCard);
|
&MessageLogWidget::logAlwaysRevealTopCard);
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,7 @@ public slots:
|
||||||
void logSpectatorSay(const ServerInfo_User &spectator, QString message);
|
void logSpectatorSay(const ServerInfo_User &spectator, QString message);
|
||||||
void logUnattachCard(PlayerLogic *player, QString cardName);
|
void logUnattachCard(PlayerLogic *player, QString cardName);
|
||||||
void logUndoDraw(PlayerLogic *player, QString cardName);
|
void logUndoDraw(PlayerLogic *player, QString cardName);
|
||||||
|
void logUndoDrawFailed(PlayerLogic *player);
|
||||||
void setContextJudgeName(QString player);
|
void setContextJudgeName(QString player);
|
||||||
void appendHtmlServerMessage(const QString &html,
|
void appendHtmlServerMessage(const QString &html,
|
||||||
bool optionalIsBold = false,
|
bool optionalIsBold = false,
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
#include <libcockatrice/protocol/pb/event_set_card_counter.pb.h>
|
#include <libcockatrice/protocol/pb/event_set_card_counter.pb.h>
|
||||||
#include <libcockatrice/protocol/pb/event_set_counter.pb.h>
|
#include <libcockatrice/protocol/pb/event_set_counter.pb.h>
|
||||||
#include <libcockatrice/protocol/pb/event_shuffle.pb.h>
|
#include <libcockatrice/protocol/pb/event_shuffle.pb.h>
|
||||||
|
#include <libcockatrice/protocol/pb/event_undo_draw_failed.pb.h>
|
||||||
#include <libcockatrice/utility/zone_names.h>
|
#include <libcockatrice/utility/zone_names.h>
|
||||||
|
|
||||||
PlayerEventHandler::PlayerEventHandler(PlayerLogic *_player) : QObject(_player), player(_player)
|
PlayerEventHandler::PlayerEventHandler(PlayerLogic *_player) : QObject(_player), player(_player)
|
||||||
|
|
@ -581,6 +582,11 @@ void PlayerEventHandler::eventChangeZoneProperties(const Event_ChangeZonePropert
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlayerEventHandler::eventUndoDrawFailed(const Event_UndoDrawFailed &)
|
||||||
|
{
|
||||||
|
emit logUndoDrawFailed(player);
|
||||||
|
}
|
||||||
|
|
||||||
void PlayerEventHandler::processGameEvent(GameEvent::GameEventType type,
|
void PlayerEventHandler::processGameEvent(GameEvent::GameEventType type,
|
||||||
const GameEvent &event,
|
const GameEvent &event,
|
||||||
const GameEventContext &context,
|
const GameEventContext &context,
|
||||||
|
|
@ -644,6 +650,9 @@ void PlayerEventHandler::processGameEvent(GameEvent::GameEventType type,
|
||||||
case GameEvent::CHANGE_ZONE_PROPERTIES:
|
case GameEvent::CHANGE_ZONE_PROPERTIES:
|
||||||
eventChangeZoneProperties(event.GetExtension(Event_ChangeZoneProperties::ext));
|
eventChangeZoneProperties(event.GetExtension(Event_ChangeZoneProperties::ext));
|
||||||
break;
|
break;
|
||||||
|
case GameEvent::UNDO_DRAW_FAILED:
|
||||||
|
eventUndoDrawFailed(event.GetExtension(Event_UndoDrawFailed::ext));
|
||||||
|
break;
|
||||||
default: {
|
default: {
|
||||||
qWarning() << "unhandled game event" << type;
|
qWarning() << "unhandled game event" << type;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,8 @@ class Event_SetCardAttr;
|
||||||
class Event_SetCardCounter;
|
class Event_SetCardCounter;
|
||||||
class Event_SetCounter;
|
class Event_SetCounter;
|
||||||
class Event_Shuffle;
|
class Event_Shuffle;
|
||||||
|
class Event_UndoDrawFailed;
|
||||||
|
|
||||||
class PlayerEventHandler : public QObject
|
class PlayerEventHandler : public QObject
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -52,6 +54,7 @@ signals:
|
||||||
void logCreateToken(PlayerLogic *player, QString cardName, QString pt, bool faceDown);
|
void logCreateToken(PlayerLogic *player, QString cardName, QString pt, bool faceDown);
|
||||||
void logDrawCards(PlayerLogic *player, int number, bool deckIsEmpty);
|
void logDrawCards(PlayerLogic *player, int number, bool deckIsEmpty);
|
||||||
void logUndoDraw(PlayerLogic *player, QString cardName);
|
void logUndoDraw(PlayerLogic *player, QString cardName);
|
||||||
|
void logUndoDrawFailed(PlayerLogic *player);
|
||||||
void logMoveCard(PlayerLogic *player,
|
void logMoveCard(PlayerLogic *player,
|
||||||
CardItem *card,
|
CardItem *card,
|
||||||
CardZoneLogic *startZone,
|
CardZoneLogic *startZone,
|
||||||
|
|
@ -108,6 +111,7 @@ public:
|
||||||
void eventDrawCards(const Event_DrawCards &event);
|
void eventDrawCards(const Event_DrawCards &event);
|
||||||
void eventRevealCards(const Event_RevealCards &event, EventProcessingOptions options);
|
void eventRevealCards(const Event_RevealCards &event, EventProcessingOptions options);
|
||||||
void eventChangeZoneProperties(const Event_ChangeZoneProperties &event);
|
void eventChangeZoneProperties(const Event_ChangeZoneProperties &event);
|
||||||
|
void eventUndoDrawFailed(const Event_UndoDrawFailed &event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlayerLogic *player;
|
PlayerLogic *player;
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@
|
||||||
#include <libcockatrice/protocol/pb/event_player_properties_changed.pb.h>
|
#include <libcockatrice/protocol/pb/event_player_properties_changed.pb.h>
|
||||||
#include <libcockatrice/protocol/pb/event_set_counter.pb.h>
|
#include <libcockatrice/protocol/pb/event_set_counter.pb.h>
|
||||||
#include <libcockatrice/protocol/pb/event_shuffle.pb.h>
|
#include <libcockatrice/protocol/pb/event_shuffle.pb.h>
|
||||||
|
#include <libcockatrice/protocol/pb/event_undo_draw_failed.pb.h>
|
||||||
#include <libcockatrice/protocol/pb/response.pb.h>
|
#include <libcockatrice/protocol/pb/response.pb.h>
|
||||||
#include <libcockatrice/protocol/pb/response_deck_download.pb.h>
|
#include <libcockatrice/protocol/pb/response_deck_download.pb.h>
|
||||||
#include <libcockatrice/protocol/pb/response_dump_zone.pb.h>
|
#include <libcockatrice/protocol/pb/response_dump_zone.pb.h>
|
||||||
|
|
@ -409,6 +410,8 @@ Server_Player::cmdUndoDraw(const Command_UndoDraw & /*cmd*/, ResponseContainer &
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastDrawList.isEmpty()) {
|
if (lastDrawList.isEmpty()) {
|
||||||
|
Event_UndoDrawFailed event;
|
||||||
|
ges.enqueueGameEvent(event, playerId);
|
||||||
return Response::RespContextError;
|
return Response::RespContextError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@ set(PROTO_FILES
|
||||||
event_set_card_counter.proto
|
event_set_card_counter.proto
|
||||||
event_set_counter.proto
|
event_set_counter.proto
|
||||||
event_shuffle.proto
|
event_shuffle.proto
|
||||||
|
event_undo_draw_failed.proto
|
||||||
event_user_joined.proto
|
event_user_joined.proto
|
||||||
event_user_left.proto
|
event_user_left.proto
|
||||||
event_user_message.proto
|
event_user_message.proto
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
syntax = "proto2";
|
||||||
|
import "game_event.proto";
|
||||||
|
|
||||||
|
message Event_UndoDrawFailed {
|
||||||
|
extend GameEvent {
|
||||||
|
optional Event_UndoDrawFailed ext = 2022;
|
||||||
|
}
|
||||||
|
optional sint32 phase = 1;
|
||||||
|
}
|
||||||
|
|
@ -33,6 +33,7 @@ message GameEvent {
|
||||||
// STOP_DUMP_ZONE = 2019; // obsolete
|
// STOP_DUMP_ZONE = 2019; // obsolete
|
||||||
CHANGE_ZONE_PROPERTIES = 2020;
|
CHANGE_ZONE_PROPERTIES = 2020;
|
||||||
REVERSE_TURN = 2021;
|
REVERSE_TURN = 2021;
|
||||||
|
UNDO_DRAW_FAILED = 2022;
|
||||||
}
|
}
|
||||||
optional sint32 player_id = 1 [default = -1];
|
optional sint32 player_id = 1 [default = -1];
|
||||||
extensions 100 to max;
|
extensions 100 to max;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue