feat: 사주 명식 카드 — 오행 세력 막대·가장 센 오행 그림, 신강·신약, 기둥별 십성·일간 '나'·월령, 용어 풀이 (API me.elements·strong·십성 추가, GA saju_view 에 strength·top_element)
This commit is contained in:
1 parent
63db0b725b
commit
d7f891fddb
14 files changed
+131
-15
No files matched your search
@@ -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` |
|
||||
|
||||
## 진행 순서
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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
|
||||
# 근거 줄은 쉬운 말 + 괄호 용어, 숫자 없이
|
||||
|
||||
@@ -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. 조후 (내 기운)
|
||||
|
||||
|
||||
+1
-1
@@ -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` |
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 8.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 9.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 8.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
+74
-11
@@ -17,6 +17,21 @@ const SEEN_KEY = 'nalssigak.b.sajuSeen'
|
||||
const EL_COLOR: Record<string, [string, string]> = { 木: ['#2f8a4c', '#e3f6ea'], 火: ['#d9442f', '#ffe6e0'], 土: ['#a8761a', '#fbf0d6'], 金: ['#6b7486', '#eef0f4'], 水: ['#2d4a8a', '#e3ebfb'] }
|
||||
const CARD_ICON: Record<string, string> = { when: 'alarm_clock', do: 'check_mark_button', avoid: 'warning', good: 'sparkles', wear: 'tshirt' }
|
||||
const POS_WORD: Record<string, string> = { hour: '시', day: '일', month: '월', year: '연' }
|
||||
const EL_WORD: Record<string, string> = { 木: '나무', 火: '불', 土: '흙', 金: '쇠', 水: '물' }
|
||||
const EL_ART: Record<string, string> = { 木: 'wood', 火: 'fire', 土: 'earth', 金: 'metal', 水: 'water' }
|
||||
const STRENGTH_WORD: Record<string, string> = { 신강: '나를 돕는 기운이 절반이 넘는 사주', 신약: '나를 돕는 기운이 절반보다 적은 사주' }
|
||||
const TEN_GOD_WORD: Record<string, string> = {
|
||||
비견: '나와 같은 기운',
|
||||
겁재: '나와 같지만 겨루는 기운',
|
||||
식신: '내가 만들어 내는 기운',
|
||||
상관: '내가 드러내는 기운',
|
||||
편재: '내가 크게 굴리는 재물',
|
||||
정재: '내가 차곡차곡 모으는 재물',
|
||||
편관: '나를 세게 다잡는 기운',
|
||||
정관: '나를 바르게 이끄는 기운',
|
||||
편인: '나를 돕는 남다른 지혜',
|
||||
정인: '나를 돕는 배움·도움',
|
||||
}
|
||||
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 <p className="m-0 px-4 py-16 text-center font-semibold text-(--ink2)">사주를 풀고 있어요…</p>
|
||||
@@ -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 (
|
||||
<Panel icon={me.scene_icon} title={`내 기운 · ${me.scene.replace(/ 기운$/, '')}`} right={<button type="button" onClick={onEdit} className="cursor-pointer text-xs font-extrabold text-(--orange)">생년월일 바꾸기</button>}>
|
||||
<p className="m-0 text-[14px] font-semibold text-(--ink2)">{me.scene_desc}</p>
|
||||
<Panel icon={me.scene_icon} title="사주 명식" right={<button type="button" onClick={onEdit} className="cursor-pointer text-xs font-extrabold text-(--orange)">생년월일 바꾸기</button>}>
|
||||
{me.top_element && strength && (
|
||||
<div className="flex items-center gap-3">
|
||||
<img src={`/saju/${EL_ART[me.top_element]}.webp`} alt="" className="size-16 shrink-0 object-contain" />
|
||||
<div className="min-w-0">
|
||||
<p className="m-0 font-jua text-[18px] leading-snug">
|
||||
{EL_WORD[me.top_element]}({me.top_element}) 기운이 가장 센 {strength} 사주
|
||||
</p>
|
||||
<p className="m-0 mt-0.5 text-[13px] font-semibold text-(--ink2)">
|
||||
나를 돕는 기운 {Math.round((me.support ?? 0) * 100)}% · {me.scene}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{total > 0 && (
|
||||
<>
|
||||
<div className="mt-2.5 flex h-2.5 overflow-hidden rounded-full" role="img" aria-label={els.map(([k, v]) => `${k} ${Math.round(v)}`).join(', ')}>
|
||||
{els.map(([k, v]) => (
|
||||
<span key={k} style={{ width: `${(v / total) * 100}%`, background: EL_COLOR[k]?.[0] }} />
|
||||
))}
|
||||
</div>
|
||||
<div className="mt-1.5 flex justify-between text-[12px] font-extrabold">
|
||||
{els.map(([k, v]) => (
|
||||
<span key={k} className="flex items-center gap-0.5" style={{ color: EL_COLOR[k]?.[0] }}>
|
||||
<img src={`/saju/${EL_ART[k]}.webp`} alt="" className="size-5 object-contain" />
|
||||
{k} {Math.round(v)}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
<div className="mt-3 grid grid-cols-4 gap-1.5 text-center">
|
||||
{(me.hour_known ? cols : [null, ...cols]).map((p, i) => (
|
||||
<div key={p?.position ?? `none-${i}`} className="flex flex-col gap-1">
|
||||
<span className="text-[11px] font-extrabold text-(--ink3)">{p ? POS_WORD[p.position] : '시'}</span>
|
||||
<span className="text-[11px] font-extrabold text-(--ink3)">{p ? `${POS_WORD[p.position]}주` : '시주'}</span>
|
||||
{p ? (
|
||||
<>
|
||||
<Char c={p.stem} ko={p.stem_ko} el={p.stem_element} />
|
||||
<span className={cx('text-[11.5px] font-extrabold', p.position === 'day' ? 'text-(--orange)' : 'text-(--ink2)')}>{p.position === 'day' ? '나' : p.stem_ten_god}</span>
|
||||
<Char c={p.stem} ko={p.stem_ko} el={p.stem_element} me={p.position === 'day'} />
|
||||
<Char c={p.branch} ko={p.branch_ko} el={p.branch_element} />
|
||||
<span className="text-[11.5px] font-extrabold text-(--ink2)">{p.branch_ten_god}</span>
|
||||
{p.position === 'month' && <span className="text-[10.5px] font-extrabold text-(--ink3)">월령</span>}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<span className="grid flex-1 place-items-center rounded-xl bg-[#f1f3f7] text-[12px] font-extrabold text-[#a0a8ba]">시각 모름</span>
|
||||
</>
|
||||
<span className="grid flex-1 place-items-center rounded-xl bg-[#f1f3f7] px-1 text-[12px] font-extrabold text-[#a0a8ba]">시각 모름</span>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<p className="m-0 mt-2 text-[11.5px] font-semibold text-(--ink3)">태어난 연·월·일·시의 여덟 글자(사주팔자)예요. 색은 나무·불·흙·쇠·물 다섯 기운이에요.</p>
|
||||
<ul className="m-0 mt-3 list-none border-t border-(--line) p-0 pt-2.5 text-[12.5px] leading-relaxed font-semibold text-(--ink2)">
|
||||
{strength && (
|
||||
<li>
|
||||
<b className="text-(--ink)">{strength}</b> = {STRENGTH_WORD[strength]}
|
||||
</li>
|
||||
)}
|
||||
{gods.map((g) => (
|
||||
<li key={g}>
|
||||
<b className="text-(--ink)">{g}</b> = {TEN_GOD_WORD[g]}
|
||||
</li>
|
||||
))}
|
||||
<li>
|
||||
<b className="text-(--ink)">월령</b> = 태어난 달의 계절 기운. 명식에서 가장 크게 봐요
|
||||
</li>
|
||||
</ul>
|
||||
{(me.need?.length ?? 0) > 0 && <p className="m-0 mt-2 text-[13px] font-bold">내 기운에 좋은 날씨: {me.need!.join(' · ')}</p>}
|
||||
{me.jeol_warning && <p className="m-0 mt-1 text-xs font-semibold text-[#c2471b]">태어난 날에 절기가 바뀌어요. 태어난 시각을 넣어야 달 기둥이 정확해요.</p>}
|
||||
</Panel>
|
||||
)
|
||||
}
|
||||
|
||||
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 (
|
||||
<span className="rounded-xl py-1.5" style={{ background: bg, color: fg }}>
|
||||
<span className={cx('rounded-xl py-1.5', me && 'ring-2 ring-(--orange)')} style={{ background: bg, color: fg }}>
|
||||
<b className="block font-batang text-[22px] leading-tight">{c}</b>
|
||||
<small className="text-[10.5px] font-extrabold">{ko}</small>
|
||||
</span>
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -3769,6 +3769,32 @@ export type SajuMe = {
|
||||
* 내 기운에 필요한 것 (따뜻함·마른 공기 등)
|
||||
*/
|
||||
need?: Array<string>;
|
||||
/**
|
||||
* 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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user