Skip to content

스토리 분기 엔진 데이터화 (전면 표준화 Phase 4) - #117

Merged
Cassiiopeia merged 1 commit into
mainfrom
20260808_스토리_전이_규칙_데이터화
Aug 8, 2026

Hidden character warning

The head ref may contain hidden characters: "20260808_\uc2a4\ud1a0\ub9ac_\uc804\uc774_\uaddc\uce59_\ub370\uc774\ud130\ud654"
Merged

스토리 분기 엔진 데이터화 (전면 표준화 Phase 4)#117
Cassiiopeia merged 1 commit into
mainfrom
20260808_스토리_전이_규칙_데이터화

Conversation

@Cassiiopeia

@Cassiiopeia Cassiiopeia commented Aug 8, 2026

Copy link
Copy Markdown
Member

관련 이슈

개요

Phase 4 — 스토리 분기 엔진 데이터화입니다.

스펙 1.2절에서 "가장 심각한 구조적 모순"으로 진단했던 문제를 해소했습니다. 씬을 하나 추가하려면 데이터가 아니라 컴포넌트를 고쳐야 하는 상태였습니다.

3단계로 안전하게

이 작업은 잘못하면 게임이 엉뚱한 엔딩으로 가는데 아무도 모르는 상태를 만듭니다. 그래서 순서를 나눴습니다.

단계 내용 PR
1 순수 함수 추출 (동작 불변) #115
2 전 경로 회귀 테스트 25개 — 현재 동작의 기대값 표 #115
3 JSON 데이터로 이관 — 위 테스트가 전후 모두 통과 이 PR

2단계 없이 3단계를 하면 회귀를 잡을 방법이 없습니다.

무엇이 바뀌었나

규칙이 데이터가 됐습니다

src/data/stageRules.json:

"0": [
  { "when": { "scoreMin": 15, "scoreMax": 40 }, "to": 1 },
  { "when": { "scoreMax": 15 }, "to": 2 },
  { "to": 3 }
]

배열을 위에서부터 평가해 첫 번째로 조건을 만족하는 대상으로 이동합니다. when이 없는 규칙이 기본값입니다.

storyFlow.js는 이제 평가만 합니다. 씬을 추가하거나 임계치를 바꾸려면 JSON만 고치면 되고 코드는 손대지 않습니다.

값은 하나도 바꾸지 않았습니다

데이터의 love: 60 선언과 실제 임계치 70의 불일치처럼 이상해 보이는 것도 현재 배포되어 동작 중인 규칙이므로 그대로 옮기고 JSON 주석으로 명시했습니다.

검증

회귀 테스트 — 이 작업의 핵심

데이터화 전에 작성한 25개 테스트가 데이터화 후에도 그대로 통과합니다. 이것이 동작 동일성의 증거입니다.

명령 결과
storyFlow.test.js 25/25 (데이터화 전후 동일)
format:check ✅ exit 0
lint ✅ exit 0
test:ci ✅ 130 tests
build ✅ Compiled successfully

브라우저 실제 게임 진행

카페(스테이지 2)에서 "카페 라떼"(0점) 선택 → 대사 진행 → 씬 2로 분기되어 화면에 정확히 그 씬("이수정: 아, 차라리 카페 가지 말 걸 그랬나…?")이 표시됐습니다.

JSON 규칙 { "when": { "scoreMax": 15 }, "to": 2 }와 일치합니다. 콘솔 에러 없음.

이제 가능해진 것

  • 씬 추가 · 임계치 조정을 JSON 편집만으로 처리
  • 전이 규칙이 테스트로 보호됨 (25개)
  • 컴포넌트는 "현재 씬 렌더 + 엔진 호출"만 담당

Summary by CodeRabbit

  • 새로운 기능

    • 스테이지별 점수와 선택 결과에 따라 다음 장면과 종료 경로가 자동으로 결정됩니다.
    • 선택한 경로에 맞춰 적절한 결과 화면으로 이동합니다.
    • 별도 조건이 없는 경우에도 기본 진행 경로가 안정적으로 적용됩니다.
  • 버그 수정

    • 스토리 구조를 인식하지 못해 잘못된 장면으로 이동하던 문제를 개선했습니다.
    • 다양한 점수 및 선택 조합에서 스토리 전환이 일관되게 동작합니다.
  • 문서

    • 점수 기준과 스토리 전환 규칙에 대한 안내를 업데이트했습니다.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

스테이지 2~5의 전이 규칙과 종료 경로를 stageRules.json으로 이동했다. storyFlow.js는 규칙을 순서대로 평가하고 씬 또는 경로를 반환한다. STAGE_END를 제거하고 RESULT_ROUTE를 추가했다.

Changes

스토리 전이 규칙 데이터화

Layer / File(s) Summary
스테이지 규칙과 조건 평가
src/data/stageRules.json, src/game/storyFlow.js
스테이지별 씬 전이, 점수 조건, 기본 경로, 선택지별 종료 경로를 JSON으로 정의했다. 규칙은 배열 순서대로 평가하며 점수 범위는 scoreMin 이상 및 scoreMax 미만으로 판정한다.
씬 전이와 종료 경로 해석
src/game/storyFlow.js, docs/GAME-FLOW.md, claude.md
resolveNextStepresolveStageExit가 JSON 규칙을 사용한다. STAGE_END를 제거하고 RESULT_ROUTE를 공개한다. 문서와 Phase 4 상태를 갱신했다.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Poem

당근을 든 토끼가 규칙을 읽네
JSON 길 따라 씬이 움직이네
점수 문턱도 차분히 넘고
출구 경로도 찾아가네
RESULT_ROUTE, 깡충 완료!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 스토리 분기 엔진을 데이터화하고 Phase 4 표준화를 완료하는 변경 사항을 정확하게 요약합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 20260808_스토리_전이_규칙_데이터화

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/game/storyFlow.js

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

🚀 CI 빌드 성공!

📦 빌드 정보

  • 빌드 크기: 167M
  • 빌드 시간: 19초
  • 커밋: d1c8db5649f9bfb3a717607a005f31dd9fcea57d
  • 브랜치: 20260808_스토리_전이_규칙_데이터화

📁 생성된 파일

static/js/main.df572349.js

✅ 모든 검사 통과

  • 포맷 체크 ✅
  • 린트 체크 ✅
  • 테스트 실행 ✅
  • 빌드 생성 ✅

이 댓글은 모든 단계가 통과했을 때만 생성됩니다.

자동 생성된 댓글입니다.

@Cassiiopeia
Cassiiopeia merged commit 8570be2 into main Aug 8, 2026
1 of 2 checks passed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/data/stageRules.json`:
- Around line 28-32: 종료 경로가 선택지 발생 씬을 기준으로 결정되도록 수정하세요. src/data/stageRules.json
28-32의 stageExit를 완료 씬 인덱스별 규칙으로 재구성하고, src/game/storyFlow.js 67-71의
resolveStageExit가 씬 인덱스를 받아 해당 씬의 byChoice만 조회하도록 호출부와 회귀 테스트를 갱신하세요. 구현이 씬별 규칙을
보장한 뒤 docs/GAME-FLOW.md 121의 “JSON만 고치면 된다” 설명을 유지하세요.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 38f4ab7b-aab3-4e41-a4ca-72cccee6702a

📥 Commits

Reviewing files that changed from the base of the PR and between 8ff8865 and 495c004.

📒 Files selected for processing (4)
  • claude.md
  • docs/GAME-FLOW.md
  • src/data/stageRules.json
  • src/game/storyFlow.js

Comment thread src/data/stageRules.json
Comment on lines +28 to +32
"stageExit": {
"_comment": "카페에서 '돈을 줍는다'(첫 선택지)를 고르면 우산 경로가 열린다",
"byChoice": { "0": "/main4" },
"default": "/main3"
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

종료 경로 규칙이 선택지 발생 씬을 식별하지 못합니다. 현재 선택지마다 종료 경로를 계산하지만 규칙과 API 모두 씬 인덱스를 사용하지 않습니다. 마지막 선택지가 우연히 값을 덮어쓰는 현재 구조는 씬 추가 또는 순서 변경 후 잘못된 최종 경로를 만들 수 있습니다.

  • src/data/stageRules.json#L28-L32: stageExit를 완료 씬 인덱스별 규칙으로 변경하세요.
  • src/game/storyFlow.js#L67-L71: resolveStageExit가 씬 인덱스를 받고, 해당 씬의 byChoice만 조회하도록 변경하세요. 호출부와 회귀 테스트도 함께 변경하세요.
  • docs/GAME-FLOW.md#L121-L121: 구현이 씬별 종료 규칙을 보장한 후에만 “JSON만 고치면 된다”는 설명을 유지하세요.
📍 Affects 3 files
  • src/data/stageRules.json#L28-L32 (this comment)
  • src/game/storyFlow.js#L67-L71
  • docs/GAME-FLOW.md#L121-L121
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/data/stageRules.json` around lines 28 - 32, 종료 경로가 선택지 발생 씬을 기준으로 결정되도록
수정하세요. src/data/stageRules.json 28-32의 stageExit를 완료 씬 인덱스별 규칙으로 재구성하고,
src/game/storyFlow.js 67-71의 resolveStageExit가 씬 인덱스를 받아 해당 씬의 byChoice만 조회하도록
호출부와 회귀 테스트를 갱신하세요. 구현이 씬별 규칙을 보장한 뒤 docs/GAME-FLOW.md 121의 “JSON만 고치면 된다” 설명을
유지하세요.

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.

1 participant