Turn Card, Deck_List, Protocol, RNG, Network (Client, Server), Settings and Utility into libraries and remove cockatrice_common. (#6212)

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
Co-authored-by: ebbit1q <ebbit1q@gmail.com>
This commit is contained in:
BruebachL 2025-10-09 07:36:12 +02:00 committed by GitHub
parent be1403c920
commit 1ef07309d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
605 changed files with 3812 additions and 3408 deletions

View file

@ -0,0 +1,28 @@
# Top-level wrapper for the protobuf library
add_subdirectory(libcockatrice/protocol/pb)
add_library(libcockatrice_protocol STATIC)
set(SOURCES libcockatrice/protocol/debug_pb_message.cpp libcockatrice/protocol/featureset.cpp
libcockatrice/protocol/get_pb_extension.cpp libcockatrice/protocol/pending_command.cpp
)
set(HEADERS libcockatrice/protocol/debug_pb_message.h libcockatrice/protocol/featureset.h
libcockatrice/protocol/get_pb_extension.h libcockatrice/protocol/pending_command.h
)
target_sources(libcockatrice_protocol PRIVATE ${SOURCES} ${HEADERS})
add_dependencies(libcockatrice_protocol libcockatrice_protocol_pb)
# Link the actual generated protobuf library
target_link_libraries(
libcockatrice_protocol PUBLIC ${COCKATRICE_QT_MODULES} libcockatrice_protocol_pb libcockatrice_utility
)
# Expose include paths
target_include_directories(
libcockatrice_protocol PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR} # points to the generated headers
)

View file

@ -0,0 +1,106 @@
#include "debug_pb_message.h"
#include <QList>
#include <QString>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/message.h>
#include <google/protobuf/text_format.h>
#include <libcockatrice/utility/trice_limits.h>
// FastFieldValuePrinter is added in protobuf 3.4, going out of our way to add the old FieldValuePrinter is not worth it
#if GOOGLE_PROTOBUF_VERSION > 3004000
// value printer to use for all values, will snip too long contents
class LimitedPrinter : public ::google::protobuf::TextFormat::FastFieldValuePrinter
{
public:
void PrintString(const std::string &val,
::google::protobuf::TextFormat::BaseTextGenerator *generator) const override;
};
// value printer to use for specifc values, will expunge sensitive info
class SafePrinter : public ::google::protobuf::TextFormat::FastFieldValuePrinter
{
public:
void PrintString(const std::string &val,
::google::protobuf::TextFormat::BaseTextGenerator *generator) const override;
static void applySafePrinter(const ::google::protobuf::Message &message,
::google::protobuf::TextFormat::Printer &printer);
};
void LimitedPrinter::PrintString(const std::string &val,
::google::protobuf::TextFormat::BaseTextGenerator *generator) const
{
auto length = val.length();
if (length > MAX_TEXT_LENGTH) {
::google::protobuf::TextFormat::FastFieldValuePrinter::PrintString(
val.substr(0, MAX_NAME_LENGTH) + "... ---snip--- (" + std::to_string(length) + " bytes total", generator);
} else {
::google::protobuf::TextFormat::FastFieldValuePrinter::PrintString(val, generator);
}
}
void SafePrinter::PrintString(const std::string & /*val*/,
::google::protobuf::TextFormat::BaseTextGenerator *generator) const
{
generator->PrintLiteral("\" ---value expunged--- \"");
}
void SafePrinter::applySafePrinter(const ::google::protobuf::Message &message,
::google::protobuf::TextFormat::Printer &printer)
{
const auto *reflection = message.GetReflection();
std::vector<const google::protobuf::FieldDescriptor *> fields;
reflection->ListFields(message, &fields);
for (const auto *field : fields) {
switch (field->cpp_type()) {
case ::google::protobuf::FieldDescriptor::CPPTYPE_STRING:
if (field->name().find("password") != std::string::npos) { // name contains password
auto *safePrinter = new SafePrinter();
if (!printer.RegisterFieldValuePrinter(field, safePrinter))
delete safePrinter; // in case safePrinter has not been taken ownership of
}
break;
case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE:
if (field->is_repeated()) {
for (int i = 0; i < reflection->FieldSize(message, field); ++i) {
applySafePrinter(reflection->GetRepeatedMessage(message, field, i), printer);
}
} else {
applySafePrinter(reflection->GetMessage(message, field), printer);
}
break;
default:
break;
}
}
}
#endif // GOOGLE_PROTOBUF_VERSION > 3004000
QString getSafeDebugString(const ::google::protobuf::Message &message)
{
#if GOOGLE_PROTOBUF_VERSION > 3001000
auto size = message.ByteSizeLong();
#else
auto size = message.ByteSize();
#endif
::google::protobuf::TextFormat::Printer printer;
printer.SetSingleLineMode(true); // compact mode
printer.SetExpandAny(true); // prints all fields
#if GOOGLE_PROTOBUF_VERSION > 3004000
// printer takes ownership of the LimitedPrinter and will delete it
printer.SetDefaultFieldValuePrinter(new LimitedPrinter());
// check field names an create SafePrinters for necessary fields
SafePrinter::applySafePrinter(message, printer);
#else
// removing passwords from debug output will only be supported on newer protobuf versions
printer.SetTruncateStringFieldLongerThan(MAX_TEXT_LENGTH);
#endif // GOOGLE_PROTOBUF_VERSION > 3004000
std::string debug_string;
printer.PrintToString(message, &debug_string);
return QString::number(size) + " bytes " + QString::fromStdString(debug_string);
}

View file

@ -0,0 +1,15 @@
#ifndef DEBUG_PB_MESSAGE_H
#define DEBUG_PB_MESSAGE_H
class QString;
namespace google
{
namespace protobuf
{
class Message;
}
} // namespace google
QString getSafeDebugString(const ::google::protobuf::Message &message);
#endif // DEBUG_PB_MESSAGE_H

View file

@ -0,0 +1,77 @@
#include "featureset.h"
#include <QDebug>
#include <QMap>
FeatureSet::FeatureSet()
{
}
QMap<QString, bool> FeatureSet::getDefaultFeatureList()
{
initalizeFeatureList(featureList);
return featureList;
}
void FeatureSet::initalizeFeatureList(QMap<QString, bool> &_featureList)
{
// default features [name], [is required to connect]
_featureList.insert("client_id", false);
_featureList.insert("client_ver", false);
_featureList.insert("feature_set", false);
_featureList.insert("user_ban_history", false);
_featureList.insert("room_chat_history", false);
_featureList.insert("client_warnings", false);
_featureList.insert("mod_log_lookup", false);
_featureList.insert("idle_client", false);
_featureList.insert("forgot_password", false);
_featureList.insert("websocket", false);
// featureList.insert("hashed_password_login", false);
// These are temp to force users onto a newer client
_featureList.insert("2.7.0_min_version", false);
_featureList.insert("2.8.0_min_version", false);
}
void FeatureSet::enableRequiredFeature(QMap<QString, bool> &_featureList, const QString &featureName)
{
if (_featureList.contains(featureName))
_featureList.insert(featureName, true);
}
void FeatureSet::disableRequiredFeature(QMap<QString, bool> &_featureList, const QString &featureName)
{
if (_featureList.contains(featureName))
_featureList.insert(featureName, false);
}
QMap<QString, bool>
FeatureSet::addFeature(QMap<QString, bool> &_featureList, const QString &featureName, bool isFeatureRequired)
{
_featureList.insert(featureName, isFeatureRequired);
return _featureList;
}
QMap<QString, bool> FeatureSet::identifyMissingFeatures(const QMap<QString, bool> &suppliedFeatures,
QMap<QString, bool> requiredFeatures)
{
QMap<QString, bool> missingList;
QMap<QString, bool>::iterator i;
for (i = requiredFeatures.begin(); i != requiredFeatures.end(); ++i) {
if (!suppliedFeatures.contains(i.key())) {
missingList.insert(i.key(), i.value());
}
}
return missingList;
}
bool FeatureSet::isRequiredFeaturesMissing(const QMap<QString, bool> &suppliedFeatures,
QMap<QString, bool> requiredFeatures)
{
QMap<QString, bool>::iterator i;
for (i = requiredFeatures.begin(); i != requiredFeatures.end(); ++i) {
if (i.value() && suppliedFeatures.contains(i.key())) {
return true;
}
}
return false;
}

View file

@ -0,0 +1,28 @@
#ifndef FEATURESET_H
#define FEATURESET_H
#include <QMap>
#include <QObject>
#include <QSet>
#include <QString>
class FeatureSet : public QObject
{
public:
FeatureSet();
QMap<QString, bool> getDefaultFeatureList();
void initalizeFeatureList(QMap<QString, bool> &_featureList);
void enableRequiredFeature(QMap<QString, bool> &_featureList, const QString &featureName);
void disableRequiredFeature(QMap<QString, bool> &_featureList, const QString &featureName);
QMap<QString, bool>
addFeature(QMap<QString, bool> &_featureList, const QString &featureName, bool isFeatureRequired);
QMap<QString, bool> identifyMissingFeatures(const QMap<QString, bool> &featureListToCheck,
QMap<QString, bool> featureListToCompareTo);
bool isRequiredFeaturesMissing(const QMap<QString, bool> &featureListToCheck,
QMap<QString, bool> featureListToCompareTo);
private:
QMap<QString, bool> featureList;
};
#endif // FEEATURESET_H

View file

@ -0,0 +1,14 @@
#include "get_pb_extension.h"
#include <google/protobuf/descriptor.h>
#include <google/protobuf/message.h>
int getPbExtension(const ::google::protobuf::Message &message)
{
std::vector<const ::google::protobuf::FieldDescriptor *> fieldList;
message.GetReflection()->ListFields(message, &fieldList);
for (unsigned int j = 0; j < fieldList.size(); ++j)
if (fieldList[j]->is_extension())
return fieldList[j]->number();
return -1;
}

View file

@ -0,0 +1,14 @@
#ifndef GET_PB_EXTENSION_H
#define GET_PB_EXTENSION_H
namespace google
{
namespace protobuf
{
class Message;
}
} // namespace google
int getPbExtension(const ::google::protobuf::Message &message);
#endif

View file

@ -0,0 +1,197 @@
# CMakeLists for common directory
#
# provides the protobuf interfaces
set(PROTO_FILES
admin_commands.proto
card_attributes.proto
color.proto
command_attach_card.proto
command_change_zone_properties.proto
command_concede.proto
command_create_arrow.proto
command_create_counter.proto
command_create_token.proto
command_deck_del.proto
command_deck_del_dir.proto
command_deck_download.proto
command_deck_list.proto
command_deck_new_dir.proto
command_deck_select.proto
command_deck_upload.proto
command_del_counter.proto
command_delete_arrow.proto
command_draw_cards.proto
command_dump_zone.proto
command_flip_card.proto
command_game_say.proto
command_inc_card_counter.proto
command_inc_counter.proto
command_kick_from_game.proto
command_leave_game.proto
command_move_card.proto
command_mulligan.proto
command_next_turn.proto
command_ready_start.proto
command_replay_delete_match.proto
command_replay_download.proto
command_replay_get_code.proto
command_replay_list.proto
command_replay_modify_match.proto
command_replay_submit_code.proto
command_reveal_cards.proto
command_reverse_turn.proto
command_roll_die.proto
command_set_active_phase.proto
command_set_card_attr.proto
command_set_card_counter.proto
command_set_counter.proto
command_set_sideboard_lock.proto
command_set_sideboard_plan.proto
command_shuffle.proto
command_undo_draw.proto
commands.proto
context_concede.proto
context_connection_state_changed.proto
context_deck_select.proto
context_move_card.proto
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
event_change_zone_properties.proto
event_connection_closed.proto
event_create_arrow.proto
event_create_counter.proto
event_create_token.proto
event_del_counter.proto
event_delete_arrow.proto
event_destroy_card.proto
event_draw_cards.proto
event_dump_zone.proto
event_flip_card.proto
event_game_closed.proto
event_game_host_changed.proto
event_game_joined.proto
event_game_say.proto
event_game_state_changed.proto
event_game_state_changed.proto
event_join.proto
event_join_room.proto
event_kicked.proto
event_leave.proto
event_leave_room.proto
event_list_games.proto
event_list_rooms.proto
event_move_card.proto
event_notify_user.proto
event_player_properties_changed.proto
event_remove_from_list.proto
event_remove_messages.proto
event_replay_added.proto
event_reveal_cards.proto
event_reverse_turn.proto
event_roll_die.proto
event_room_say.proto
event_server_complete_list.proto
event_server_identification.proto
event_server_message.proto
event_server_shutdown.proto
event_set_active_phase.proto
event_set_active_player.proto
event_set_card_attr.proto
event_set_card_counter.proto
event_set_counter.proto
event_shuffle.proto
event_user_joined.proto
event_user_left.proto
event_user_message.proto
game_commands.proto
game_event.proto
game_event_container.proto
game_event_context.proto
game_replay.proto
isl_message.proto
moderator_commands.proto
move_card_to_zone.proto
response.proto
response_activate.proto
response_adjust_mod.proto
response_ban_history.proto
response_deck_download.proto
response_deck_list.proto
response_deck_upload.proto
response_dump_zone.proto
response_forgotpasswordrequest.proto
response_get_admin_notes.proto
response_get_games_of_user.proto
response_get_user_info.proto
response_join_room.proto
response_list_users.proto
response_login.proto
response_password_salt.proto
response_register.proto
response_replay_download.proto
response_replay_get_code.proto
response_replay_list.proto
response_viewlog_history.proto
response_warn_history.proto
response_warn_list.proto
room_commands.proto
room_event.proto
server_message.proto
serverinfo_arrow.proto
serverinfo_ban.proto
serverinfo_card.proto
serverinfo_cardcounter.proto
serverinfo_chat_message.proto
serverinfo_counter.proto
serverinfo_deckstorage.proto
serverinfo_game.proto
serverinfo_gametype.proto
serverinfo_player.proto
serverinfo_playerping.proto
serverinfo_playerproperties.proto
serverinfo_replay.proto
serverinfo_replay_match.proto
serverinfo_room.proto
serverinfo_user.proto
serverinfo_warning.proto
serverinfo_zone.proto
session_commands.proto
session_event.proto
)
if(${Protobuf_VERSION} VERSION_LESS "3.21.0.0")
message(STATUS "Using Protobuf Legacy Mode")
include_directories(${PROTOBUF_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTO_FILES})
add_library(libcockatrice_protocol_pb ${PROTO_SRCS} ${PROTO_HDRS})
set(libcockatrice_protocol_pb_LIBS ${PROTOBUF_LIBRARIES})
if(UNIX)
set(libcockatrice_protocol_pb_LIBS ${libcockatrice_protocol_pb_LIBS} -lpthread)
endif(UNIX)
target_link_libraries(libcockatrice_protocol_pb ${libcockatrice_protocol_pb_LIBS})
# ubuntu uses an outdated package for protobuf, 3.1.0 is required
if(${Protobuf_VERSION} VERSION_LESS "3.1.0")
# remove unused parameter and misleading indentation warnings when compiling to avoid errors
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-unused-parameter -Wno-misleading-indentation")
message(WARNING "Older protobuf version found (${Protobuf_VERSION} < 3.1.0), "
"disabled the warnings 'unused-parameter' and 'misleading-indentation' for protobuf generated code "
"to avoid compilation errors."
)
endif()
else()
add_library(libcockatrice_protocol_pb ${PROTO_FILES})
target_link_libraries(libcockatrice_protocol_pb PUBLIC protobuf::libprotobuf)
set(PROTO_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
target_include_directories(libcockatrice_protocol_pb PUBLIC "${PROTOBUF_INCLUDE_DIRS}")
protobuf_generate(TARGET libcockatrice_protocol_pb IMPORT_DIRS "." PROTOC_OUT_DIR "${PROTO_BINARY_DIR}")
endif()

View file

@ -0,0 +1,39 @@
syntax = "proto2";
message AdminCommand {
enum AdminCommandType {
UPDATE_SERVER_MESSAGE = 1000;
SHUTDOWN_SERVER = 1001;
RELOAD_CONFIG = 1002;
ADJUST_MOD = 1003;
}
extensions 100 to max;
}
message Command_UpdateServerMessage {
extend AdminCommand {
optional Command_UpdateServerMessage ext = 1000;
}
}
message Command_ShutdownServer {
extend AdminCommand {
optional Command_ShutdownServer ext = 1001;
}
optional string reason = 1;
optional uint32 minutes = 2;
}
message Command_ReloadConfig {
extend AdminCommand {
optional Command_ReloadConfig ext = 1002;
}
}
message Command_AdjustMod {
extend AdminCommand {
optional Command_AdjustMod ext = 1003;
}
required string user_name = 1;
optional bool should_be_mod = 2;
optional bool should_be_judge = 3;
}

View file

@ -0,0 +1,10 @@
syntax = "proto2";
enum CardAttribute {
AttrTapped = 1;
AttrAttacking = 2;
AttrFaceDown = 3;
AttrColor = 4;
AttrPT = 5;
AttrAnnotation = 6;
AttrDoesntUntap = 7;
}

View file

@ -0,0 +1,16 @@
syntax = "proto2";
// Container for a 4 component color code
message color {
// the red component of the color, limited to 256 values
optional uint32 r = 1;
// the green component of the color, limited to 256 values
optional uint32 g = 2;
// the blue component of the color, limited to 256 values
optional uint32 b = 3;
// the opacity component of the color, limited to 256 values
optional uint32 a = 4;
}

View file

@ -0,0 +1,12 @@
syntax = "proto2";
import "game_commands.proto";
message Command_AttachCard {
extend GameCommand {
optional Command_AttachCard ext = 1009;
}
optional string start_zone = 1;
optional sint32 card_id = 2 [default = -1];
optional sint32 target_player_id = 3 [default = -1];
optional string target_zone = 4;
optional sint32 target_card_id = 5 [default = -1];
}

View file

@ -0,0 +1,14 @@
syntax = "proto2";
import "game_commands.proto";
message Command_ChangeZoneProperties {
extend GameCommand {
optional Command_ChangeZoneProperties ext = 1031;
}
optional string zone_name = 1;
// Reveal top card to all players.
optional bool always_reveal_top_card = 10;
// reveal top card to the owner.
optional bool always_look_at_top_card = 11;
}

View file

@ -0,0 +1,13 @@
syntax = "proto2";
import "game_commands.proto";
message Command_Concede {
extend GameCommand {
optional Command_Concede ext = 1017;
}
}
message Command_Unconcede {
extend GameCommand {
optional Command_Unconcede ext = 1032;
}
}

View file

@ -0,0 +1,30 @@
syntax = "proto2";
import "game_commands.proto";
import "color.proto";
// Command to draw an arrow from cards to either other cards or a player
message Command_CreateArrow {
extend GameCommand {
optional Command_CreateArrow ext = 1011;
}
// the player that has the card the arrow is drawn from
optional sint32 start_player_id = 1 [default = -1];
// the zone that the card the arrow is drawn from is in
optional string start_zone = 2;
// the id of the card that the arrow is drawn from
optional sint32 start_card_id = 3 [default = -1];
// the player that has the card the arrow is drawn to, or that the arrow is drawn to if not a card
optional sint32 target_player_id = 4 [default = -1];
// the zone that the card the arrow is drawn to is in, the player will be targeted if this is absent
optional string target_zone = 5;
// the id of the card that the arrow is drawn to, the player will be targeted if this is absent
optional sint32 target_card_id = 6 [default = -1];
// the color of the arrow
optional color arrow_color = 7;
}

View file

@ -0,0 +1,13 @@
syntax = "proto2";
import "game_commands.proto";
import "color.proto";
message Command_CreateCounter {
extend GameCommand {
optional Command_CreateCounter ext = 1019;
}
optional string counter_name = 1;
optional color counter_color = 2;
optional uint32 radius = 3;
optional sint32 value = 4;
}

View file

@ -0,0 +1,31 @@
syntax = "proto2";
import "game_commands.proto";
message Command_CreateToken {
enum TargetMode {
// Attach the target to the token
ATTACH_TO = 0;
// Transform the target into the token
TRANSFORM_INTO = 1;
}
extend GameCommand {
optional Command_CreateToken ext = 1010;
}
optional string zone = 1;
optional string card_name = 2;
optional string color = 3;
optional string pt = 4;
optional string annotation = 5;
optional bool destroy_on_zone_change = 6;
optional sint32 x = 7;
optional sint32 y = 8;
optional string target_zone = 9;
optional sint32 target_card_id = 10 [default = -1];
// What to do with the target card. Ignored if there is no target card.
optional TargetMode target_mode = 11;
optional string card_provider_id = 12;
optional bool face_down = 13;
}

View file

@ -0,0 +1,9 @@
syntax = "proto2";
import "session_commands.proto";
message Command_DeckDel {
extend SessionCommand {
optional Command_DeckDel ext = 1011;
}
optional sint32 deck_id = 1 [default = -1];
}

View file

@ -0,0 +1,9 @@
syntax = "proto2";
import "session_commands.proto";
message Command_DeckDelDir {
extend SessionCommand {
optional Command_DeckDelDir ext = 1010;
}
optional string path = 1;
}

View file

@ -0,0 +1,9 @@
syntax = "proto2";
import "session_commands.proto";
message Command_DeckDownload {
extend SessionCommand {
optional Command_DeckDownload ext = 1012;
}
optional sint32 deck_id = 1 [default = -1];
}

View file

@ -0,0 +1,8 @@
syntax = "proto2";
import "session_commands.proto";
message Command_DeckList {
extend SessionCommand {
optional Command_DeckList ext = 1008;
}
}

View file

@ -0,0 +1,10 @@
syntax = "proto2";
import "session_commands.proto";
message Command_DeckNewDir {
extend SessionCommand {
optional Command_DeckNewDir ext = 1009;
}
optional string path = 1;
optional string dir_name = 2;
}

View file

@ -0,0 +1,9 @@
syntax = "proto2";
import "game_commands.proto";
message Command_DeckSelect {
extend GameCommand {
optional Command_DeckSelect ext = 1029;
}
optional string deck = 1;
optional sint32 deck_id = 2 [default = -1];
}

View file

@ -0,0 +1,11 @@
syntax = "proto2";
import "session_commands.proto";
message Command_DeckUpload {
extend SessionCommand {
optional Command_DeckUpload ext = 1013;
}
optional string path = 1; // to upload a new deck
optional uint32 deck_id = 2; // to replace an existing deck
optional string deck_list = 3;
}

View file

@ -0,0 +1,8 @@
syntax = "proto2";
import "game_commands.proto";
message Command_DelCounter {
extend GameCommand {
optional Command_DelCounter ext = 1021;
}
optional sint32 counter_id = 1 [default = -1];
}

View file

@ -0,0 +1,8 @@
syntax = "proto2";
import "game_commands.proto";
message Command_DeleteArrow {
extend GameCommand {
optional Command_DeleteArrow ext = 1012;
}
optional sint32 arrow_id = 1 [default = -1];
}

View file

@ -0,0 +1,8 @@
syntax = "proto2";
import "game_commands.proto";
message Command_DrawCards {
extend GameCommand {
optional Command_DrawCards ext = 1006;
}
optional uint32 number = 1;
}

View file

@ -0,0 +1,11 @@
syntax = "proto2";
import "game_commands.proto";
message Command_DumpZone {
extend GameCommand {
optional Command_DumpZone ext = 1024;
}
optional sint32 player_id = 1 [default = -1];
optional string zone_name = 2;
optional sint32 number_cards = 3;
optional bool is_reversed = 4 [default = false];
}

View file

@ -0,0 +1,11 @@
syntax = "proto2";
import "game_commands.proto";
message Command_FlipCard {
extend GameCommand {
optional Command_FlipCard ext = 1008;
}
optional string zone = 1;
optional sint32 card_id = 2 [default = -1];
optional bool face_down = 3;
optional string pt = 4;
}

View file

@ -0,0 +1,8 @@
syntax = "proto2";
import "game_commands.proto";
message Command_GameSay {
extend GameCommand {
optional Command_GameSay ext = 1002;
}
optional string message = 1;
}

View file

@ -0,0 +1,11 @@
syntax = "proto2";
import "game_commands.proto";
message Command_IncCardCounter {
extend GameCommand {
optional Command_IncCardCounter ext = 1015;
}
optional string zone = 1;
optional sint32 card_id = 2 [default = -1];
optional sint32 counter_id = 3 [default = -1];
optional sint32 counter_delta = 4;
}

View file

@ -0,0 +1,9 @@
syntax = "proto2";
import "game_commands.proto";
message Command_IncCounter {
extend GameCommand {
optional Command_IncCounter ext = 1018;
}
optional sint32 counter_id = 1 [default = -1];
optional sint32 delta = 2;
}

View file

@ -0,0 +1,8 @@
syntax = "proto2";
import "game_commands.proto";
message Command_KickFromGame {
extend GameCommand {
optional Command_KickFromGame ext = 1000;
}
optional sint32 player_id = 1 [default = -1];
}

View file

@ -0,0 +1,7 @@
syntax = "proto2";
import "game_commands.proto";
message Command_LeaveGame {
extend GameCommand {
optional Command_LeaveGame ext = 1001;
}
}

View file

@ -0,0 +1,53 @@
syntax = "proto2";
import "game_commands.proto";
// Container describing a single card to move
message CardToMove {
// Id of the card in its current zone
optional sint32 card_id = 1 [default = -1];
// Places the card face down, hiding its name
optional bool face_down = 2;
// When moving add this value to the power/toughness field of the card
optional string pt = 3;
// When moving sets the card to be tapped
optional bool tapped = 4;
}
// Container of multiple cards to move
message ListOfCardsToMove {
repeated CardToMove card = 1;
}
// Command to move an amount of cards from one zone to another index/coordinate or another zone
message Command_MoveCard {
extend GameCommand {
optional Command_MoveCard ext = 1027;
}
// The player the zone the cards are in belongs to
optional sint32 start_player_id = 1 [default = -1];
// The zone the cards start in
optional string start_zone = 2;
// List of the cards and their new properties
optional ListOfCardsToMove cards_to_move = 3;
// The player the zone the cards will be moved to belongs to
optional sint32 target_player_id = 4 [default = -1];
// The zone the cards will be moved to
optional string target_zone = 5;
// New x coordinate of the first card in the list
optional sint32 x = 6 [default = -1];
// New y coordinate of the first card in the list
optional sint32 y = 7 [default = -1];
// Inverts the x coordinate to apply from the end of the target zone instead of the start
optional bool is_reversed = 8 [default = false];
}

View file

@ -0,0 +1,8 @@
syntax = "proto2";
import "game_commands.proto";
message Command_Mulligan {
extend GameCommand {
optional Command_Mulligan ext = 1004;
}
optional uint32 number = 7;
}

View file

@ -0,0 +1,7 @@
syntax = "proto2";
import "game_commands.proto";
message Command_NextTurn {
extend GameCommand {
optional Command_NextTurn ext = 1022;
}
}

View file

@ -0,0 +1,9 @@
syntax = "proto2";
import "game_commands.proto";
message Command_ReadyStart {
extend GameCommand {
optional Command_ReadyStart ext = 1016;
}
optional bool ready = 1;
optional bool force_start = 2;
}

View file

@ -0,0 +1,9 @@
syntax = "proto2";
import "session_commands.proto";
message Command_ReplayDeleteMatch {
extend SessionCommand {
optional Command_ReplayDeleteMatch ext = 1103;
}
optional sint32 game_id = 1 [default = -1];
}

View file

@ -0,0 +1,9 @@
syntax = "proto2";
import "session_commands.proto";
message Command_ReplayDownload {
extend SessionCommand {
optional Command_ReplayDownload ext = 1101;
}
optional sint32 replay_id = 1 [default = -1];
}

View file

@ -0,0 +1,9 @@
syntax = "proto2";
import "session_commands.proto";
message Command_ReplayGetCode {
extend SessionCommand {
optional Command_ReplayGetCode ext = 1104;
}
optional sint32 game_id = 1 [default = -1];
}

View file

@ -0,0 +1,8 @@
syntax = "proto2";
import "session_commands.proto";
message Command_ReplayList {
extend SessionCommand {
optional Command_ReplayList ext = 1100;
}
}

View file

@ -0,0 +1,10 @@
syntax = "proto2";
import "session_commands.proto";
message Command_ReplayModifyMatch {
extend SessionCommand {
optional Command_ReplayModifyMatch ext = 1102;
}
optional sint32 game_id = 1 [default = -1];
optional bool do_not_hide = 2;
}

View file

@ -0,0 +1,9 @@
syntax = "proto2";
import "session_commands.proto";
message Command_ReplaySubmitCode {
extend SessionCommand {
optional Command_ReplaySubmitCode ext = 1105;
}
optional string replay_code = 1;
}

View file

@ -0,0 +1,12 @@
syntax = "proto2";
import "game_commands.proto";
message Command_RevealCards {
extend GameCommand {
optional Command_RevealCards ext = 1026;
}
optional string zone_name = 1;
repeated sint32 card_id = 2 [packed = false];
optional sint32 player_id = 3 [default = -1];
optional bool grant_write_access = 4;
optional sint32 top_cards = 5 [default = -1];
}

View file

@ -0,0 +1,7 @@
syntax = "proto2";
import "game_commands.proto";
message Command_ReverseTurn {
extend GameCommand {
optional Command_ReverseTurn ext = 1034;
}
}

View file

@ -0,0 +1,9 @@
syntax = "proto2";
import "game_commands.proto";
message Command_RollDie {
extend GameCommand {
optional Command_RollDie ext = 1005;
}
optional uint32 sides = 1;
optional uint32 count = 2;
}

View file

@ -0,0 +1,8 @@
syntax = "proto2";
import "game_commands.proto";
message Command_SetActivePhase {
extend GameCommand {
optional Command_SetActivePhase ext = 1023;
}
optional uint32 phase = 1;
}

View file

@ -0,0 +1,13 @@
syntax = "proto2";
import "game_commands.proto";
import "card_attributes.proto";
message Command_SetCardAttr {
extend GameCommand {
optional Command_SetCardAttr ext = 1013;
}
optional string zone = 1;
optional sint32 card_id = 2 [default = -1];
optional CardAttribute attribute = 3;
optional string attr_value = 4;
}

View file

@ -0,0 +1,11 @@
syntax = "proto2";
import "game_commands.proto";
message Command_SetCardCounter {
extend GameCommand {
optional Command_SetCardCounter ext = 1014;
}
optional string zone = 1;
optional sint32 card_id = 2 [default = -1];
optional sint32 counter_id = 3 [default = -1];
optional sint32 counter_value = 4;
}

View file

@ -0,0 +1,9 @@
syntax = "proto2";
import "game_commands.proto";
message Command_SetCounter {
extend GameCommand {
optional Command_SetCounter ext = 1020;
}
optional sint32 counter_id = 1 [default = -1];
optional sint32 value = 2;
}

View file

@ -0,0 +1,8 @@
syntax = "proto2";
import "game_commands.proto";
message Command_SetSideboardLock {
extend GameCommand {
optional Command_SetSideboardLock ext = 1030;
}
optional bool locked = 1;
}

View file

@ -0,0 +1,10 @@
syntax = "proto2";
import "game_commands.proto";
import "move_card_to_zone.proto";
message Command_SetSideboardPlan {
extend GameCommand {
optional Command_SetSideboardPlan ext = 1028;
}
repeated MoveCard_ToZone move_list = 1;
}

View file

@ -0,0 +1,10 @@
syntax = "proto2";
import "game_commands.proto";
message Command_Shuffle {
extend GameCommand {
optional Command_Shuffle ext = 1003;
}
optional string zone_name = 1;
optional sint32 start = 2 [default = 0];
optional sint32 end = 3 [default = -1];
}

View file

@ -0,0 +1,7 @@
syntax = "proto2";
import "game_commands.proto";
message Command_UndoDraw {
extend GameCommand {
optional Command_UndoDraw ext = 1007;
}
}

View file

@ -0,0 +1,19 @@
syntax = "proto2";
import "session_commands.proto";
import "game_commands.proto";
import "room_commands.proto";
import "moderator_commands.proto";
import "admin_commands.proto";
message CommandContainer {
optional uint64 cmd_id = 1;
optional uint32 game_id = 10;
optional uint32 room_id = 20;
repeated SessionCommand session_command = 100;
repeated GameCommand game_command = 101;
repeated RoomCommand room_command = 102;
repeated ModeratorCommand moderator_command = 103;
repeated AdminCommand admin_command = 104;
}

View file

@ -0,0 +1,14 @@
syntax = "proto2";
import "game_event_context.proto";
message Context_Concede {
extend GameEventContext {
optional Context_Concede ext = 1001;
}
}
message Context_Unconcede {
extend GameEventContext {
optional Context_Unconcede ext = 1009;
}
}

View file

@ -0,0 +1,8 @@
syntax = "proto2";
import "game_event_context.proto";
message Context_ConnectionStateChanged {
extend GameEventContext {
optional Context_ConnectionStateChanged ext = 1007;
}
}

View file

@ -0,0 +1,11 @@
syntax = "proto2";
import "game_event_context.proto";
message Context_DeckSelect {
extend GameEventContext {
optional Context_DeckSelect ext = 1002;
}
optional string deck_hash = 1;
optional int32 sideboard_size = 2 [default = -1];
optional string deck_list = 3;
}

View file

@ -0,0 +1,8 @@
syntax = "proto2";
import "game_event_context.proto";
message Context_MoveCard {
extend GameEventContext {
optional Context_MoveCard ext = 1004;
}
}

View file

@ -0,0 +1,9 @@
syntax = "proto2";
import "game_event_context.proto";
message Context_Mulligan {
extend GameEventContext {
optional Context_Mulligan ext = 1005;
}
optional uint32 number = 1;
}

View file

@ -0,0 +1,8 @@
syntax = "proto2";
import "game_event_context.proto";
message Context_PingChanged {
extend GameEventContext {
optional Context_PingChanged ext = 1006;
}
}

View file

@ -0,0 +1,8 @@
syntax = "proto2";
import "game_event_context.proto";
message Context_ReadyStart {
extend GameEventContext {
optional Context_ReadyStart ext = 1000;
}
}

View file

@ -0,0 +1,8 @@
syntax = "proto2";
import "game_event_context.proto";
message Context_SetSideboardLock {
extend GameEventContext {
optional Context_SetSideboardLock ext = 1008;
}
}

View file

@ -0,0 +1,8 @@
syntax = "proto2";
import "game_event_context.proto";
message Context_UndoDraw {
extend GameEventContext {
optional Context_UndoDraw ext = 1003;
}
}

View file

@ -0,0 +1,11 @@
syntax = "proto2";
import "session_event.proto";
import "serverinfo_user.proto";
message Event_AddToList {
extend SessionEvent {
optional Event_AddToList ext = 1005;
}
optional string list_name = 1;
optional ServerInfo_User user_info = 2;
}

View file

@ -0,0 +1,13 @@
syntax = "proto2";
import "game_event.proto";
message Event_AttachCard {
extend GameEvent {
optional Event_AttachCard ext = 2012;
}
optional string start_zone = 1;
optional sint32 card_id = 2;
optional sint32 target_player_id = 3;
optional string target_zone = 4;
optional sint32 target_card_id = 5;
}

View file

@ -0,0 +1,14 @@
syntax = "proto2";
import "game_event.proto";
message Event_ChangeZoneProperties {
extend GameEvent {
optional Event_ChangeZoneProperties ext = 2020;
}
optional string zone_name = 1;
// Reveal top card to all players.
optional bool always_reveal_top_card = 10;
// reveal top card to the owner.
optional bool always_look_at_top_card = 11;
}

View file

@ -0,0 +1,21 @@
syntax = "proto2";
import "session_event.proto";
message Event_ConnectionClosed {
extend SessionEvent {
optional Event_ConnectionClosed ext = 1002;
}
enum CloseReason {
OTHER = 1;
SERVER_SHUTDOWN = 2;
TOO_MANY_CONNECTIONS = 3;
BANNED = 4;
USERNAMEINVALID = 5;
USER_LIMIT_REACHED = 6;
DEMOTED = 7;
LOGGEDINELSEWERE = 8;
}
optional CloseReason reason = 1;
optional string reason_str = 2;
optional uint32 end_time = 3;
}

View file

@ -0,0 +1,10 @@
syntax = "proto2";
import "game_event.proto";
import "serverinfo_arrow.proto";
message Event_CreateArrow {
extend GameEvent {
optional Event_CreateArrow ext = 2000;
}
optional ServerInfo_Arrow arrow_info = 1;
}

View file

@ -0,0 +1,10 @@
syntax = "proto2";
import "game_event.proto";
import "serverinfo_counter.proto";
message Event_CreateCounter {
extend GameEvent {
optional Event_CreateCounter ext = 2002;
}
optional ServerInfo_Counter counter_info = 1;
}

View file

@ -0,0 +1,19 @@
syntax = "proto2";
import "game_event.proto";
message Event_CreateToken {
extend GameEvent {
optional Event_CreateToken ext = 2013;
}
optional string zone_name = 1;
optional sint32 card_id = 2;
optional string card_name = 3;
optional string color = 4;
optional string pt = 5;
optional string annotation = 6;
optional bool destroy_on_zone_change = 7;
optional sint32 x = 8;
optional sint32 y = 9;
optional string card_provider_id = 10;
optional bool face_down = 11;
}

View file

@ -0,0 +1,9 @@
syntax = "proto2";
import "game_event.proto";
message Event_DelCounter {
extend GameEvent {
optional Event_DelCounter ext = 2004;
}
optional sint32 counter_id = 1;
}

View file

@ -0,0 +1,9 @@
syntax = "proto2";
import "game_event.proto";
message Event_DeleteArrow {
extend GameEvent {
optional Event_DeleteArrow ext = 2001;
}
optional sint32 arrow_id = 1;
}

View file

@ -0,0 +1,10 @@
syntax = "proto2";
import "game_event.proto";
message Event_DestroyCard {
extend GameEvent {
optional Event_DestroyCard ext = 2011;
}
optional string zone_name = 1;
optional uint32 card_id = 2;
}

View file

@ -0,0 +1,11 @@
syntax = "proto2";
import "game_event.proto";
import "serverinfo_card.proto";
message Event_DrawCards {
extend GameEvent {
optional Event_DrawCards ext = 2005;
}
optional sint32 number = 1;
repeated ServerInfo_Card cards = 2;
}

View file

@ -0,0 +1,12 @@
syntax = "proto2";
import "game_event.proto";
message Event_DumpZone {
extend GameEvent {
optional Event_DumpZone ext = 2018;
}
optional sint32 zone_owner_id = 1;
optional string zone_name = 2;
optional sint32 number_cards = 3;
optional bool is_reversed = 4 [default = false];
}

View file

@ -0,0 +1,13 @@
syntax = "proto2";
import "game_event.proto";
message Event_FlipCard {
extend GameEvent {
optional Event_FlipCard ext = 2010;
}
optional string zone_name = 1;
optional sint32 card_id = 2;
optional string card_name = 3;
optional bool face_down = 4;
optional string card_provider_id = 5;
}

View file

@ -0,0 +1,8 @@
syntax = "proto2";
import "game_event.proto";
message Event_GameClosed {
extend GameEvent {
optional Event_GameClosed ext = 1002;
}
}

View file

@ -0,0 +1,8 @@
syntax = "proto2";
import "game_event.proto";
message Event_GameHostChanged {
extend GameEvent {
optional Event_GameHostChanged ext = 1003;
}
}

View file

@ -0,0 +1,17 @@
syntax = "proto2";
import "session_event.proto";
import "serverinfo_game.proto";
import "serverinfo_gametype.proto";
message Event_GameJoined {
extend SessionEvent {
optional Event_GameJoined ext = 1009;
}
optional ServerInfo_Game game_info = 1;
repeated ServerInfo_GameType game_types = 2;
optional sint32 host_id = 3;
optional sint32 player_id = 4;
optional bool spectator = 5;
optional bool resuming = 6;
optional bool judge = 7;
}

View file

@ -0,0 +1,9 @@
syntax = "proto2";
import "game_event.proto";
message Event_GameSay {
extend GameEvent {
optional Event_GameSay ext = 1009;
}
optional string message = 1;
}

View file

@ -0,0 +1,27 @@
syntax = "proto2";
import "game_event.proto";
import "serverinfo_player.proto";
// Signals that the game state has changed.
// If a field is present in this message, it will overwrite the client's game state.
// Also used to provide the entire game state when joining a game.
message Event_GameStateChanged {
extend GameEvent {
optional Event_GameStateChanged ext = 1005;
}
// the list of players. Players contain their zones which contain all cards in the game
repeated ServerInfo_Player player_list = 1;
// if the game has started
optional bool game_started = 2;
// the player who is currently holding the turn
optional sint32 active_player_id = 3;
// the current phase
optional sint32 active_phase = 4;
// the amount of seconds since the game started
optional uint32 seconds_elapsed = 5;
}

View file

@ -0,0 +1,10 @@
syntax = "proto2";
import "game_event.proto";
import "serverinfo_playerproperties.proto";
message Event_Join {
extend GameEvent {
optional Event_Join ext = 1000;
}
optional ServerInfo_PlayerProperties player_properties = 1;
}

View file

@ -0,0 +1,10 @@
syntax = "proto2";
import "room_event.proto";
import "serverinfo_user.proto";
message Event_JoinRoom {
extend RoomEvent {
optional Event_JoinRoom ext = 1001;
}
optional ServerInfo_User user_info = 1;
}

View file

@ -0,0 +1,8 @@
syntax = "proto2";
import "game_event.proto";
message Event_Kicked {
extend GameEvent {
optional Event_Kicked ext = 1004;
}
}

View file

@ -0,0 +1,15 @@
syntax = "proto2";
import "game_event.proto";
message Event_Leave {
extend GameEvent {
optional Event_Leave ext = 1001;
}
enum LeaveReason {
OTHER = 1;
USER_KICKED = 2;
USER_LEFT = 3;
USER_DISCONNECTED = 4;
}
optional LeaveReason reason = 1;
}

View file

@ -0,0 +1,9 @@
syntax = "proto2";
import "room_event.proto";
message Event_LeaveRoom {
extend RoomEvent {
optional Event_LeaveRoom ext = 1000;
}
optional string name = 1;
}

View file

@ -0,0 +1,10 @@
syntax = "proto2";
import "room_event.proto";
import "serverinfo_game.proto";
message Event_ListGames {
extend RoomEvent {
optional Event_ListGames ext = 1003;
}
repeated ServerInfo_Game game_list = 1;
}

View file

@ -0,0 +1,10 @@
syntax = "proto2";
import "session_event.proto";
import "serverinfo_room.proto";
message Event_ListRooms {
extend SessionEvent {
optional Event_ListRooms ext = 1004;
}
repeated ServerInfo_Room room_list = 1;
}

View file

@ -0,0 +1,48 @@
syntax = "proto2";
import "game_event.proto";
// Sent by the server to signal a single card was moved to update the client state
message Event_MoveCard {
extend GameEvent {
optional Event_MoveCard ext = 2009;
}
// The card id in the original zone
optional sint32 card_id = 1 [default = -1];
// The name of the card in case it was not known yet
optional string card_name = 2;
// The player whose zone the card started in
optional sint32 start_player_id = 3 [default = -1];
// The original zone
optional string start_zone = 4;
// The original position that the card was at.
// In zones without y coordinate, this corresponds with the previous x coordinate of the card.
// In zones with y coordinate, this value is not used.
optional sint32 position = 5 [default = -1];
// The player who owns the new zone the card is in
optional sint32 target_player_id = 6 [default = -1];
// The new zone the card is in
optional string target_zone = 7;
// The new x coordinate (or new position for zones with no y coordinate)
optional sint32 x = 8 [default = -1];
// The new y coordinate
optional sint32 y = 9 [default = -1];
// The new id of the card if the card moved zone
optional sint32 new_card_id = 10 [default = -1];
// If the card is face down, face down cards will not show their name
optional bool face_down = 11;
// The provider id of the card in case it was not known yet.
// Extends the name to supply a specific printing of that type of card.
optional string new_card_provider_id = 12;
}

View file

@ -0,0 +1,21 @@
syntax = "proto2";
import "session_event.proto";
message Event_NotifyUser {
enum NotificationType {
UNKNOWN = 0; // Default enum value if no "type" is defined when used
PROMOTED = 1;
WARNING = 2;
IDLEWARNING = 3;
CUSTOM = 4;
}
extend SessionEvent {
optional Event_NotifyUser ext = 1010;
}
optional NotificationType type = 1;
optional string warning_reason = 2;
optional string custom_title = 3;
optional string custom_content = 4;
}

View file

@ -0,0 +1,10 @@
syntax = "proto2";
import "game_event.proto";
import "serverinfo_playerproperties.proto";
message Event_PlayerPropertiesChanged {
extend GameEvent {
optional Event_PlayerPropertiesChanged ext = 1007;
}
optional ServerInfo_PlayerProperties player_properties = 1;
}

View file

@ -0,0 +1,10 @@
syntax = "proto2";
import "session_event.proto";
message Event_RemoveFromList {
extend SessionEvent {
optional Event_RemoveFromList ext = 1006;
}
optional string list_name = 1;
optional string user_name = 2;
}

View file

@ -0,0 +1,10 @@
syntax = "proto2";
import "room_event.proto";
message Event_RemoveMessages {
extend RoomEvent {
optional Event_RemoveMessages ext = 1004;
}
optional string name = 1;
optional uint32 amount = 2;
}

View file

@ -0,0 +1,10 @@
syntax = "proto2";
import "session_event.proto";
import "serverinfo_replay_match.proto";
message Event_ReplayAdded {
extend SessionEvent {
optional Event_ReplayAdded ext = 1100;
}
optional ServerInfo_ReplayMatch match_info = 1;
}

View file

@ -0,0 +1,15 @@
syntax = "proto2";
import "game_event.proto";
import "serverinfo_card.proto";
message Event_RevealCards {
extend GameEvent {
optional Event_RevealCards ext = 2006;
}
optional string zone_name = 1;
repeated sint32 card_id = 2 [packed = false];
optional sint32 other_player_id = 3 [default = -1];
repeated ServerInfo_Card cards = 4;
optional bool grant_write_access = 5;
optional uint32 number_of_cards = 6;
}

View file

@ -0,0 +1,9 @@
syntax = "proto2";
import "game_event.proto";
message Event_ReverseTurn {
extend GameEvent {
optional Event_ReverseTurn ext = 2021;
}
optional bool reversed = 1;
}

View file

@ -0,0 +1,11 @@
syntax = "proto2";
import "game_event.proto";
message Event_RollDie {
extend GameEvent {
optional Event_RollDie ext = 2008;
}
optional uint32 sides = 1;
optional uint32 value = 2;
repeated uint32 values = 3;
}

View file

@ -0,0 +1,17 @@
syntax = "proto2";
import "room_event.proto";
message Event_RoomSay {
extend RoomEvent {
optional Event_RoomSay ext = 1002;
}
enum RoomMessageType {
UserMessage = 0; // user message
Welcome = 1; // rooms welcome message
ChatHistory = 2; // rooms chat history message
}
optional string name = 1;
optional string message = 2;
optional RoomMessageType message_type = 3;
optional uint64 time_of = 4;
}

Some files were not shown because too many files have changed in this diff Show more