Skip to content

実装: sortie の 30秒タイムアウトを defeat と区別し中立な「戦闘終了」表示にする #725

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "sortie の 30秒タイムアウトを defeat から切り離し、neutral terminal (`timeout`) として表示・定義する"
change_kind: mixed

Parent Issue

none(単独改善 / #689 M2 手動プレイテスト由来の follow-up)

Parent Goal Ref

  • Goal: sortie の terminal 状態のうち「30秒タイムアウト」をゲームデザイン上の hp0 defeat から切り離し、将来の reward/debrief consumer が区別できる neutral terminal として扱う
  • Desired Destination: なし(単独 Issue)

Current Validated Scope

  • src/systems/SortieSystem.ts の terminal 判定で、30秒タイムアウトを defeat から切り離した neutral outcome として表現する
  • src/render/CanvasRenderer.ts の結果オーバーレイで、timeout 時に defeat tone を使わず中立ラベル「戦闘終了」を描画する
  • src/state/GameState.ts の SortieStatus / SortieResult / SortieEndReason を timeout 区別に必要な範囲で拡張する
  • docs/product/features/sortie.md と docs/playtest/m2-combat-mvp.md の「30秒タイムアウト = defeat」記述を中立表記へ更新する
  • tests/sortie-system.test.ts と tests/e2e/m2-combat-mvp.spec.ts の timeout 期待値を中立表現へ更新する

Remaining Parent Gaps

  • 報酬付与ロジックそのもの(debrief / reward)の実装は本 Issue のスコープ外。本 Issue は「タイムアウトを defeat から分離した neutral terminal として定義する」ことに限定する
  • victory 文言の中立化(「VICTORY」表記の再検討)は本 Issue では扱わず、必要なら別 Issue とする

Outcome

30秒タイムアウトで sortie が終了したとき、SortieResult が hp0 敗北と区別可能な timeout outcome / timeout endReason を持ち、SortieState.status も defeat ではなく timeout になり、CanvasRenderer が「戦闘終了」中立ラベルと neutral tone を描画し、docs/product/features/sortie.md / docs/playtest/m2-combat-mvp.md / tests/e2e/m2-combat-mvp.spec.ts が timeout=defeat の記述を更新済みで、Vitest と E2E が PASS している状態。

In Scope

  • SortieSystem の terminal 判定でタイムアウトを defeat と区別する timeout outcome 表現
  • SortieStatus / SortieResult / SortieEndReason の timeout 区別に必要な最小拡張
  • CanvasRenderer の timeout 終了時 presentation を中立ラベル「戦闘終了」へ変更
  • docs/product/features/sortie.md / docs/playtest/m2-combat-mvp.md / tests/e2e/m2-combat-mvp.spec.ts の timeout 意味づけ更新(敗北ではなく neutral terminal)
  • 対応する unit test / E2E 期待値の追加・更新

Out of Scope

  • 報酬付与(reward / debrief)ロジックの実装
  • hp0 による defeat、敵全滅 victory の判定ロジック変更
  • VICTORY 文言の中立化
  • HUD(DOM)側のステータス集約(別 Issue)
  • ダメージ/HP の数値フォーマット是正(別 Issue)

Product Spec Context

diff_rationale: Timeout is a neutral terminal result distinct from hp0 defeat so future reward/debrief consumers can branch on outcome without inferring from endReason alone.
changed_requirement_id: sortie.timeout_terminal_result
affected_sections:

  • docs/product/features/sortie.md: Authority / Conflict Resolution
  • docs/product/features/sortie.md: Sortie State Machine
  • docs/product/features/sortie.md: End Conditions
  • docs/product/features/sortie.md: SortieResult
  • src/ui/HudController.ts: sortie status/result labels
  • src/main.ts: E2E snapshot sortie.status/result bridge
  • docs/playtest/m2-combat-mvp.md: timeout evidence wording
  • tests/e2e/m2-combat-mvp.spec.ts: timeout fixture assertions

Related Migration

Acceptance Criteria

  • AC1: 30秒タイムアウト終了時の SortieResult が、hp0 による defeat とプログラム的に区別できる(outcome: 'timeout' と endReason: 'timeout' を持ち、ended は post-result ack 用に残す)。
  • AC2: CanvasRenderer がタイムアウト終了時に DEFEAT ではなく中立ラベル「戦闘終了」を描画し、defeat tone を使わない。
  • AC3: docs/product/features/sortie.md / docs/playtest/m2-combat-mvp.md / tests/e2e/m2-combat-mvp.spec.ts が timeout を「敗北(defeat)」ではなく中立な戦闘終了として記述している。
  • AC4: hp0 defeat / 敵全滅 victory / 同一 tick 優先順位 の既存挙動が回帰していない(unit test で PASS)。
  • AC5: timeout の E2E 期待値が中立表現に更新され、Canvas overlay / HUD の timeout 表示が defeat ベースではない。
  • AC6: 追加・更新した unit test を含め Vitest 全件が PASS する。
  • AC7: pnpm typecheck が PASS する。
  • AC8: pnpm lint が PASS する。
  • AC9: pnpm build が PASS する。

Verification Commands

# AC1
$ pnpm test -- tests/sortie-system.test.ts
# AC2
# preflight-scope: runtime_only
$ pnpm test:e2e -- tests/e2e/m2-combat-mvp.spec.ts
# AC3
$ rg -n "戦闘終了" docs/product/features/sortie.md docs/playtest/m2-combat-mvp.md tests/e2e/m2-combat-mvp.spec.ts src/render/CanvasRenderer.ts
# AC4
$ pnpm test -- tests/sortie-system.test.ts
# AC5
# preflight-scope: runtime_only
$ pnpm test:e2e -- tests/e2e/m2-combat-mvp.spec.ts
# AC6
$ pnpm test
# AC7
$ pnpm typecheck
# AC8
$ pnpm lint
# AC9
$ pnpm build

Runtime Verification Applicability

  • decision: not_applicable
  • reason: 本 Issue は static / automated test の更新で完結し、別途の人間 runtime verification は要求しない。E2E は Allowed Paths 内の自動検証として扱う。

Allowed Paths

  • src/systems/SortieSystem.ts
  • src/state/GameState.ts
  • src/render/CanvasRenderer.ts
  • src/ui/HudController.ts
  • src/main.ts
  • docs/product/features/sortie.md
  • docs/playtest/m2-combat-mvp.md
  • tests/sortie-system.test.ts
  • tests/e2e/m2-combat-mvp.spec.ts

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • SortieResult outcome 型変更が e2e(tests/e2e/m2-combat-mvp.spec.ts)の defeat pixel 判定に波及し、Allowed Paths 外の修正が必要になった場合

Required Skills

  • TypeScript / TSC strict
  • ECS(state / systems 分離)
  • Canvas 2D 描画

Scope Delta(任意)

N/A

Notes for Reviewer

Activity

  1. added
    enhancement
    on Jun 6, 2026
  2. squne121 commented on Jun 6, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST CHANGES。
    #725 の方向性自体は妥当です。ただし、現状の Issue 契約のままだと「表示だけ DEFEAT を隠す」「型・状態遷移・docs・playtest 証跡はまだ timeout defeat のまま」という中途半端な実装になりやすいです。

    #725 は「30秒 timeout を defeat と区別し、中立な“戦闘終了”表示にする」ことを目的にし、SortieSystem.ts、GameState.ts、CanvasRenderer.ts、docs/product/features/sortie.md、tests/sortie-system.test.ts を対象にしています。AC も timeout の区別、renderer 表示、docs 修正、HP0/victory 回帰、テスト通過を求めています。([GitHub]1)

    一方、現在の main はすでに #680/#709 で endReason: 'timeout' を持っています。つまり AC1 の「明示フラグで timeout を distinguishable にする」は既に概ね満たされています。現状コードでは timeout は outcome: 'defeat', endReason: 'timeout' で、SortieState.status も result.outcome 由来なので defeat に遷移します。([GitHub]2)


    ブロッカー

    1. #725 は「UI 表示修正」なのか「ドメインモデル変更」なのか曖昧

    現状の SortieResult は discriminated union ですが、timeout は依然として outcome: 'defeat' 側に属します。SortieEndReason コメントも timeout を「defeat」と説明しています。([GitHub]3)

    #725 の文面は「defeat と区別」「中立な戦闘終了」「報酬受領可能」と読めるため、単に CanvasRenderer で endReason === 'timeout' のときだけ表示を変える実装では、内部契約は defeat のままです。これは将来の reward/debrief/persistence 実装で高確率に破綻します。

    要求修正案:

    どちらかを Issue に明記してください。

    A. 最小変更案:
    outcome: 'defeat' は維持し、UI/文書上だけ timeout を「戦闘終了」と表示する。ただしこれは「ゲームロジック上は defeat のまま」と明記する。

    B. 推奨案:
    timeout を defeat から型レベルで切り離す。例:

    export type SortieResult =
      | (BaseSortieResult & {
          outcome: 'victory';
          endReason: 'all_enemies_defeated';
        })
      | (BaseSortieResult & {
          outcome: 'defeat';
          endReason: 'player_hp_zero';
        })
      | (BaseSortieResult & {
          outcome: 'timeout';
          endReason: 'timeout';
        });

    TypeScript の discriminated union は共通プロパティの literal type によって安全に絞り込めるため、この種の状態契約に向いています。網羅性チェックには never を使えます。(TypeScript)


    2. ended という既存 status と衝突しやすい

    SortieStatus にはすでに 'ended' があります。現在の docs でも ended は result 表示後の post-result 状態として説明されています。([GitHub]5)

    そのため、timeout の outcome/status に安易に ended を使うと、「30秒で戦闘終了した結果」なのか「結果確認後に sortie を閉じた状態」なのかが混線します。

    推奨:
    timeout 結果は outcome: 'timeout' または outcome: 'completed' のように、既存 status: 'ended' と衝突しない名前にする。個人的には timeout が最も誤読が少ないです。


    3. CanvasRenderer のラベルだけ直すと defeat 色が残る

    現在の renderer は state.sortie.result.outcome だけを見て VICTORY / DEFEAT を決め、victory でなければ defeat 扱いの色・表示になります。つまり timeout でラベルだけ 戦闘終了 にしても、赤系の defeat overlay が残る可能性があります。([GitHub]6)

    これは UI 上の semantic leak です。
    「中立な戦闘終了」とするなら、少なくとも presentation を中央集約してください。

    function getSortieResultPresentation(result: SortieResult): {
      label: 'VICTORY' | 'DEFEAT' | '戦闘終了';
      tone: 'victory' | 'defeat' | 'neutral';
    } {
      switch (result.endReason) {
        case 'all_enemies_defeated':
          return { label: 'VICTORY', tone: 'victory' };
        case 'player_hp_zero':
          return { label: 'DEFEAT', tone: 'defeat' };
        case 'timeout':
          return { label: '戦闘終了', tone: 'neutral' };
        default:
          return assertNever(result);
      }
    }

    Canvas の fillText() は指定座標に文字列を描画する API なので、renderer test では pixel diff だけでなく、mock context の fillText('戦闘終了', ...) と fillStyle/presentation helper を検証できます。([MDN Web Docs]7)


    4. Allowed paths が足りない可能性が高い

    #725 の allowed paths は renderer と sortie unit test までですが、Stop condition では tests/e2e/m2-combat-mvp.spec.ts の defeat pixel 変更可能性に触れています。([GitHub]1)

    これは「必要なら止まる」ではなく、ほぼ確実に事前スコープ化すべき箇所です。#552 で 30秒 timeout は defeat として E2E/docs/unit に入った経緯があり、timeout 表示を変えるなら E2E の期待値もズレる可能性が高いです。([GitHub]8)

    要求修正:
    allowed paths に少なくとも以下を追加するか、別 Issue に明示分離してください。

    tests/e2e/m2-combat-mvp.spec.ts
    tests/render/... または CanvasRenderer 用の既存/新規 test
    

    現状のままでは AC2「renderer label が戦闘終了」は rg と unit test だけでごまかされるリスクがあります。


    5. docs の修正範囲が過小評価されている

    docs/product/features/sortie.md は複数箇所で timeout を defeat として規定しています。Authority、States、Transition table、End Conditions、Normative per-tick evaluation、SortieResult shape、endReason mapping の全てが影響します。([GitHub]5)

    #725 のメモは「docs line 42-43/62/82」程度に見えますが、これは不足です。部分置換だと docs 内で「timeout は戦闘終了」「timeout は defeat」が混在します。

    要求修正:
    検証に negative grep を入れてください。

    rg -n "timeout.*defeat|defeat.*timeout|30秒.*defeat|30秒.*敗北|timeout.*敗北|敗北.*timeout" \
      docs/product/features/sortie.md src tests

    ただし、過去経緯として残す changelog/comment は allowlist 化してください。


    6. #690 / #542 / #552 との整合が未処理

    #690 は timeout_30s_defeat の手動動画証跡 waiver を扱う Issue です。#725 で timeout を中立化するなら、#690 の名称・証跡観点・playtest vocabulary も旧仕様になります。([GitHub]9)

    また #542 では M2 MVP の仕様として「30秒到達は victory ではなく defeat/end treatment」「優先順位は defeat > victory > timeout」と整理されています。#552 でも 30秒 timeout → defeat として docs/test/E2E を更新した履歴があります。([GitHub]10)

    要求修正:
    #725 に以下を追加すべきです。

    Related migration:
    - Supersedes or revises #690 terminology: timeout_30s_defeat → timeout_30s_end / combat_end_timeout
    - Revises #542/#552 M2 wording: timeout is not victory and not HP defeat; it is neutral timeout terminal
    - E2E/playtest evidence labels must not continue to call timeout "defeat"

    #689 は viewport/DPR 証跡が主題で、timeout 動画 waiver は #690 に分離されていました。#725 の「#689 からの follow-up」という説明だけでは根拠として弱いです。([GitHub]11)


    7. reward/debrief の表現が先走っている

    #725 は「中立な戦闘終了 / 報酬受領可能」と書いていますが、reward/debrief の実装は out of scope です。docs の現状でも persistence/rewards は non-goal です。([GitHub]1)

    危険:
    「報酬受領可能」と仕様文に書くと、未実装なのに product contract だけ先に確定します。

    推奨文言:

    Timeout is not HP defeat. It is a neutral terminal result.
    Reward/debrief handling is intentionally deferred; this Issue only preserves enough result semantics for future reward/debrief consumers.

    推奨する #725 の再定義

    この Issue は次のように契約を締めた方が安全です。

    Goal:
    30s timeout must no longer be represented as HP defeat.
    It must be a neutral timeout terminal result, rendered as 「戦闘終了」.
    
    Non-goal:
    - reward/debrief implementation
    - persistence implementation
    - victory condition redesign
    - HP/damage formatting
    
    Required model:
    - HP zero: outcome=defeat, endReason=player_hp_zero
    - Enemy wipe: outcome=victory, endReason=all_enemies_defeated
    - 30s timeout with player alive and enemies remaining:
      - outcome=timeout または equivalent neutral terminal outcome
      - endReason=timeout
      - playerHpRemaining remains actual HP snapshot, not 0
    
    Renderer:
    - timeout must render 「戦闘終了」
    - timeout must not render DEFEAT
    - timeout must not use defeat-only presentation tone
    
    Docs:
    - Remove normative wording that describes timeout as defeat.
    - Preserve “not victory” wording.
    - Clarify reward/debrief is deferred.
    
    Tests:
    - HP0 regression
    - enemy wipe regression
    - same-tick priority regression
    - timeout result regression
    - renderer presentation regression
    - affected E2E expectations updated or explicitly split to follow-up

    実装上の注意点

    state.enemies.length > 0 の guard は維持してください。JavaScript の Array.prototype.every() は空配列で true を返すため、敵配列が空のときに victory 判定が誤爆しないようにする現在の guard は重要です。([MDN Web Docs]12)

    現在の SortieSystem は HP0 → victory → timeout の順で terminal result を作っています。timeout を中立化しても、同 tick の優先順位は既存の regression test を残すべきです。([GitHub]13)


    最終レビューコメント案

    そのまま GitHub に貼るなら以下です。

    REQUEST CHANGES.
    
    #725 の方向性には賛成です。ただし現状の Issue 契約は曖昧で、このままだと「CanvasRenderer で DEFEAT 文字列だけ隠すが、SortieResult/status/docs/playtest は timeout defeat のまま」という半端な実装になりやすいです。
    
    現在 main は #680/#709 により timeout を `endReason: 'timeout'` として既に識別可能です。一方で `outcome` は `defeat`、`SortieState.status` も `defeat`、docs も複数箇所で timeout defeat を normative に定義しています。したがって #725 は単なる AC1 追加ではなく、timeout を defeat から外す semantic migration として再定義すべきです。
    
    Blockers:
    1. `outcome: 'defeat', endReason: 'timeout'` を維持するのか、`outcome: 'timeout'` など neutral terminal outcome を追加するのか明記してください。
    2. `ended` は既に post-result status として使われているため、timeout outcome/status に安易に流用しないでください。
    3. CanvasRenderer は label だけでなく tone/color も outcome 依存です。timeout で `戦闘終了` を表示しても defeat tone が残る実装は reject すべきです。
    4. allowed paths に E2E または renderer test が不足しています。`tests/e2e/m2-combat-mvp.spec.ts` への影響は stop condition ではなく事前スコープ化が必要です。
    5. `docs/product/features/sortie.md` は Authority / States / Transition table / End Conditions / SortieResult shape / endReason mapping の全てが影響します。部分置換では仕様矛盾が残ります。
    6. #690 の `timeout_30s_defeat` 証跡 terminology も旧仕様になるため、rename/supersede/follow-up を明記してください。
    7. reward/debrief は out of scope なので、「報酬受領可能」と断定せず「将来の reward/debrief consumer のために timeout を HP defeat から区別する」に留めるべきです。
    
    推奨は、timeout を型レベルで neutral terminal として表現し、renderer presentation helper を追加して `VICTORY` / `DEFEAT` / `戦闘終了` と tone を一箇所に集約することです。

    結論として、#725 は実装前に Issue 契約を締め直すべきです。特に outcome/status を変えるかどうか、E2E を今回含めるか、#690 の旧 timeout_30s_defeat 表記をどう処理するかを曖昧にしたまま着手すると、後続の reward/debrief 実装でまた仕様債務になります。

  3. added 2 commits that reference this issue on Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions