protocol changes for drafting

This commit is contained in:
ebbit1q 2025-09-02 13:52:30 +02:00
parent 5381562a5e
commit c4026cd1ec
17 changed files with 212 additions and 2 deletions

View file

@ -21,6 +21,8 @@ set(PROTO_FILES
command_deck_upload.proto command_deck_upload.proto
command_del_counter.proto command_del_counter.proto
command_delete_arrow.proto command_delete_arrow.proto
command_draft_options_select.proto
command_draft_pick_select.proto
command_draw_cards.proto command_draw_cards.proto
command_dump_zone.proto command_dump_zone.proto
command_flip_card.proto command_flip_card.proto
@ -60,6 +62,7 @@ set(PROTO_FILES
context_ready_start.proto context_ready_start.proto
context_set_sideboard_lock.proto context_set_sideboard_lock.proto
context_undo_draw.proto context_undo_draw.proto
draft_options.proto
event_add_to_list.proto event_add_to_list.proto
event_attach_card.proto event_attach_card.proto
event_change_zone_properties.proto event_change_zone_properties.proto
@ -70,6 +73,8 @@ set(PROTO_FILES
event_del_counter.proto event_del_counter.proto
event_delete_arrow.proto event_delete_arrow.proto
event_destroy_card.proto event_destroy_card.proto
event_draft_pack.proto
event_draft_pick_select.proto
event_draw_cards.proto event_draw_cards.proto
event_dump_zone.proto event_dump_zone.proto
event_flip_card.proto event_flip_card.proto
@ -124,6 +129,8 @@ set(PROTO_FILES
response_deck_download.proto response_deck_download.proto
response_deck_list.proto response_deck_list.proto
response_deck_upload.proto response_deck_upload.proto
response_draft_deck_invalid.proto
response_draft_pick_selection_invalid.proto
response_dump_zone.proto response_dump_zone.proto
response_forgotpasswordrequest.proto response_forgotpasswordrequest.proto
response_get_admin_notes.proto response_get_admin_notes.proto

View file

@ -0,0 +1,11 @@
syntax = "proto2";
import "game_commands.proto";
import "draft_options.proto";
// Sends the options to use to draft before the draft starts.
message Command_DraftOptionsSelect {
extend GameCommand {
optional Command_DraftOptionsSelect ext = 1035;
}
optional Draft_Options options = 1;
}

View file

@ -0,0 +1,19 @@
syntax = "proto2";
import "game_commands.proto";
// Confirms the previously sent actions to the server and signals the next pack.
message Command_DraftPickSelect {
extend GameCommand {
optional Command_DraftPickSelect ext = 1036;
}
// Index in the sequence of pick selections made, important to keep track of in case the pack is invalidated with a
// new one by the server during transit.
optional sint32 selection_index = 1 [default = -1];
// Confirms that the player desires to leave an unexpected amount of cards in the pack
optional bool is_overpicking = 2;
// Confirms that the player desires to place cards into the pack
optional bool is_returning = 3;
}

View file

@ -50,4 +50,7 @@ message Command_MoveCard {
// Inverts the x coordinate to apply from the end of the target zone instead of the start // Inverts the x coordinate to apply from the end of the target zone instead of the start
optional bool is_reversed = 8 [default = false]; optional bool is_reversed = 8 [default = false];
// During a draft this is the index of the pick selection
optional sint32 draft_selection_index = 9 [default = -1];
} }

View file

@ -0,0 +1,66 @@
syntax = "proto2";
import "command_deck_select.proto";
// Types of draft gamemodes available
enum Draft_Type {
Booster_Draft = 1;
Sealed = 2;
}
// Container for options related to drafting shared in the game state
message Draft_Options {
// The draft gamemode
optional Draft_Type type = 1;
// The cards to draft from as cockatrice decklist
optional string draft_list = 2;
// The cards to draft from as a decklist stored on the server
optional sint32 draft_list_id = 3 [default = -1];
// The cards that can be freely added to the deck before deck submission as cockatrice decklist
optional string addable_card_list = 4;
// The cards that can be freely added to the deck before deck submission as a decklist stored on the server
optional sint32 addable_card_list_id = 5 [default = -1];
// The amount of cards in each pack when using a cube, for example this is commonly 15 in boosterdrafts
optional uint32 cards_per_pack = 6;
// The amount of packs that will be drafted by each player when using a cube, for example this is commonly 3 in
// boosterdrafts
optional uint32 packs_per_player = 7;
// The minimum amount of cards in the mainboard of submitted decklists, often 40, -1 means any size
optional sint32 minimum_deck_size = 8 [default = -1];
// The amount of cards to pick every time a pack is passed, usually 1
optional uint32 picks_per_selection = 9 [default = 1];
// The amount of cards picked for removal every time a pack is passed, usually 0
optional uint32 burns_per_selection = 10;
// Amount of seconds before the server will decide picks automatically, -1 means no limit
optional sint32 selection_timer = 11 [default = -1];
// Amount of pick selections that can be made without having to wait on other players, this means that the slowest
// player can never have more than this amount of packs waiting for them and the fastest player can never be more
// than this amount of pick selections ahead of the slowest player, -1 means to never wait, 0 means to wait for all
// players to confirm their picks before showing the next pack
optional sint32 max_selections_ahead = 12 [default = -1];
// Amount of new packs that can be opened without having to wait on other players, only after all that player's pick
// selections in the current round of opened packs are finished can a new pack be opened, -1 means to never wait, 0
// means to wait for all players to finish their packs before showing the next pack when the player finished all
// picks
optional sint32 max_new_packs_ahead = 13 [default = -1];
// Allow players to interact using normal card actions on a table zone
optional bool enable_table = 32;
// Allow players to take more or less cards from packs with confirmation
optional bool enable_overpicking = 33;
// Allow players to return cards back into a pack with confirmation
optional bool enable_returning = 34;
}

View file

@ -0,0 +1,16 @@
syntax = "proto2";
import "game_event.proto";
import "serverinfo_card.proto";
// Sent out by the server when a new pack is available, implicitly signals the start of the round timer
message Event_DraftPack {
extend GameEvent {
optional Event_DraftPack ext = 2022;
}
// Index in the sequence of pick selections made
optional sint32 selection_index = 1 [default = -1];
// sequence of cards in the pack by index
repeated ServerInfo_Card cards = 2;
}

View file

@ -0,0 +1,27 @@
syntax = "proto2";
import "game_event.proto";
// Sent by the server to confirm a player's picks that round
message Event_DraftPickSelect {
extend GameEvent {
optional Event_DraftPickSelect ext = 2023;
}
// Index in the sequence of pick selections made
optional sint32 selection_index = 1 [default = -1];
// Amount of cards picked
optional sint32 picked_cards = 2 [default = -1];
// Amount of cards picked to destroy
optional sint32 burned_cards = 3 [default = -1];
// Amount of cards placed into the pack
optional sint32 returned_cards = 4 [default = -1];
// Amount of cards in the pack after picks
optional sint32 remaining_cards = 5 [default = -1];
// Next player receiving the pack
optional sint32 passed_to_user_id = 6 [default = -1];
}

View file

@ -1,6 +1,7 @@
syntax = "proto2"; syntax = "proto2";
import "game_event.proto"; import "game_event.proto";
import "serverinfo_player.proto"; import "serverinfo_player.proto";
import "draft_options.proto";
// Signals that the game state has changed. // Signals that the game state has changed.
// If a field is present in this message, it will overwrite the client's game state. // If a field is present in this message, it will overwrite the client's game state.
@ -10,7 +11,7 @@ message Event_GameStateChanged {
optional Event_GameStateChanged ext = 1005; optional Event_GameStateChanged ext = 1005;
} }
// the list of players. Players contain their zones which contain all cards in the game // The list of players. Players contain their zones which contain all cards in the game
repeated ServerInfo_Player player_list = 1; repeated ServerInfo_Player player_list = 1;
// if the game has started // if the game has started
@ -24,4 +25,7 @@ message Event_GameStateChanged {
// the amount of seconds since the game started // the amount of seconds since the game started
optional uint32 seconds_elapsed = 5; optional uint32 seconds_elapsed = 5;
// the options for the draft if this is a draft game
optional Draft_Options options = 6;
} }

View file

@ -45,4 +45,7 @@ message Event_MoveCard {
// The provider id of the card in case it was not known yet. // 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. // Extends the name to supply a specific printing of that type of card.
optional string new_card_provider_id = 12; optional string new_card_provider_id = 12;
// During a draft this is the index of the pick selection
optional sint32 draft_selection_index = 13 [default = -1];
} }

View file

@ -38,6 +38,8 @@ message GameCommand {
UNCONCEDE = 1032; UNCONCEDE = 1032;
JUDGE = 1033; JUDGE = 1033;
REVERSE_TURN = 1034; REVERSE_TURN = 1034;
DRAFT_OPTIONS_SELECT = 1035;
DRAFT_PICK_SELECT = 1036;
} }
extensions 100 to max; extensions 100 to max;
} }

View file

@ -33,6 +33,8 @@ 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;
DRAFT_PACK = 2022;
DRAFT_PICK_SELECT = 2023;
} }
optional sint32 player_id = 1 [default = -1]; optional sint32 player_id = 1 [default = -1];
extensions 100 to max; extensions 100 to max;

View file

@ -68,6 +68,8 @@ message Response {
REPLAY_LIST = 1100; REPLAY_LIST = 1100;
REPLAY_DOWNLOAD = 1101; REPLAY_DOWNLOAD = 1101;
REPLAY_GET_CODE = 1102; REPLAY_GET_CODE = 1102;
DRAFT_PICK_SELECTION_INVALID = 1200;
DRAFT_DECK_INVALID = 1201;
} }
required uint64 cmd_id = 1; required uint64 cmd_id = 1;
optional ResponseCode response_code = 2; optional ResponseCode response_code = 2;

View file

@ -0,0 +1,16 @@
syntax = "proto2";
import "response.proto";
// Sent in response to selecting a deck during a draft that does not meet the requirements. Clients are already aware of
// what the requirements are but the fields in this serve as an extra validation.
message Response_DraftDeckInvalid {
extend Response {
optional Response_DraftDeckInvalid ext = 1201;
}
// amount of cards that should be in the deck but aren't
optional uint32 missing_cards = 1;
// amount of cards that are in the deck but shouldn't
optional uint32 additional_cards = 2;
}

View file

@ -0,0 +1,20 @@
syntax = "proto2";
import "response.proto";
// Response sent to a draft pick selection command when it isn't following the draft options or didn't confirm it's
// actions. Clients are already aware of the options so the fields in this message just serve as an additional
// validation.
message Response_DraftPickSelectionInvalid {
extend Response {
optional Response_DraftPickSelectionInvalid ext = 1200;
}
// amount of picks performed that exceed the picks per selection, negative means too few picks were performed
optional sint32 too_many_picks = 1;
// amount of burns performed that exceed the burns per selection, negative means too few burns were performed
optional sint32 too_many_burns = 2;
// amount of cards that were returned to the pack
optional sint32 cards_returned_to_pack = 3;
}

View file

@ -69,6 +69,9 @@ message Command_CreateGame {
// share decklists with all players when selected // share decklists with all players when selected
optional bool share_decklists_on_load = 14; optional bool share_decklists_on_load = 14;
// if the game is a draft game
optional bool is_draft = 15;
} }
message Command_JoinGame { message Command_JoinGame {

View file

@ -53,4 +53,10 @@ message ServerInfo_Card {
// unique id of this kind of card, extends the name to specify a specific printing of a card // unique id of this kind of card, extends the name to specify a specific printing of a card
optional string provider_id = 17; optional string provider_id = 17;
// index of the selection this card was picked in
optional sint32 draft_pick_selection_index = 64 [default = -1];
// user that picked this card
optional sint32 draft_pick_by_user_id = 65 [default = -1];
} }

View file

@ -48,6 +48,9 @@ message ServerInfo_Game {
// decklists are sent to all players when loaded // decklists are sent to all players when loaded
optional bool share_decklists_on_load = 15; optional bool share_decklists_on_load = 15;
// the game is a draft game
optional bool is_draft = 16;
// the current player count // the current player count
optional uint32 player_count = 30; optional uint32 player_count = 30;
@ -60,6 +63,6 @@ message ServerInfo_Game {
// time that the game started at // time that the game started at
optional uint32 start_time = 51; optional uint32 start_time = 51;
// whether the game is closed. Closed games are finished and can't be interacted with // Whether the game is closed. Closed games are finished and can't be interacted with
optional bool closed = 52; optional bool closed = 52;
} }