Skip to content

Commit 0836d29

Browse files
committed
[arenabuddy] fix issues with parsing mulligans
1 parent 49c370e commit 0836d29

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

arenabuddy/arenabuddy/src/app/components/mulligan_display.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ fn MulliganCard(mulligan: Mulligan) -> Element {
8585

8686
fn get_decision_class(decision: &str) -> &'static str {
8787
match decision {
88-
"keep" => "bg-emerald-900/40 text-emerald-300",
89-
"mulligan" => "bg-red-900/40 text-red-300",
88+
"Keep" => "bg-emerald-900/40 text-emerald-300",
89+
"Mulligan" => "bg-red-900/40 text-red-300",
9090
_ => "bg-gray-700 text-gray-300",
9191
}
9292
}

arenabuddy/core/src/player_log/replay.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,10 @@ impl MatchReplay {
247247
}
248248
})?;
249249

250-
let mulligan_responses: BTreeMap<i32, &MulliganRespWrapper> = self
250+
let mulligan_responses: Vec<&MulliganRespWrapper> = self
251251
.client_messages_iter()
252252
.filter_map(|client_message| match &client_message.payload {
253-
ClientMessage::MulliganResp(wrapper) => Some((wrapper.meta.game_state_id?, wrapper)),
253+
ClientMessage::MulliganResp(wrapper) => Some(wrapper),
254254
_ => None,
255255
})
256256
.collect();
@@ -268,9 +268,10 @@ impl MatchReplay {
268268
Ok(opening_hands
269269
.into_iter()
270270
.zip(mulligan_requests)
271-
.filter_map(|((gn, hand), (gn2, mulligan_request))| {
271+
.enumerate()
272+
.filter_map(|(i, ((gn, hand), (gn2, mulligan_request)))| {
272273
if gn != gn2 {
273-
warn!("invalid mulilgan data for {}", self.match_id);
274+
warn!("invalid mulligan data for {}", self.match_id);
274275
return None;
275276
}
276277

@@ -282,12 +283,8 @@ impl MatchReplay {
282283
.collect::<Vec<String>>()
283284
.join(",");
284285

285-
let Some(game_state_id) = mulligan_request.meta.game_state_id else {
286-
warn!("No game state ID found for mulligan request");
287-
return None;
288-
};
289286
let number_to_keep = DEFAULT_HAND_SIZE - mulligan_request.mulligan_req.mulligan_count;
290-
let decision = match mulligan_responses.get(&game_state_id) {
287+
let decision = match mulligan_responses.get(i) {
291288
Some(mulligan_response) => match mulligan_response.mulligan_resp.decision {
292289
MulliganOption::AcceptHand => "Keep",
293290
MulliganOption::Mulligan => "Mulligan",

arenabuddy/data/src/db/postgres.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ impl PostgresMatchDB {
412412
COUNT(CASE WHEN mr.winning_team_id = m.controller_seat_id THEN 1 END) AS wins,
413413
COUNT(CASE WHEN mr.winning_team_id != m.controller_seat_id THEN 1 END) AS losses
414414
FROM match m
415-
JOIN mulligan mul ON m.id = mul.match_id AND mul.decision = 'keep'
415+
JOIN mulligan mul ON m.id = mul.match_id AND mul.decision = 'Keep'
416416
AND mul.play_draw IN ('Play', 'Draw')
417417
JOIN match_result mr ON m.id = mr.match_id AND mr.result_scope = 'MatchScope_Game' AND mr.game_number = mul.game_number
418418
WHERE ($1::uuid IS NULL OR m.user_id = $1)
@@ -454,7 +454,7 @@ impl PostgresMatchDB {
454454
COUNT(CASE WHEN mr.winning_team_id = m.controller_seat_id THEN 1 END) AS wins,
455455
COUNT(CASE WHEN mr.winning_team_id != m.controller_seat_id THEN 1 END) AS losses
456456
FROM match m
457-
JOIN mulligan mul ON m.id = mul.match_id AND mul.decision = 'keep'
457+
JOIN mulligan mul ON m.id = mul.match_id AND mul.decision = 'Keep'
458458
JOIN match_result mr ON m.id = mr.match_id AND mr.result_scope = 'MatchScope_Game' AND mr.game_number = mul.game_number
459459
WHERE ($1::uuid IS NULL OR m.user_id = $1)
460460
GROUP BY mul.number_to_keep

0 commit comments

Comments
 (0)