fix: 신강·신약을 득령 먼저 보고 판정 — 월령 오행이 일간을 도우면 +0.15, 45~55%는 중화 (未월 己土가 시주 하나로 신약이 되던 문제)
This commit is contained in:
1 parent
b9dd0f203d
commit
263f01b4f1
9 files changed
+43
-11
No files matched your search
@@ -54,6 +54,7 @@ class SajuMe(WebPacketProtocol):
|
||||
elements: dict[str, float] = Field({}, description="오행 세력 점수 木火土金水 (월지 30·일지 20·나머지 10, 지지는 지장간 날 수로 나눔)")
|
||||
top_element: Optional[str] = Field(None, description="가장 센 오행")
|
||||
strong: Optional[bool] = Field(None, description="신강이면 true, 신약이면 false")
|
||||
strength: Optional[str] = Field(None, description="신강 · 중화 · 신약 (득령이면 돕는 몫에 가산, 45~55% 사이는 중화)")
|
||||
support: Optional[float] = Field(None, description="일간을 뺀 점수 중 일간을 돕는 기운 몫 0~1")
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ def _res(r: Reading) -> Res_Saju:
|
||||
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,
|
||||
elements=strength.elements, top_element=strength.top, strong=strength.strong, strength=strength.label, 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],
|
||||
|
||||
@@ -10,7 +10,10 @@ POSITION_POINTS = {
|
||||
("year", "stem"): 10, ("year", "branch"): 10, ("month", "stem"): 10, ("month", "branch"): 30,
|
||||
("day", "stem"): 10, ("day", "branch"): 20, ("hour", "stem"): 10, ("hour", "branch"): 10,
|
||||
}
|
||||
STRONG_FROM = 0.5 # 일간을 뺀 점수 중 비겁·인성 몫이 이 이상이면 신강
|
||||
# 월령: 태어난 달의 오행. 일간 오행이 이와 같거나(왕) 달이 일간을 생하면(상) 득령. 강약은 득령을 먼저 본다
|
||||
SEASON_ELEMENT = dict(zip("寅卯巳午申酉亥子辰戌丑未", "木木火火金金水水土土土土"))
|
||||
DEUK_RYEONG_BONUS = 0.15 # 득령이면 돕는 몫에 더한다
|
||||
STRONG_FROM, WEAK_BELOW = 0.55, 0.45 # (돕는 몫 + 득령 가산) 이 이상이면 신강, 미만이면 신약, 사이는 중화
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -18,7 +21,12 @@ class Strength:
|
||||
elements: dict[str, float] # 오행별 점수 (일간 포함), 木火土金水 순
|
||||
top: str # 가장 센 오행
|
||||
support: float # 일간을 뺀 점수 중 일간을 돕는 오행(같은 오행·생해 주는 오행) 몫 0~1
|
||||
strong: bool
|
||||
deuk_ryeong: bool
|
||||
label: str # 신강 · 중화 · 신약
|
||||
|
||||
@property
|
||||
def strong(self) -> bool:
|
||||
return self.label == "신강"
|
||||
|
||||
|
||||
def char_points(chart: Chart) -> list[tuple[str, str, str, float]]:
|
||||
@@ -48,4 +56,7 @@ def chart_strength(chart: Chart) -> Strength:
|
||||
support += points if el in helpers else 0.0
|
||||
elements = {k: round(v, 1) for k, v in elements.items()}
|
||||
ratio = round(support / others, 3)
|
||||
return Strength(elements, max(elements, key=elements.get), ratio, ratio >= STRONG_FROM)
|
||||
deuk = SEASON_ELEMENT[chart.month.branch] in helpers
|
||||
judged = ratio + (DEUK_RYEONG_BONUS if deuk else 0.0)
|
||||
label = "신강" if judged >= STRONG_FROM else "신약" if judged < WEAK_BELOW else "중화"
|
||||
return Strength(elements, max(elements, key=elements.get), ratio, deuk, label)
|
||||
@@ -36,7 +36,7 @@ async def test_reading_for_anyone_gives_me_today_and_cards(offline):
|
||||
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
|
||||
assert r["me"]["top_element"] == "木" and r["me"]["strong"] is True and r["me"]["strength"] == "신강" 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
|
||||
# 근거 줄은 쉬운 말 + 괄호 용어, 숫자 없이
|
||||
|
||||
@@ -269,6 +269,15 @@ def test_summer_earth_chart_reads_hot_and_dry_not_rainy():
|
||||
assert climate.strength.top == "土" and climate.strength.strong
|
||||
|
||||
|
||||
def test_month_rooted_day_master_stays_strong_whatever_the_hour():
|
||||
# 未월 己土는 득령(월령 土) — 시주가 물·쇠라도 신강, 득령 없는 같은 몫이면 낮게
|
||||
for h in range(0, 24, 2):
|
||||
s = chart_strength(make_chart(date(1959, 7, 16), time(h, 30)))
|
||||
assert s.deuk_ryeong and s.label == "신강", (h, s)
|
||||
winter = chart_strength(make_chart(date(1959, 12, 20))) # 子월 — 己土 득령 아님
|
||||
assert not winter.deuk_ryeong
|
||||
|
||||
|
||||
def test_month_dries_summer_earth_and_soaks_winter_earth():
|
||||
assert seasoned("己", "未")[1] < 0 < seasoned("己", "子")[1]
|
||||
assert seasoned("壬", "未")[0] > seasoned("壬", "子")[0]
|
||||
|
||||
+3
-2
@@ -7,7 +7,7 @@
|
||||
| 단계 | 하는 일 | 코드 |
|
||||
|---|---|---|
|
||||
| 1. 네 기둥 | 연주는 입춘, 월주는 절입 시각(천문 계산), 일주·시주는 출생지 지방평균시(서머타임 걷어냄)로 가른다 | `services/saju/pillars.py`, `birth.py`, `solar_terms.py` |
|
||||
| 2. 오행 세력 | 자리 점수(월지 30·일지 20·나머지 10)를 지지는 지장간 날 수대로 나눠 오행별로 더한다. 일간을 돕는 몫이 50% 이상이면 신강 | `services/saju/strength.py` |
|
||||
| 2. 오행 세력 | 자리 점수(월지 30·일지 20·나머지 10)를 지지는 지장간 날 수대로 나눠 오행별로 더한다. 일간을 돕는 몫 + 득령 가산 0.15 가 55% 이상 신강, 45% 미만 신약, 사이 중화 | `services/saju/strength.py` |
|
||||
| 3. 조후(내 기운) | 글자마다 한난·조습 값을 두고, 태어난 달(월령)이 다른 글자를 데우거나 식힌다. 흙은 계절 따라 마르고 젖는다. 자리 점수로 평균 → '따뜻·마름' 같은 결 + 계절 = 기운 장면 | `services/saju/climate.py` |
|
||||
| 4. 사주 점수 | 50에서 시작, 오늘 일진의 십성·원국과의 합충형파해·도화·홍염을 더한다 | `services/saju/daily.py` |
|
||||
| 5. 날씨 궁합 | 시간별 체감·습도·비가 내 조후를 균형 쪽으로 옮기는지. 50이 보통 | `services/saju/climate.py` |
|
||||
@@ -36,7 +36,8 @@
|
||||
- 예: 월지 未 30점 → 丁(화) 9, 乙(목) 3, 己(토) 18.
|
||||
- `elements`: 일간 포함 오행별 합. `top`: 가장 큰 오행(같으면 木火土金水 순 앞).
|
||||
- `support` = (일간 빼고) 일간과 같은 오행 + 일간을 생하는 오행 점수 ÷ 일간 뺀 점수 합. 시주가 있으면 분모 100.
|
||||
- `strong` = support ≥ 0.5 (신강).
|
||||
- 득령 = 월지 계절 오행(寅卯 木, 巳午 火, 申酉 金, 亥子 水, 辰戌丑未 土)이 일간과 같거나 일간을 생함. 득령이면 support 에 0.15 를 더해 판정.
|
||||
- `label` = (support + 득령 가산) ≥ 0.55 신강, < 0.45 신약, 사이 중화. 강약은 득령을 먼저 본다 (10/29 사용자 결정 — 未월 己土가 시주 하나로 신약이 되던 문제).
|
||||
- 근거: 득령(월지)·득지(일지)·득세 판단, 월지 30·일지 20·그 외 10 배점은 흔히 쓰는 예시 배점.
|
||||
- 화면: API `me.elements`·`top_element`·`strong`·`support`, 기둥별 `stem_ten_god`·`branch_ten_god`(지지는 정기 기준) → 사주 명식 카드.
|
||||
|
||||
|
||||
+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`, `strength`(신강·신약), `top_element`(가장 센 오행) | `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` |
|
||||
|
||||
@@ -19,7 +19,11 @@ const CARD_ICON: Record<string, string> = { when: 'alarm_clock', do: 'check_mark
|
||||
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 STRENGTH_WORD: Record<string, string> = {
|
||||
신강: '나를 돕는 기운이 센 사주. 태어난 달(월령)의 힘을 먼저 봐요',
|
||||
중화: '나를 돕는 기운과 다른 기운이 비슷한 사주',
|
||||
신약: '나를 돕는 기운이 약한 사주',
|
||||
}
|
||||
const TEN_GOD_WORD: Record<string, string> = {
|
||||
비견: '나와 같은 기운',
|
||||
겁재: '나와 같지만 겨루는 기운',
|
||||
@@ -207,7 +211,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, strength: r.me?.strong == null ? '' : r.me.strong ? '신강' : '신약', top_element: r.me?.top_element ?? '' })
|
||||
track('saju_view', { scene: r.me?.scene ?? '', score: r.today.score, strength: r.me?.strength ?? '', 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>
|
||||
@@ -356,7 +360,7 @@ function MeCard({ r, onEdit }: { r: ResSaju; onEdit: () => void }) {
|
||||
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 ? '신강' : '신약'
|
||||
const strength = me.strength ?? (me.strong == null ? null : me.strong ? '신강' : '신약')
|
||||
return (
|
||||
<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 && (
|
||||
|
||||
@@ -3855,6 +3855,12 @@ export type SajuMe = {
|
||||
* 신강이면 true, 신약이면 false
|
||||
*/
|
||||
strong?: boolean | null;
|
||||
/**
|
||||
* Strength
|
||||
*
|
||||
* 신강 · 중화 · 신약 (득령이면 돕는 몫에 가산, 45~55% 사이는 중화)
|
||||
*/
|
||||
strength?: string | null;
|
||||
/**
|
||||
* Support
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user