mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
changed lock icon, added sideboard locking, issue #15 fixed
This commit is contained in:
parent
0b51af888c
commit
b2b7242802
17 changed files with 336 additions and 122 deletions
|
|
@ -40,6 +40,7 @@ SET(PROTO_FILES
|
|||
command_set_card_counter.proto
|
||||
command_set_counter.proto
|
||||
command_set_sideboard_plan.proto
|
||||
command_set_sideboard_lock.proto
|
||||
command_shuffle.proto
|
||||
commands.proto
|
||||
command_stop_dump_zone.proto
|
||||
|
|
@ -51,6 +52,7 @@ SET(PROTO_FILES
|
|||
context_mulligan.proto
|
||||
context_ping_changed.proto
|
||||
context_ready_start.proto
|
||||
context_set_sideboard_lock.proto
|
||||
context_undo_draw.proto
|
||||
event_add_to_list.proto
|
||||
event_attach_card.proto
|
||||
|
|
|
|||
7
common/pb/command_set_sideboard_lock.proto
Normal file
7
common/pb/command_set_sideboard_lock.proto
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import "game_commands.proto";
|
||||
message Command_SetSideboardLock {
|
||||
extend GameCommand {
|
||||
optional Command_SetSideboardLock ext = 1030;
|
||||
}
|
||||
optional bool locked = 1;
|
||||
}
|
||||
7
common/pb/context_set_sideboard_lock.proto
Normal file
7
common/pb/context_set_sideboard_lock.proto
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import "game_event_context.proto";
|
||||
|
||||
message Context_SetSideboardLock {
|
||||
extend GameEventContext {
|
||||
optional Context_SetSideboardLock ext = 1008;
|
||||
}
|
||||
}
|
||||
|
|
@ -30,6 +30,7 @@ message GameCommand {
|
|||
MOVE_CARD = 1027;
|
||||
SET_SIDEBOARD_PLAN = 1028;
|
||||
DECK_SELECT = 1029;
|
||||
SET_SIDEBOARD_LOCK = 1030;
|
||||
}
|
||||
extensions 100 to max;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ message GameEventContext {
|
|||
MULLIGAN = 1005;
|
||||
PING_CHANGED = 1006;
|
||||
CONNECTION_STATE_CHANGED = 1007;
|
||||
SET_SIDEBOARD_LOCK = 1008;
|
||||
}
|
||||
extensions 100 to max;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,4 +8,5 @@ message ServerInfo_PlayerProperties {
|
|||
optional bool ready_start = 5;
|
||||
optional string deck_hash = 6;
|
||||
optional sint32 ping_seconds = 7;
|
||||
optional bool sideboard_locked = 8;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include "pb/command_create_counter.pb.h"
|
||||
#include "pb/command_create_token.pb.h"
|
||||
#include "pb/command_deck_select.pb.h"
|
||||
#include "pb/command_set_sideboard_lock.pb.h"
|
||||
#include "pb/command_del_counter.pb.h"
|
||||
#include "pb/command_delete_arrow.pb.h"
|
||||
#include "pb/command_draw_cards.pb.h"
|
||||
|
|
@ -70,6 +71,7 @@
|
|||
#include "pb/context_connection_state_changed.pb.h"
|
||||
#include "pb/context_concede.pb.h"
|
||||
#include "pb/context_deck_select.pb.h"
|
||||
#include "pb/context_set_sideboard_lock.pb.h"
|
||||
#include "pb/context_move_card.pb.h"
|
||||
#include "pb/context_mulligan.pb.h"
|
||||
#include "pb/context_undo_draw.pb.h"
|
||||
|
|
@ -78,7 +80,7 @@
|
|||
#include <QDebug>
|
||||
|
||||
Server_Player::Server_Player(Server_Game *_game, int _playerId, const ServerInfo_User &_userInfo, bool _spectator, Server_AbstractUserInterface *_userInterface)
|
||||
: game(_game), userInterface(_userInterface), userInfo(new ServerInfo_User(_userInfo)), deck(0), pingTime(0), playerId(_playerId), spectator(_spectator), nextCardId(0), readyStart(false), conceded(false)
|
||||
: game(_game), userInterface(_userInterface), userInfo(new ServerInfo_User(_userInfo)), deck(0), pingTime(0), playerId(_playerId), spectator(_spectator), nextCardId(0), readyStart(false), conceded(false), sideboardLocked(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -257,6 +259,7 @@ ServerInfo_PlayerProperties Server_Player::getProperties(bool withUserInfo)
|
|||
result.mutable_user_info()->CopyFrom(*userInfo);
|
||||
result.set_spectator(spectator);
|
||||
result.set_conceded(conceded);
|
||||
result.set_sideboard_locked(sideboardLocked);
|
||||
result.set_ready_start(readyStart);
|
||||
if (deck)
|
||||
result.set_deck_hash(deck->getDeckHash().toStdString());
|
||||
|
|
@ -645,8 +648,10 @@ Response::ResponseCode Server_Player::cmdDeckSelect(const Command_DeckSelect &cm
|
|||
|
||||
delete deck;
|
||||
deck = newDeck;
|
||||
sideboardLocked = true;
|
||||
|
||||
Event_PlayerPropertiesChanged event;
|
||||
event.mutable_player_properties()->set_sideboard_locked(true);
|
||||
event.mutable_player_properties()->set_deck_hash(deck->getDeckHash().toStdString());
|
||||
ges.enqueueGameEvent(event, playerId);
|
||||
|
||||
|
|
@ -669,6 +674,8 @@ Response::ResponseCode Server_Player::cmdSetSideboardPlan(const Command_SetSideb
|
|||
return Response::RespContextError;
|
||||
if (!deck)
|
||||
return Response::RespContextError;
|
||||
if (sideboardLocked)
|
||||
return Response::RespContextError;
|
||||
|
||||
QList<MoveCard_ToZone> sideboardPlan;
|
||||
for (int i = 0; i < cmd.move_list_size(); ++i)
|
||||
|
|
@ -678,6 +685,29 @@ Response::ResponseCode Server_Player::cmdSetSideboardPlan(const Command_SetSideb
|
|||
return Response::RespOk;
|
||||
}
|
||||
|
||||
Response::ResponseCode Server_Player::cmdSetSideboardLock(const Command_SetSideboardLock &cmd, ResponseContainer & /*rc*/, GameEventStorage &ges)
|
||||
{
|
||||
if (spectator)
|
||||
return Response::RespFunctionNotAllowed;
|
||||
if (readyStart)
|
||||
return Response::RespContextError;
|
||||
if (!deck)
|
||||
return Response::RespContextError;
|
||||
if (sideboardLocked == cmd.locked())
|
||||
return Response::RespContextError;
|
||||
|
||||
sideboardLocked = cmd.locked();
|
||||
if (sideboardLocked)
|
||||
deck->setCurrentSideboardPlan(QList<MoveCard_ToZone>());
|
||||
|
||||
Event_PlayerPropertiesChanged event;
|
||||
event.mutable_player_properties()->set_sideboard_locked(sideboardLocked);
|
||||
ges.enqueueGameEvent(event, playerId);
|
||||
ges.setGameEventContext(Context_SetSideboardLock());
|
||||
|
||||
return Response::RespOk;
|
||||
}
|
||||
|
||||
Response::ResponseCode Server_Player::cmdConcede(const Command_Concede & /*cmd*/, ResponseContainer & /*rc*/, GameEventStorage &ges)
|
||||
{
|
||||
if (spectator)
|
||||
|
|
@ -1572,6 +1602,7 @@ Response::ResponseCode Server_Player::processGameCommand(const GameCommand &comm
|
|||
case GameCommand::MOVE_CARD: return cmdMoveCard(command.GetExtension(Command_MoveCard::ext), rc, ges); break;
|
||||
case GameCommand::SET_SIDEBOARD_PLAN: return cmdSetSideboardPlan(command.GetExtension(Command_SetSideboardPlan::ext), rc, ges); break;
|
||||
case GameCommand::DECK_SELECT: return cmdDeckSelect(command.GetExtension(Command_DeckSelect::ext), rc, ges); break;
|
||||
case GameCommand::SET_SIDEBOARD_LOCK: return cmdSetSideboardLock(command.GetExtension(Command_SetSideboardLock::ext), rc, ges); break;
|
||||
default: return Response::RespInvalidCommand;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ class Command_RevealCards;
|
|||
class Command_MoveCard;
|
||||
class Command_SetSideboardPlan;
|
||||
class Command_DeckSelect;
|
||||
class Command_SetSideboardLock;
|
||||
|
||||
class Server_Player : public Server_ArrowTarget {
|
||||
Q_OBJECT
|
||||
|
|
@ -76,6 +77,7 @@ private:
|
|||
int nextCardId;
|
||||
bool readyStart;
|
||||
bool conceded;
|
||||
bool sideboardLocked;
|
||||
public:
|
||||
mutable QMutex playerMutex;
|
||||
Server_Player(Server_Game *_game, int _playerId, const ServerInfo_User &_userInfo, bool _spectator, Server_AbstractUserInterface *_handler);
|
||||
|
|
@ -127,6 +129,7 @@ public:
|
|||
Response::ResponseCode cmdReadyStart(const Command_ReadyStart &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
||||
Response::ResponseCode cmdDeckSelect(const Command_DeckSelect &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
||||
Response::ResponseCode cmdSetSideboardPlan(const Command_SetSideboardPlan &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
||||
Response::ResponseCode cmdSetSideboardLock(const Command_SetSideboardLock &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
||||
Response::ResponseCode cmdGameSay(const Command_GameSay &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
||||
Response::ResponseCode cmdShuffle(const Command_Shuffle &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
||||
Response::ResponseCode cmdMulligan(const Command_Mulligan &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue