diff --git a/TODO.md b/TODO.md index e91d063..43c92c8 100644 --- a/TODO.md +++ b/TODO.md @@ -100,7 +100,7 @@ | [ ] | **[결정 필요]** 날씨 사주 화면·문구 — '내 기운'(계절·날씨 장면 16종), 점수 → 사주 풀이 → 계절·날씨 한 스푼, 하루 풀이를 '오늘의 결정 카드'(언제·미룰 것·입을 것/갈 곳·이번 주 날짜)로 줄지, 규칙별 의미 사전·문구 검토, 기운 장면 그림 | 사용자 피드백 10/28 | 기획서 '날씨 사주 기획 v2', '계정 레벨·날씨 사주 UI 기획' | | [ ] | **[결정 필요]** 날씨 사주 Codex 검수(10/28) 중 반영 안 한 것: ① 금전·일 날짜 추천("큰돈 쓰거나 계약할 일은 10/31(토)") — Codex는 운세로 계약·면접 날짜를 정해 주지 말고 점검 행동만 주라고 했으나, 사주 앱 장르상 날짜가 핵심이라 유지하고 그날 점수 60 이상일 때만 고르게 함 ② 점수를 '참고 점수'로 부를지 ③ 결과 위에 출생 정보 요약·칸 이동 메뉴, 사주 글자 표 접기 ④ 11월부터 올해 운 자리에 내년 미리 보기 — 올해·내년을 따로 고르게 할지 ⑤ 연애운 성별 기준(남 재성·여 관성)을 '전통 기준'이라고 더 밝힐지 | Codex 검수 `/tmp/sweep/codex-review.md` | `backend/services/saju_service.py`, `frontend/src/b/SajuPage.tsx` | | [x] | 사주 보정(10/29 사용자 지적: 토 많은 未월생이 '장맛비 기운'으로 나옴) — 월령 바탕값, 흙은 계절 따라 조습, 未 0.9, 오행 세력(지장간 날 수·월지 30·일지 20·그 외 10)·신강신약, 균형 축 이름은 세력 1위 오행 쪽 | 『궁통보감』 三夏己土, 계산식 `docs/사주_계산식.md` | `backend/services/saju/climate.py`, `strength.py` | -| [ ] | **[결정 필요]** 오행 세력·신강신약을 화면에 보여 줄지와 문구 — 계산은 있음(`chart_strength`), API·화면엔 아직 안 나감 | 문구 검토 먼저 | `backend/services/saju/strength.py`, `frontend/src/b/SajuPage.tsx` | +| [ ] | **[결정 필요]** 사주 명식 C안(요약 먼저형) 문구 확인 — 10/29 사용자 C안 선택, 구현은 `fix/saju-climate`(제목 '사주 명식', '흙(土) 기운이 가장 센 신강 사주', 오행 막대, 십성·'나'·월령 표시, 용어 풀이 10개). 문구 확인 뒤 병합 | 시안 v5, 사용자 선택 10/29 | `frontend/src/b/SajuPage.tsx` `MeCard`, `backend/router/v1/saju/saju.py` | ## 진행 순서 diff --git a/backend/router/v1/saju/protocol.py b/backend/router/v1/saju/protocol.py index 20d04f0..169b937 100644 --- a/backend/router/v1/saju/protocol.py +++ b/backend/router/v1/saju/protocol.py @@ -37,6 +37,8 @@ class SajuPillar(WebPacketProtocol): branch_ko: str stem_element: str = Field(description="木火土金水") branch_element: str + stem_ten_god: Optional[str] = Field(None, description="천간 십성 (일간은 없음)") + branch_ten_god: str = Field(description="지지 십성 (정기 기준)") class SajuMe(WebPacketProtocol): @@ -49,6 +51,10 @@ class SajuMe(WebPacketProtocol): season: Optional[str] = None climate: Optional[str] = Field(None, description="따뜻·마름 / 따뜻·촉촉 / 서늘·마름 / 서늘·촉촉") need: list[str] = Field([], description="내 기운에 필요한 것 (따뜻함·마른 공기 등)") + elements: dict[str, float] = Field({}, description="오행 세력 점수 木火土金水 (월지 30·일지 20·나머지 10, 지지는 지장간 날 수로 나눔)") + top_element: Optional[str] = Field(None, description="가장 센 오행") + strong: Optional[bool] = Field(None, description="신강이면 true, 신약이면 false") + support: Optional[float] = Field(None, description="일간을 뺀 점수 중 일간을 돕는 기운 몫 0~1") class SajuCard(WebPacketProtocol): diff --git a/backend/router/v1/saju/saju.py b/backend/router/v1/saju/saju.py index 61858f0..2e774fd 100644 --- a/backend/router/v1/saju/saju.py +++ b/backend/router/v1/saju/saju.py @@ -11,6 +11,8 @@ from router.v1.saju.protocol import Req_Saju, Req_SajuBirth, Req_SajuMatch, Res_ from services import saju_text as T from services.level_service import UNLOCKS from services.saju.ganji import branch_element, ko, stem_element +from services.saju.rules import chart_ten_gods +from services.saju.strength import chart_strength from services.saju_service import Reading, SajuService, shown_saju, weather_points router = APIRouter(prefix="/v1/saju", tags=["saju"]) @@ -20,12 +22,16 @@ _WEEKDAY = "월화수목금토일" def _res(r: Reading) -> Res_Saju: c = r.chart pillars = [("year", c.year), ("month", c.month), ("day", c.day)] + ([("hour", c.hour)] if c.hour else []) + gods = chart_ten_gods(c.day_stem, dict(pillars)) + strength = chart_strength(c) today = r.today best = max(r.week, key=lambda d: d.score).day if r.week else None return Res_Saju( me=SajuMe( - pillars=[SajuPillar(position=pos, stem=p.stem, branch=p.branch, stem_ko=ko(p.stem), branch_ko=ko(p.branch), stem_element=stem_element(p.stem), branch_element=branch_element(p.branch)) for pos, p in pillars], + pillars=[SajuPillar(position=pos, stem=p.stem, branch=p.branch, stem_ko=ko(p.stem), branch_ko=ko(p.branch), stem_element=stem_element(p.stem), branch_element=branch_element(p.branch), + stem_ten_god=gods[pos]["stem"], branch_ten_god=gods[pos]["branch"]) for pos, p in pillars], hour_known=c.hour is not None, jeol_warning=c.jeol_on_birth_day, scene=r.scene[0], scene_desc=r.scene[1], scene_icon=r.scene_icon, need=r.need, + elements=strength.elements, top_element=strength.top, strong=strength.strong, support=strength.support, ), today=SajuToday( day=today.day, pillar=ko(today.facts.pillar.stem + today.facts.pillar.branch), ten_god=today.facts.stem_ten_god, title=T.TEN_GOD_TEXT[today.facts.stem_ten_god][0], diff --git a/backend/tests/test_saju_api.py b/backend/tests/test_saju_api.py index c0f3a8e..89e9008 100644 --- a/backend/tests/test_saju_api.py +++ b/backend/tests/test_saju_api.py @@ -35,6 +35,8 @@ async def test_reading_for_anyone_gives_me_today_and_cards(offline): r = (await c.post("/v1/saju/reading", json=BIRTH)).json() assert [p["stem"] + p["branch"] for p in r["me"]["pillars"]] == ["乙亥", "己卯", "甲辰"] and r["me"]["hour_known"] is False assert r["me"]["scene"].endswith("기운") and r["today"]["title"] and 0 <= r["today"]["score"] <= 100 + assert [(p.get("stem_ten_god"), p["branch_ten_god"]) for p in r["me"]["pillars"]] == [("겁재", "편인"), ("정재", "겁재"), (None, "편재")] + assert r["me"]["top_element"] == "木" and r["me"]["strong"] is True and r["me"]["elements"]["木"] == 58.3 kinds = [x["kind"] for x in r["today"]["cards"]] assert "when" in kinds and "do" in kinds and "wear" in kinds # 근거 줄은 쉬운 말 + 괄호 용어, 숫자 없이 diff --git a/docs/사주_계산식.md b/docs/사주_계산식.md index bf94980..08d5d95 100644 --- a/docs/사주_계산식.md +++ b/docs/사주_계산식.md @@ -38,6 +38,7 @@ - `support` = (일간 빼고) 일간과 같은 오행 + 일간을 생하는 오행 점수 ÷ 일간 뺀 점수 합. 시주가 있으면 분모 100. - `strong` = support ≥ 0.5 (신강). - 근거: 득령(월지)·득지(일지)·득세 판단, 월지 30·일지 20·그 외 10 배점은 흔히 쓰는 예시 배점. +- 화면: API `me.elements`·`top_element`·`strong`·`support`, 기둥별 `stem_ten_god`·`branch_ten_god`(지지는 정기 기준) → 사주 명식 카드. ## 3. 조후 (내 기운) diff --git a/docs/이벤트_추적.md b/docs/이벤트_추적.md index edda4cc..45169fc 100644 --- a/docs/이벤트_추적.md +++ b/docs/이벤트_추적.md @@ -54,7 +54,7 @@ GA4 태그(`gtag.js`, 측정 ID `G-D378J4X373`)를 `index.html`에 심고, 화 | `day_log` | 저녁 체크인을 적어 둠 (고쳐 적어도 보냄). 다녀온 곳 이름은 보내지 않음 | `mood`(1~5), `went_out`, `card_hit`(맞았어요 true·글쎄요 false·안 고름 null) | `fortune.tsx` `useTodayCard` | | `today_icon` | 오늘 탭 아이콘 줄에서 아이콘을 누름 | `icon`(`tarot`·`saju`·`game`·`foliage`·`shorts`·`myGak`·`talk`) | `todayIcons.tsx` `TodayIcons` | | `saju_input` | 날씨 사주 생년월일을 넣음 (생년월일 값은 보내지 않음) | `with_time` | `SajuPage.tsx` `BirthForm` | -| `saju_view` | 날씨 사주 결과가 뜸 | `scene`(내 기운 이름), `score` | `SajuPage.tsx` `Reading` | +| `saju_view` | 날씨 사주 결과가 뜸 | `scene`(내 기운 이름), `score`, `strength`(신강·신약), `top_element`(가장 센 오행) | `SajuPage.tsx` `Reading` | | `game_start` | 구름 합치기 한 판의 첫 그림을 떨어뜨림 (페이지만 열고 안 한 사람과 구분) | `again`(다시 하기로 시작), `logged_in`, `wind_ms`(오늘 우리 구 풍속) | `CloudMergePage.tsx` `onUp` | | `game_round` | 구름 합치기 라운드를 깸 | `round`(깬 라운드), `score`(그때 총점), `logged_in`(각을 받는지) | `CloudMergePage.tsx` `onScore` | | `game_over` | 구름 합치기가 넘쳐서 끝남 | `round`(끝난 라운드), `score`, `best`(최고 기록 갱신), `drops`(떨어뜨린 횟수) | `CloudMergePage.tsx` `onOver` | diff --git a/frontend/public/saju/earth.webp b/frontend/public/saju/earth.webp new file mode 100644 index 0000000..4ff503c Binary files /dev/null and b/frontend/public/saju/earth.webp differ diff --git a/frontend/public/saju/fire.webp b/frontend/public/saju/fire.webp new file mode 100644 index 0000000..719afc5 Binary files /dev/null and b/frontend/public/saju/fire.webp differ diff --git a/frontend/public/saju/metal.webp b/frontend/public/saju/metal.webp new file mode 100644 index 0000000..a81f802 Binary files /dev/null and b/frontend/public/saju/metal.webp differ diff --git a/frontend/public/saju/water.webp b/frontend/public/saju/water.webp new file mode 100644 index 0000000..e6cf957 Binary files /dev/null and b/frontend/public/saju/water.webp differ diff --git a/frontend/public/saju/wood.webp b/frontend/public/saju/wood.webp new file mode 100644 index 0000000..ae2d643 Binary files /dev/null and b/frontend/public/saju/wood.webp differ diff --git a/frontend/src/b/SajuPage.tsx b/frontend/src/b/SajuPage.tsx index 10863c6..6e11e78 100644 --- a/frontend/src/b/SajuPage.tsx +++ b/frontend/src/b/SajuPage.tsx @@ -17,6 +17,21 @@ const SEEN_KEY = 'nalssigak.b.sajuSeen' const EL_COLOR: Record = { 木: ['#2f8a4c', '#e3f6ea'], 火: ['#d9442f', '#ffe6e0'], 土: ['#a8761a', '#fbf0d6'], 金: ['#6b7486', '#eef0f4'], 水: ['#2d4a8a', '#e3ebfb'] } const CARD_ICON: Record = { when: 'alarm_clock', do: 'check_mark_button', avoid: 'warning', good: 'sparkles', wear: 'tshirt' } const POS_WORD: Record = { hour: '시', day: '일', month: '월', year: '연' } +const EL_WORD: Record = { 木: '나무', 火: '불', 土: '흙', 金: '쇠', 水: '물' } +const EL_ART: Record = { 木: 'wood', 火: 'fire', 土: 'earth', 金: 'metal', 水: 'water' } +const STRENGTH_WORD: Record = { 신강: '나를 돕는 기운이 절반이 넘는 사주', 신약: '나를 돕는 기운이 절반보다 적은 사주' } +const TEN_GOD_WORD: Record = { + 비견: '나와 같은 기운', + 겁재: '나와 같지만 겨루는 기운', + 식신: '내가 만들어 내는 기운', + 상관: '내가 드러내는 기운', + 편재: '내가 크게 굴리는 재물', + 정재: '내가 차곡차곡 모으는 재물', + 편관: '나를 세게 다잡는 기운', + 정관: '나를 바르게 이끄는 기운', + 편인: '나를 돕는 남다른 지혜', + 정인: '나를 돕는 배움·도움', +} const HOURS = Array.from({ length: 24 }, (_, i) => i) const MINUTES = Array.from({ length: 60 }, (_, i) => i) const dayWord = (iso: string, weekday: string) => `${Number(iso.slice(5, 7))}/${Number(iso.slice(8, 10))}(${weekday})` @@ -192,7 +207,7 @@ function Reading({ birth, onEdit }: { birth: Birth; onEdit: () => void }) { useEffect(() => { if (!r?.today) return markSeen() - track('saju_view', { scene: r.me?.scene ?? '', score: r.today.score }) + track('saju_view', { scene: r.me?.scene ?? '', score: r.today.score, strength: r.me?.strong == null ? '' : r.me.strong ? '신강' : '신약', top_element: r.me?.top_element ?? '' }) }, [r]) if (q.isPending) return

사주를 풀고 있어요…

@@ -292,37 +307,85 @@ function DecisionCard({ c }: { c: SajuCard }) { function MeCard({ r, onEdit }: { r: ResSaju; onEdit: () => void }) { const me = r.me! const cols = [...me.pillars].reverse() + const els = Object.entries(me.elements ?? {}) + const total = els.reduce((a, [, v]) => a + v, 0) + const gods = [...new Set(me.pillars.flatMap((p) => [p.stem_ten_god, p.branch_ten_god]).filter((g): g is string => !!g && g in TEN_GOD_WORD))] + const strength = me.strong == null ? null : me.strong ? '신강' : '신약' return ( - 생년월일 바꾸기}> -

{me.scene_desc}

+ 생년월일 바꾸기}> + {me.top_element && strength && ( +
+ +
+

+ {EL_WORD[me.top_element]}({me.top_element}) 기운이 가장 센 {strength} 사주 +

+

+ 나를 돕는 기운 {Math.round((me.support ?? 0) * 100)}% · {me.scene} +

+
+
+ )} + {total > 0 && ( + <> +
`${k} ${Math.round(v)}`).join(', ')}> + {els.map(([k, v]) => ( + + ))} +
+
+ {els.map(([k, v]) => ( + + + {k} {Math.round(v)} + + ))} +
+ + )}
{(me.hour_known ? cols : [null, ...cols]).map((p, i) => (
- {p ? POS_WORD[p.position] : '시'} + {p ? `${POS_WORD[p.position]}주` : '시주'} {p ? ( <> - + {p.position === 'day' ? '나' : p.stem_ten_god} + + {p.branch_ten_god} + {p.position === 'month' && 월령} ) : ( - <> - 시각 모름 - + 시각 모름 )}
))}
-

태어난 연·월·일·시의 여덟 글자(사주팔자)예요. 색은 나무·불·흙·쇠·물 다섯 기운이에요.

+
    + {strength && ( +
  • + {strength} = {STRENGTH_WORD[strength]} +
  • + )} + {gods.map((g) => ( +
  • + {g} = {TEN_GOD_WORD[g]} +
  • + ))} +
  • + 월령 = 태어난 달의 계절 기운. 명식에서 가장 크게 봐요 +
  • +
{(me.need?.length ?? 0) > 0 &&

내 기운에 좋은 날씨: {me.need!.join(' · ')}

} {me.jeol_warning &&

태어난 날에 절기가 바뀌어요. 태어난 시각을 넣어야 달 기둥이 정확해요.

}
) } -function Char({ c, ko, el }: { c: string; ko: string; el: string }) { +function Char({ c, ko, el, me }: { c: string; ko: string; el: string; me?: boolean }) { const [fg, bg] = EL_COLOR[el] ?? ['#28304a', '#f3f6fb'] return ( - + {c} {ko} diff --git a/frontend/src/lib/analytics.ts b/frontend/src/lib/analytics.ts index 5534170..f0db84c 100644 --- a/frontend/src/lib/analytics.ts +++ b/frontend/src/lib/analytics.ts @@ -32,7 +32,7 @@ type Events = { day_log: { mood: number; went_out: boolean; card_hit: boolean | null } today_icon: { icon: string } saju_input: { with_time: boolean } - saju_view: { scene: string; score: number } + saju_view: { scene: string; score: number; strength: string; top_element: string } game_start: { again: boolean; logged_in: boolean; wind_ms: number } game_round: { round: number; score: number; logged_in: boolean } game_over: { round: number; score: number; best: boolean; drops: number } diff --git a/shared/api/client/types.gen.ts b/shared/api/client/types.gen.ts index 4d10a28..412d86d 100644 --- a/shared/api/client/types.gen.ts +++ b/shared/api/client/types.gen.ts @@ -3769,6 +3769,32 @@ export type SajuMe = { * 내 기운에 필요한 것 (따뜻함·마른 공기 등) */ need?: Array; + /** + * Elements + * + * 오행 세력 점수 木火土金水 (월지 30·일지 20·나머지 10, 지지는 지장간 날 수로 나눔) + */ + elements?: { + [key: string]: number; + }; + /** + * Top Element + * + * 가장 센 오행 + */ + top_element?: string | null; + /** + * Strong + * + * 신강이면 true, 신약이면 false + */ + strong?: boolean | null; + /** + * Support + * + * 일간을 뺀 점수 중 일간을 돕는 기운 몫 0~1 + */ + support?: number | null; }; /** @@ -3845,6 +3871,18 @@ export type SajuPillar = { * Branch Element */ branch_element: string; + /** + * Stem Ten God + * + * 천간 십성 (일간은 없음) + */ + stem_ten_god?: string | null; + /** + * Branch Ten God + * + * 지지 십성 (정기 기준) + */ + branch_ten_god: string; }; /**