allow tournament matches to start at any battle table
This commit is contained in:
+17
-21
@@ -953,13 +953,12 @@ static bool add_next_game_client(shared_ptr<Lobby> l) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool start_ep3_battle_table_game_if_ready(
|
static bool start_ep3_battle_table_game_if_ready(shared_ptr<Lobby> l, int16_t table_number) {
|
||||||
shared_ptr<Lobby> l, int16_t table_number, int16_t tournament_table_number) {
|
|
||||||
if (table_number < 0) {
|
if (table_number < 0) {
|
||||||
// Negative numbers are supposed to mean the client is not seated at a
|
// Negative numbers are supposed to mean the client is not seated at a
|
||||||
// table, so it's an error for this function to be called with a negative
|
// table, so it's an error for this function to be called with a negative
|
||||||
// table number
|
// table number
|
||||||
throw logic_error("negative table number");
|
throw runtime_error("negative table number");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Figure out which clients are at this table. If any client has declined, we
|
// Figure out which clients are at this table. If any client has declined, we
|
||||||
@@ -972,7 +971,7 @@ static bool start_ep3_battle_table_game_if_ready(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (c->card_battle_table_seat_number >= 4) {
|
if (c->card_battle_table_seat_number >= 4) {
|
||||||
throw logic_error("invalid seat number");
|
throw runtime_error("invalid seat number");
|
||||||
}
|
}
|
||||||
// Apparently this can actually happen; just prevent them from starting a
|
// Apparently this can actually happen; just prevent them from starting a
|
||||||
// battle if multiple players are in the same seat
|
// battle if multiple players are in the same seat
|
||||||
@@ -992,18 +991,16 @@ static bool start_ep3_battle_table_game_if_ready(
|
|||||||
|
|
||||||
// Figure out if this is a tournament match setup
|
// Figure out if this is a tournament match setup
|
||||||
unordered_set<shared_ptr<Episode3::Tournament::Match>> tourn_matches;
|
unordered_set<shared_ptr<Episode3::Tournament::Match>> tourn_matches;
|
||||||
if (table_number == tournament_table_number) {
|
for (const auto& it : table_clients) {
|
||||||
for (const auto& it : table_clients) {
|
auto team = it.second->ep3_tournament_team.lock();
|
||||||
auto team = it.second->ep3_tournament_team.lock();
|
auto tourn = team ? team->tournament.lock() : nullptr;
|
||||||
auto tourn = team ? team->tournament.lock() : nullptr;
|
auto match = tourn ? tourn->next_match_for_team(team) : nullptr;
|
||||||
auto match = tourn ? tourn->next_match_for_team(team) : nullptr;
|
// Note: We intentionally don't check for null here. This is to handle the
|
||||||
// Note: We intentionally don't check for null here. This is to handle the
|
// case where a tournament-registered player steps into a seat at a table
|
||||||
// case where a tournament-registered player steps into a seat at a table
|
// where a non-tournament-registered player is already present - we should
|
||||||
// where a non-tournament-registered player is already present - we should
|
// NOT start any match until the non-tournament-registered player leaves,
|
||||||
// NOT start any match until the non-tournament-registered player leaves,
|
// or they both accept (and we start a non-tournament match).
|
||||||
// or they both accept (and we start a non-tournament match).
|
tourn_matches.emplace(match);
|
||||||
tourn_matches.emplace(match);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the tournament. Invariant: both tourn_match and tourn are null, or
|
// Get the tournament. Invariant: both tourn_match and tourn are null, or
|
||||||
@@ -1140,7 +1137,7 @@ static bool start_ep3_battle_table_game_if_ready(
|
|||||||
|
|
||||||
static void on_ep3_battle_table_state_updated(shared_ptr<Lobby> l, int16_t table_number) {
|
static void on_ep3_battle_table_state_updated(shared_ptr<Lobby> l, int16_t table_number) {
|
||||||
send_ep3_card_battle_table_state(l, table_number);
|
send_ep3_card_battle_table_state(l, table_number);
|
||||||
start_ep3_battle_table_game_if_ready(l, table_number, 2);
|
start_ep3_battle_table_game_if_ready(l, table_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_E4_Ep3(shared_ptr<Client> c, uint16_t, uint32_t flag, const string& data) {
|
static void on_E4_Ep3(shared_ptr<Client> c, uint16_t, uint32_t flag, const string& data) {
|
||||||
@@ -2056,10 +2053,9 @@ static void on_10(shared_ptr<Client> c, uint16_t, uint32_t, const string& data)
|
|||||||
tourn->send_all_state_updates();
|
tourn->send_all_state_updates();
|
||||||
string message = string_printf("$C7You are registered in $C6%s$C7.\n\
|
string message = string_printf("$C7You are registered in $C6%s$C7.\n\
|
||||||
\n\
|
\n\
|
||||||
After registration ends, start your matches by\n\
|
After the tournament begins, start your matches\n\
|
||||||
standing at the 4-player Battle Table near the\n\
|
by standing at any Battle Table along with your\n\
|
||||||
lobby warp in the lobby along with your partner\n\
|
partner (if any) and opponent(s).",
|
||||||
(if any) and opponent(s).",
|
|
||||||
tourn->get_name().c_str());
|
tourn->get_name().c_str());
|
||||||
send_ep3_timed_message_box(c->channel, 240, message.c_str());
|
send_ep3_timed_message_box(c->channel, 240, message.c_str());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user