抓大鹅B3实现
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
2026-04-30 21:29:36 +08:00
parent 08815d98bc
commit 2f76367108
16 changed files with 279 additions and 81 deletions

View File

@@ -775,9 +775,7 @@ fn click_match3d_item_tx(
Ok(click_result(
status,
next,
confirmation
.accepted
.then_some(input.item_instance_id),
confirmation.accepted.then_some(input.item_instance_id),
confirmation.cleared_item_instance_ids,
))
}
@@ -790,6 +788,7 @@ fn stop_match3d_run_tx(
let stopped_at_ms = input.stopped_at_ms.max(current_server_ms(ctx));
let snapshot = deserialize_snapshot(&row.snapshot_json)?;
let domain_run = domain_snapshot_from_snapshot(&snapshot, &row.owner_user_id);
let domain_run = resolve_domain_run_timer_at(&domain_run, to_u64_ms(stopped_at_ms));
let domain_run = stop_domain_run_at(&domain_run, "match3d-stop".to_string());
let next = snapshot_from_domain(&domain_run, stopped_at_ms);
persist_snapshot(ctx, &row, &next, stopped_at_ms);
@@ -966,24 +965,22 @@ fn build_initial_run_snapshot(
seed,
domain_started_at_ms,
)
.unwrap_or_else(|_| {
DomainMatch3DRunSnapshot {
run_id: run_id.to_string(),
profile_id: work.profile_id.clone(),
owner_user_id: work.owner_user_id.clone(),
status: DomainMatch3DRunStatus::Running,
started_at_ms: domain_started_at_ms,
duration_limit_ms: MATCH3D_DEFAULT_DURATION_LIMIT_MS as u64,
remaining_ms: MATCH3D_DEFAULT_DURATION_LIMIT_MS as u64,
clear_count: work.clear_count.max(1),
total_item_count: work.clear_count.max(1).saturating_mul(3),
cleared_item_count: 0,
board_version: 1,
items: Vec::new(),
tray_slots: Vec::new(),
failure_reason: None,
last_confirmed_action_id: None,
}
.unwrap_or_else(|_| DomainMatch3DRunSnapshot {
run_id: run_id.to_string(),
profile_id: work.profile_id.clone(),
owner_user_id: work.owner_user_id.clone(),
status: DomainMatch3DRunStatus::Running,
started_at_ms: domain_started_at_ms,
duration_limit_ms: MATCH3D_DEFAULT_DURATION_LIMIT_MS as u64,
remaining_ms: MATCH3D_DEFAULT_DURATION_LIMIT_MS as u64,
clear_count: work.clear_count.max(1),
total_item_count: work.clear_count.max(1).saturating_mul(3),
cleared_item_count: 0,
board_version: 1,
items: Vec::new(),
tray_slots: Vec::new(),
failure_reason: None,
last_confirmed_action_id: None,
});
snapshot_from_domain(&domain_run, started_at_ms)
}
@@ -1256,10 +1253,7 @@ fn domain_config_from_snapshot(
)
}
fn snapshot_from_domain(
run: &DomainMatch3DRunSnapshot,
server_now_ms: i64,
) -> Match3DRunSnapshot {
fn snapshot_from_domain(run: &DomainMatch3DRunSnapshot, server_now_ms: i64) -> Match3DRunSnapshot {
Match3DRunSnapshot {
run_id: run.run_id.clone(),
profile_id: run.profile_id.clone(),
@@ -1278,7 +1272,10 @@ fn snapshot_from_domain(
.map(snapshot_tray_slot_from_domain)
.collect(),
items: run.items.iter().map(snapshot_item_from_domain).collect(),
failure_reason: run.failure_reason.map(domain_failure_to_text).map(str::to_string),
failure_reason: run
.failure_reason
.map(domain_failure_to_text)
.map(str::to_string),
}
}
@@ -1298,7 +1295,11 @@ fn domain_snapshot_from_snapshot(
total_item_count: snapshot.total_item_count,
cleared_item_count: snapshot.cleared_item_count,
board_version: snapshot.snapshot_version as u64,
items: snapshot.items.iter().map(domain_item_from_snapshot).collect(),
items: snapshot
.items
.iter()
.map(domain_item_from_snapshot)
.collect(),
tray_slots: snapshot
.tray_slots
.iter()
@@ -1627,14 +1628,12 @@ mod tests {
assert!(confirmation.accepted);
assert_eq!(confirmation.cleared_item_instance_ids.len(), 3);
assert!(
next
.tray_slots
next.tray_slots
.iter()
.all(|slot| slot.item_instance_id.is_none())
);
assert!(
next
.items
next.items
.iter()
.all(|item| item.state == MATCH3D_ITEM_CLEARED)
);