All files / app-leaderboard/src/pages help-content.ts

100% Statements 17/17
62.5% Branches 5/8
100% Functions 12/12
100% Lines 17/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415                                          14x     64x               2x     20x             11x                     2x     14x                 2x 6x 6x                 11x                       110x   1x                                                                                                                                                                                                                                                                                                 11x                                           1x                                                                                                                                                                                                                                                                                                   11x       20x              
import type { PageContent } from './template.ts';
import { html, nothing } from '@be-music/service-web-theme/server';
/** The Help page's text, one version per page language. */
import { Lamp } from './components/basics.ts';
import { PROSE_LINK, ProseSection } from './components/prose.ts';
import { LAMP_STYLES, RULESET_LABELS } from './format.ts';
import { HELP_SECTIONS, type HelpId } from './help-topics.ts';
import type { Locale, Messages } from './i18n/index.ts';
 
export interface HelpContent {
  title: string;
  description: string;
  lead: PageContent;
  contents: string;
  /** Each section's title, in the order of `HELP_SECTIONS`. */
  sections: Readonly<Record<HelpId, string>>;
  body: (t: Messages) => PageContent;
}
 
/** Label / meaning rows. */
function Terms(props: { rows: Array<[PageContent, PageContent]> }) {
  return html`<dl class="grid grid-cols-[max-content_1fr] gap-x-6 gap-y-2">
    ${props.rows.map(
      ([term, meaning]) =>
        html`<dt class="text-foreground">${term}</dt>
          <dd>${meaning}</dd>`,
    )}
  </dl>`;
}
 
/** Every clear lamp with its meaning, lowest first. */
function LampTerms(props: { t: Messages }, messages: Messages) {
  return html`<dl class="grid grid-cols-[max-content_1fr] gap-x-6 gap-y-2">
    ${Object.keys(LAMP_STYLES).map(
      (lamp) =>
        html`<dt>${Lamp({ lamp: Number(lamp) }, messages)}</dt>
          <dd>${props.t.lampMeanings[Number(lamp)]}</dd>`,
    )}
  </dl>`;
}
 
/** The DJ LEVEL steps: ninths of the maximum EX-Score. */
const DJ_LEVELS: Array<[string, number]> = [
  ['AAA', 8],
  ['AA', 7],
  ['A', 6],
  ['B', 5],
  ['C', 4],
  ['D', 3],
  ['E', 2],
];
 
function DjLevels(props: { below: string }) {
  return html`<div class="flex flex-wrap gap-x-4 gap-y-1">
    ${DJ_LEVELS.map(
      ([label, ninths]) =>
        html`<span
          ><span class="text-foreground font-medium">${label}</span> ${((ninths / 9) * 100).toFixed(2)}%+</span
        >`,
    )}<span><span class="text-foreground font-medium">F</span> ${props.below}</span>
  </div>`;
}
 
/** The long-note modes as name / meaning rows, from the catalog's "LN — meaning" lines. */
function lnModeRows(t: Messages): Array<[PageContent, PageContent]> {
  return ([1, 2, 3] as const).map((mode) => {
    const [name, meaning] = t.lnModes[mode].split(' — ');
    return [
      name,
      meaning === undefined
        ? ''
        : `${meaning.charAt(0).toUpperCase()}${meaning.slice(1)}${t.locale === 'ja' ? '。' : '.'}`,
    ];
  });
}
 
const en: HelpContent = {
  title: 'Help',
  description: 'What the figures and marks on the Be-Music Leaderboard mean.',
  // One span: the header's line is a flex row, which would set the full stop apart from the link.
  lead: html`<span
    >What the figures and marks on these pages mean. For how plays are counted, see${' '}<a
      class=${PROSE_LINK ?? nothing}
      href="/about"
      >About</a
    >.</span
  >`,
  contents: 'Contents',
  sections: Object.fromEntries(HELP_SECTIONS.map((section) => [section.id, section.title])) as Record<HelpId, string>,
  body: (t) =>
    html`${Section({
      id: 'rows',
      t: t,
      children: html`<p>Every play in a list reads the same way:</p>
        ${Terms({
          rows: [
            ['Colour bar', 'The play’s clear lamp (below).'],
            [html`7K ☆12`, 'The chart’s key mode and level (#PLAYLEVEL); its difficulty name on hover.'],
            ['EASY CLEAR → CLEAR', 'A lamp the play raised over the player’s earlier best.'],
            ['BP 21 −5', 'Misses, and how many fewer than the player’s earlier best.'],
            [
              'RANDOM',
              'The lane option the play used; OFF is not shown. MIRROR / RANDOM gives both sides of a double play, FLIP a swap of the sides.',
            ],
            ['#3 / 12', 'Where the play’s EX-Score stands among the players on the chart.'],
            ['played with LR2 rules', 'The rules the player played under (their judgment windows and gauge).'],
            [html`+23 81`, 'The EX-Score, with how far it beat the player’s earlier best.'],
            ['AA 64.48%', 'The DJ LEVEL and the score rate.'],
            ['ⓘ', 'The play’s details: gauge, lane option, assists, length, verification and the app it came from.'],
          ],
        })}`,
    })}${Section({
      id: 'lamps',
      t: t,
      children: html`<p>The best a play reached, lowest first. Each ruleset tops out at its own lamp.</p>
        ${LampTerms({ t: t }, t)}`,
    })}${Section({
      id: 'scores',
      t: t,
      children: html`<p>
          <strong>EX-Score</strong> is 2 for each PGREAT and 1 for each GREAT, so the maximum is twice the note count.
          The <strong>rate</strong> is the EX-Score over that maximum. Rankings order by EX-Score; ties share a rank.
        </p>
        <p>The <strong>DJ LEVEL</strong> marks the rate in ninths:</p>
        ${DjLevels({ below: 'below' })}`,
    })}${Section({
      id: 'judgments',
      t: t,
      children: html`${Terms({
        rows: [
          ['PG · GR · GD', 'PGREAT, GREAT and GOOD: hits, best first. They keep the combo.'],
          ['BD · PR', 'BAD and POOR (a missed note). They break the combo.'],
          ['EPR', 'Empty POOR: a press with no note to hit.'],
          ['BP', 'Misses: BAD + POOR + empty POOR, as LR2 and beatoraja count them. Lower is better.'],
        ],
      })}`,
    })}${Section({
      id: 'rules',
      t: t,
      children: html`<p>
          Every play is scored under all three rulesets, each with its own judgment windows, gauges and lamps. Pick the
          one the pages show from the menu in the header; it is kept for your next visit.
        </p>
        ${Terms({
          rows: [
            [
              t.rules.name(RULESET_LABELS.lr2!),
              'LR2’s judgment windows, gauges and lamps; FULL COMBO is the top lamp.',
            ],
            [
              t.rules.name(RULESET_LABELS.beatoraja!),
              'beatoraja’s, with PERFECT (no GOOD) and MAX (all PGREAT) above FULL COMBO.',
            ],
            [
              t.rules.name(RULESET_LABELS.____!),
              'That-Which-Must-Not-Be-Named’s, with charge notes; FULL COMBO is the top lamp.',
            ],
            [t.score.selected, 'On a play’s page: the ruleset the pages show.'],
            [t.score.playedWith, 'The ruleset the player played under.'],
          ],
        })}`,
    })}${Section({
      id: 'gauges',
      t: t,
      children: html`<p>
          The gauge a play chose, named as each ruleset names it. GROOVE is beatoraja’s NORMAL. A failed play shows how
          far its gauge got.
        </p>
        <p>
          Under LR2 rules, DEATH requires at least 80% at the end of a single chart, while DEATH corrected clears by
          surviving. Both award the CLEAR lamp for a standard clear. Under beatoraja rules, HAZARD awards FULL COMBO
          when the gauge determines the lamp.
        </p>`,
    })}${Section({
      id: 'long-notes',
      t: t,
      children: html`${Terms({ rows: lnModeRows(t) })}
        <p>A chart sets its mode with #LNMODE; LN when it does not. It matters only on charts with long notes.</p>`,
    })}${Section({
      id: 'filters',
      t: t,
      children: html`${Terms({
        rows: [
          [
            t.filters.everyPlay,
            'Each play on its own row, so a player can appear more than once. Off: each player’s best.',
          ],
          [
            t.filters.assisted,
            'Plays with an assist (auto scratch, a widened judgment window), ranked apart from the rest.',
          ],
          [t.filters.anonymous, 'Guest accounts not yet kept with a passkey, Google or Discord, shown when turned on.'],
          [t.filters.file, 'One chart can come in several files (re-saves, re-encodes); rank one file’s plays only.'],
        ],
      })}`,
    })}${Section({
      id: 'verification',
      t: t,
      children: html`${Terms({
          rows: [
            ['L3', 'The chart in the replay matches its fingerprint.'],
            ['L4', 'The chart played is known to be this one: it has no #RANDOM, or this branch was seen before.'],
          ],
        })}
        <p>Every play is recounted from its inputs whatever its layer.</p>`,
    })}${Section({
      id: 'visibility',
      t: t,
      children: html`<p>
          A play by a player with an account on a listed chart is <strong>public</strong>: it is in the rankings, Latest
          and its player’s page. A play that is not shows to its own player marked${' '}<strong
            >${t.visibility.notPublic}</strong
          >
          or <strong>${t.visibility.hidden}</strong>, with the reason under its “?”.
        </p>
        ${Terms({
          rows: [
            [
              'Chart not listed yet',
              'A new chart is listed once two players who are not guests have played it. Until then its plays reach the lists and rankings only for their own player, and search engines skip them.',
            ],
            [
              'Guest',
              'Plays by a guest account show in the rankings and Latest only with “Guests” on. Keep the account with a passkey, Google or Discord and they become public.',
            ],
            [
              'Hidden',
              'A play its player hid: kept, but out of the rankings, the personal bests, the figures and every list, and only its player can open it. They can show it again from its page.',
            ],
            [t.filters.assisted, 'Plays with an assist are public, but ranked apart from the rest.'],
          ],
        })}`,
    })}`,
};
 
const ja: HelpContent = {
  title: 'ヘルプ',
  description: 'Be-Music Leaderboard の数字や記号の意味。',
  lead: html`<span
    >このサイトの数字や記号の意味です。プレイの採点方法は<a class=${PROSE_LINK ?? nothing} href="/about"
      >このサイトについて</a
    >をご覧ください。</span
  >`,
  contents: '目次',
  sections: {
    rows: 'プレイの見方',
    lamps: 'クリアランプ',
    scores: 'EX スコア・レート・DJ LEVEL',
    judgments: '判定と BP',
    rules: '採点ルール',
    gauges: 'ゲージ',
    'long-notes': 'ロングノーツ',
    filters: 'ランキングの切り替え',
    verification: '検証',
    visibility: 'プレイの公開範囲',
  },
  body: (t) =>
    html`${Section({
      id: 'rows',
      t: t,
      children: html`<p>リストのプレイは、どれも同じように読めます。</p>
        ${Terms({
          rows: [
            ['色のバー', 'プレイのクリアランプ(下記)。'],
            [html`7K ☆12`, '譜面のキーモードとレベル(#PLAYLEVEL)。ホバーで難易度名を表示。'],
            ['EASY CLEAR → CLEAR', 'それまでの自己ベストから更新したランプ。'],
            ['BP 21 −5', 'ミス数と、それまでの自己ベストから減った数。'],
            [
              'RANDOM',
              'プレイで使ったレーンオプション(OFF は表示しません)。MIRROR / RANDOM はダブルプレイの左右両方、FLIP は左右の入れ替え。',
            ],
            ['#3 / 12', 'その譜面のプレイヤーの中での EX スコアの順位。'],
            [t.rules.playedWith(t.rules.name('LR2')), 'プレイヤーが遊んだルール(判定幅とゲージ)。'],
            [html`+23 81`, 'EX スコアと、それまでの自己ベストからの伸び。'],
            ['AA 64.48%', 'DJ LEVEL とスコアレート。'],
            ['ⓘ', 'プレイの詳細: ゲージ、レーンオプション、アシスト、長さ、検証、送信したアプリ。'],
          ],
        })}`,
    })}${Section({
      id: 'lamps',
      t: t,
      children: html`<p>
          プレイが到達した最高のランプを、低い順に並べています。ルールごとに最上位のランプが異なります。
        </p>
        ${LampTerms({ t: t }, t)}`,
    })}${Section({
      id: 'scores',
      t: t,
      children: html`<p>
          <strong>EX スコア</strong>は PGREAT 1 つにつき 2、GREAT 1 つにつき 1 で、最大はノーツ数の 2
          倍です。<strong>レート</strong>は EX スコアをその最大で割ったもの。ランキングは EX
          スコア順で、同点は同順位です。
        </p>
        <p><strong>DJ LEVEL</strong> はレートを 9 分の 1 刻みで表します。</p>
        ${DjLevels({ below: '未満' })}`,
    })}${Section({
      id: 'judgments',
      t: t,
      children: html`${Terms({
        rows: [
          ['PG · GR · GD', 'PGREAT・GREAT・GOOD: ヒット(良い順)。コンボが続きます。'],
          ['BD · PR', 'BAD と POOR(見逃し)。コンボが途切れます。'],
          ['EPR', '空 POOR: ノーツのない所での空打ち。'],
          ['BP', 'ミス数: BAD + POOR + 空 POOR(LR2 と beatoraja の数え方)。少ないほど良い。'],
        ],
      })}`,
    })}${Section({
      id: 'rules',
      t: t,
      children: html`<p>
          どのプレイも 3
          つのルールすべてで採点します。判定幅・ゲージ・ランプはルールごとに異なります。ページに表示するルールはヘッダーのメニューで選べ、次に来たときも引き継がれます。
        </p>
        ${Terms({
          rows: [
            [t.rules.name(RULESET_LABELS.lr2!), 'LR2 の判定幅・ゲージ・ランプ。最上位のランプは FULL COMBO。'],
            [
              t.rules.name(RULESET_LABELS.beatoraja!),
              'beatoraja のもの。FULL COMBO の上に PERFECT(GOOD なし)と MAX(すべて PGREAT)があります。',
            ],
            [
              t.rules.name(RULESET_LABELS.____!),
              '名前を言ってはいけないあのゲームのもの(チャージノート付き)。最上位のランプは FULL COMBO。',
            ],
            [t.score.selected, 'プレイのページで、ページの表示に使っているルール。'],
            [t.score.playedWith, 'プレイヤーが遊んだルール。'],
          ],
        })}`,
    })}${Section({
      id: 'gauges',
      t: t,
      children: html`<p>
          プレイで選んだゲージを、ルールごとの呼び名で表示します。GROOVE は beatoraja の NORMAL です。FAILED
          のプレイには、ゲージがどこまで残ったかを表示します。
        </p>
        <p>
          LR2 の単曲プレイでは、DEATH は終了時に 80% 以上でクリアし、DEATH corrected
          は生き残ればクリアします。どちらも通常クリアのランプは CLEAR です。beatoraja
          ルールでゲージからランプを決める場合、HAZARD は FULL COMBO になります。
        </p>`,
    })}${Section({
      id: 'long-notes',
      t: t,
      children: html`${Terms({ rows: lnModeRows(t) })}
        <p>
          譜面は #LNMODE でモードを指定します。指定がなければ LN です。ロングノーツのある譜面でのみ意味があります。
        </p>`,
    })}${Section({
      id: 'filters',
      t: t,
      children: html`${Terms({
        rows: [
          [
            t.filters.everyPlay,
            'プレイを 1 行ずつ表示します。同じプレイヤーが複数回並ぶことがあります。オフでは各プレイヤーのベスト。',
          ],
          [
            t.filters.assisted,
            'アシスト(オートスクラッチ、判定幅の拡大)を使ったプレイ。ほかとは別にランキングします。',
          ],
          [t.filters.anonymous, 'パスキー・Google・Discord で保存していないゲストアカウント。オンにすると表示します。'],
          [
            t.filters.file,
            '1 つの譜面が複数のファイル(保存し直し、再エンコード)で配られることがあります。1 ファイルのプレイだけでランキングします。',
          ],
        ],
      })}`,
    })}${Section({
      id: 'verification',
      t: t,
      children: html`${Terms({
          rows: [
            ['L3', 'リプレイの譜面が譜面 ID と一致する。'],
            ['L4', '遊んだ譜面がこの譜面だと確かめられる: #RANDOM がない、または既に確認済みの分岐。'],
          ],
        })}
        <p>どの段階でも、スコアは打鍵の記録から計算し直しています。</p>`,
    })}${Section({
      id: 'visibility',
      t: t,
      children: html`<p>
          アカウントを持つプレイヤーの、公開された譜面でのプレイは<strong>公開</strong>され、ランキング、最新のプレイ、プレイヤーのページに載ります。公開されていないプレイは本人にだけ<strong>${t.visibility.notPublic}</strong>または<strong>${t.visibility.hidden}</strong>の印つきで表示され、「?」から理由を確認できます。
        </p>
        ${Terms({
          rows: [
            [
              '譜面が公開前',
              '新しい譜面は、ゲストでないプレイヤー 2 人が遊ぶと公開されます。それまでは、そのプレイはリストとランキングで本人にだけ表示され、検索エンジンにも載りません。',
            ],
            [
              'ゲスト',
              'ゲストアカウントのプレイは、「ゲスト」をオンにしたときだけランキングと最新のプレイに表示されます。パスキー・Google・Discord でアカウントを保存すると、これまでのプレイも公開されます。',
            ],
            [
              '非表示',
              'プレイヤーが非表示にしたプレイ。プレイは保存されたまま、ランキング・自己ベスト・集計・すべてのリストから外れ、本人だけが見られます。プレイのページから表示に戻せます。',
            ],
            [t.filters.assisted, 'アシストを使ったプレイも公開されますが、ほかとは別にランキングします。'],
          ],
        })}`,
    })}`,
};
 
export const HELP: Readonly<Record<Locale, HelpContent>> = { en, ja };
 
/** A help section, titled in the page's language. */
function Section(props: { id: HelpId; t: Messages; children: PageContent }) {
  return ProseSection({
    id: props.id,
    title: HELP[props.t.locale as Locale].sections[props.id],
    loose: true,
    children: html`${props.children}`,
  });
}