Skip to content

feat: add drag/flick early tap judgment protection - #887

Open
SeRazon wants to merge 4 commits into
TeamFlos:mainfrom
SeRazon:drag-flick-protection
Open

SeRazon wants to merge 4 commits into
TeamFlos:mainfrom
SeRazon:drag-flick-protection

Conversation

@SeRazon

@SeRazon SeRazon commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

概述

参考官方 Phigros 判定机制,增加 Drag/Flick 早按保护,避免误触后续蓝键。

参考资料:关于Phigros判定

实现内容

  • 当 Drag/Flick 已经过判定线但尚未被判定时,保护后续的 Click/Hold 不被早按误触
  • 保护触发条件:Drag/Flick 比 Click/Hold 更靠近判定线至少 0.01 秒(官方阈值)
  • 实现方式:在 closest 匹配阶段,将被保护的 Click/Hold 的匹配权重设为 INFINITY,使其不会被选中
  • 仅保护 early 侧(尚未到达判定线)的 Click/Hold,late 侧不受影响

判定逻辑示意

judgment protection logic 1 judgment protection logic 2

改动文件

  • prpr/src/judge.rs:新增 PROTECTION_THRESHOLD 常量、保护时间预处理、匹配阶段权重调整

测试情况

  • 编译通过
  • 普通单键/多押判定正常(未受保护影响)
  • Drag/Flick 早按保护生效,不会误触后续蓝键
  • cargo fmt --all --check 通过

When a drag/flick note has passed the judge line but is not yet judged,
protect upcoming click/hold notes from being triggered by early taps.
This matches official Phigros behavior where tapping early near a yellow
or red note prioritizes that note over a later blue note.

Protection triggers when:
- The drag/flick is on the late side (time < current time) and NotJudged
- The click/hold is on the early side (time > current time)
- The drag/flick is at least 0.01s closer to the judge line than the click/hold
Copilot AI lite review requested due to automatic review settings August 29, 2026 01:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Judge matching logic to add “early tap” protection for Drag/Flick notes (aligned with Phigros-style judgment behavior), preventing unintended early hits on subsequent Click/Hold notes during closest-note matching.

Changes:

  • Added a PROTECTION_THRESHOLD constant and protection-time preprocessing for unjudged Drag/Flick notes.
  • Adjusted closest-note matching weights to de-prioritize protected early-side Click/Hold notes (by setting weight to INFINITY).
  • Minor refactor to avoid borrowing line.notes mutably before filtering Flick in click handling.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread prpr/src/judge.rs
Comment thread prpr/src/judge.rs
SeRazon and others added 2 commits August 29, 2026 09:44
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The threshold boundary is incorrect, and the protection scan introduces avoidable quadratic work.

Review details

Suppressed comments (2)

Previously missed (1) — in code that hasn't changed since the last review.

prpr/src/judge.rs:614

  • The documented trigger is a lead of at least 0.01 seconds, but this strict comparison excludes the exact-threshold boundary. Use <= so a Drag/Flick exactly 0.01 seconds closer also protects the Click/Hold.

prpr/src/judge.rs:568

  • The per-touch scan walks every remaining note on every line, including all future notes. Since each idx is sorted by note time, this can make repeated taps near the start of a large chart approach quadratic work; stop scanning a line once its first non-past note is reached.
                for &note_idx in &idx[*st..] {
                    let note = &line.notes[note_idx as usize];
                    if matches!(note.kind, NoteKind::Drag | NoteKind::Flick) && note.time < t && matches!(note.judge, JudgeStatus::NotJudged) {
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants