update:对接节奏训练
This commit is contained in:
@@ -92,6 +92,8 @@ const rhythmServerTimestamp = ref(0);
|
||||
const rhythmFallbackWindowStart = ref(0);
|
||||
const rhythmFallbackTimestamp = ref(0);
|
||||
const rhythmHasActiveServerAnchor = ref(false);
|
||||
// 节奏训练目标箭数以服务端 total_arrows 为准;首帧缺失时用 arrows_left 初始化并保持稳定。
|
||||
const rhythmTargetArrows = ref(0);
|
||||
// 服务端状态立即落到 practiceInfo,精准训练的目标区域单独延迟展示。
|
||||
const visiblePrecisionTarget = ref({
|
||||
randomBlock: 0,
|
||||
@@ -416,7 +418,7 @@ const trainingCopy = computed(() => {
|
||||
}
|
||||
|
||||
if (trainingType.value === "rhythm") {
|
||||
const targetArrows = getPositiveInteger(total.value);
|
||||
const targetArrows = getPositiveInteger(rhythmTargetArrows.value);
|
||||
const arrowsLeft = Math.min(
|
||||
targetArrows,
|
||||
Math.max(
|
||||
@@ -494,6 +496,8 @@ const practiceInfoFields = [
|
||||
"deltaTotalArrows",
|
||||
"deltaAverageRing",
|
||||
"deltaStability",
|
||||
"tenRingCount",
|
||||
"deltaTenRingCount",
|
||||
"beforeExp",
|
||||
"beforeLevel",
|
||||
"currentExp",
|
||||
@@ -522,6 +526,8 @@ const practiceResultFields = [
|
||||
"deltaTotalArrows",
|
||||
"deltaAverageRing",
|
||||
"deltaStability",
|
||||
"tenRingCount",
|
||||
"deltaTenRingCount",
|
||||
"beforeExp",
|
||||
"beforeLevel",
|
||||
"currentExp",
|
||||
@@ -569,8 +575,31 @@ const cacheRhythmTrainingConfig = (message = {}) => {
|
||||
}
|
||||
};
|
||||
|
||||
const cacheRhythmTargetArrows = (message = {}) => {
|
||||
const messageTrainingType = String(
|
||||
message.trainingType ?? message.training_type ?? trainingType.value
|
||||
).trim();
|
||||
if (messageTrainingType !== "rhythm") return;
|
||||
|
||||
const totalArrows = getPositiveInteger(
|
||||
message.totalArrows ?? message.total_arrows
|
||||
);
|
||||
if (totalArrows > 0) {
|
||||
rhythmTargetArrows.value = totalArrows;
|
||||
return;
|
||||
}
|
||||
|
||||
// 兼容服务端首帧 total_arrows 暂为 0:只初始化一次,避免剩余数递减时分母跟着变化。
|
||||
if (rhythmTargetArrows.value === 0) {
|
||||
rhythmTargetArrows.value = getPositiveInteger(
|
||||
message.arrowsLeft ?? message.arrows_left
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const syncPracticeInfo = (message = {}) => {
|
||||
cacheRhythmTrainingConfig(message);
|
||||
cacheRhythmTargetArrows(message);
|
||||
const nextInfo = practiceInfoFields.reduce((result, field) => {
|
||||
if (Object.prototype.hasOwnProperty.call(message, field)) {
|
||||
result[field] = message[field];
|
||||
@@ -1427,6 +1456,7 @@ async function onRetry() {
|
||||
rhythmFallbackWindowStart.value = 0;
|
||||
rhythmFallbackTimestamp.value = 0;
|
||||
rhythmHasActiveServerAnchor.value = false;
|
||||
rhythmTargetArrows.value = 0;
|
||||
invalidateShotPresentations({ resetVisible: true });
|
||||
start.value = false;
|
||||
scores.value = [];
|
||||
|
||||
Reference in New Issue
Block a user