feat: 优化分享模式通关判定逻辑

This commit is contained in:
richarjiang
2026-05-10 22:26:10 +08:00
parent c53eac6b24
commit 851297e124
5 changed files with 627 additions and 51 deletions

View File

@@ -711,7 +711,6 @@ export class PageLevel extends BaseView {
private tryAutoSubmitAnswer(): void {
if (!this._currentConfig || this._isTransitioning) return;
if (this._isShareMode) return;
const values = this.getInputValues();
const isFilled = values.length === Array.from(this._currentConfig.answer ?? '').length && values.every(value => value.length === 1);
@@ -1655,12 +1654,10 @@ export class PageLevel extends BaseView {
const userAnswer = this.getAnswer();
console.log(`[PageLevel] 提交答案: ${userAnswer}, 正确答案: ${this._currentConfig.answer}`);
if (this._isShareMode) {
void this._submitShareAnswerAndContinue(userAnswer);
return;
}
if (userAnswer === this._currentConfig.answer) {
if (this._isShareMode) {
this._recordCurrentShareSubmission(userAnswer);
}
// 答案正确,只播放成功音效(不播放点击音效,避免重合)
this.showSuccess();
} else {
@@ -1700,37 +1697,10 @@ export class PageLevel extends BaseView {
// 不论是否有谐音梗,都停留固定时间,保证玩家能看到答案反馈
await this.delay(PageLevel.PASS_MODAL_DELAY_MS);
if (this._isShareMode) {
if (this._isFinalShareLevel()) {
await this._showShareEndPage();
} else {
await this.goToNextLevel();
}
return;
}
// 显示通关弹窗
this._showPassModal();
}
private async _submitShareAnswerAndContinue(userAnswer: string): Promise<void> {
if (!this._currentConfig || this._isTransitioning || this._isSubmittingShareResult) {
return;
}
this._isTransitioning = true;
this.stopCountdown();
this.hidePunchline();
this._recordCurrentShareSubmission(userAnswer);
if (this._isFinalShareLevel()) {
await this._showShareEndPage();
return;
}
await this.goToNextLevel();
}
private getValidPunchline(punchline: string | null): string | null {
if (!punchline?.trim()) {
return null;
@@ -2030,7 +2000,8 @@ export class PageLevel extends BaseView {
const timeoutModal = modalNode.getComponent(TimeoutModal);
if (timeoutModal) {
timeoutModal.setParams({
levelIndex: this.getDisplayLevelNumber()
levelIndex: this.getDisplayLevelNumber(),
shareMode: this._isShareMode,
});
timeoutModal.setCallbacks({
onShare: () => {
@@ -2042,6 +2013,11 @@ export class PageLevel extends BaseView {
console.error('[PageLevel] 重新进入关卡失败:', err);
});
},
onNext: () => {
this._closeTimeoutModal();
this._recordCurrentShareSubmission();
void this.goToNextLevel();
},
onHome: () => {
this._closeTimeoutModal();
if (this._isShareMode) {