From 2fe8030c7987cc79f2dfd97ad4aba5422d6652b8 Mon Sep 17 00:00:00 2001 From: 6tail <6tail@6tail.cn> Date: Mon, 19 Aug 2024 21:29:00 +0800 Subject: [PATCH] =?UTF-8?q?v1.1.2=20=E4=BC=98=E5=8C=96=E5=8D=81=E7=A5=9E?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E9=80=BB=E8=BE=91=EF=BC=9B=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E8=B5=B7=E8=BF=90=E6=97=B6=E9=97=B4=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++++ src/culture/Element.php | 8 ++++---- .../impl/China95ChildLimitProvider.php | 3 ++- .../impl/DefaultChildLimitProvider.php | 3 ++- src/sixtycycle/HeavenStem.php | 18 +++++------------- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a7287c..66091e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,3 +34,7 @@ 3. 新增:天干五合、地支六合、地支六害。 4. 修复:获取当年第几周报错的问题。 5. 优化:性能。 + +## [1.1.2] - 2024-08-19 +1. 优化:十神计算逻辑。 +2. 修复:获取起运时间报错的问题。 diff --git a/src/culture/Element.php b/src/culture/Element.php index c1e82b6..00b2951 100644 --- a/src/culture/Element.php +++ b/src/culture/Element.php @@ -39,7 +39,7 @@ function next(int $n): static } /** - * 我生者(生) + * 我生者 * * @return Element 五行 */ @@ -49,7 +49,7 @@ function getReinforce(): static } /** - * 我克者(克) + * 我克者 * * @return Element 五行 */ @@ -59,7 +59,7 @@ function getRestrain(): static } /** - * 生我者(泄) + * 生我者 * * @return Element 五行 */ @@ -69,7 +69,7 @@ function getReinforced(): static } /** - * 克我者(耗) + * 克我者 * * @return Element 五行 */ diff --git a/src/eightchar/provider/impl/China95ChildLimitProvider.php b/src/eightchar/provider/impl/China95ChildLimitProvider.php index d40b80a..cb146a6 100644 --- a/src/eightchar/provider/impl/China95ChildLimitProvider.php +++ b/src/eightchar/provider/impl/China95ChildLimitProvider.php @@ -30,9 +30,10 @@ function getInfo(SolarTime $birthTime, SolarTerm $term): ChildLimitInfo $d = $birthTime->getDay() + $day; $dc = $sm->getDayCount(); - if ($d > $dc) { + while ($d > $dc) { $d -= $dc; $sm = $sm->next(1); + $dc = $sm->getDayCount(); } return new ChildLimitInfo($birthTime, SolarTime::fromYmdHms($sm->getYear(), $sm->getMonth(), $d, $birthTime->getHour(), $birthTime->getMinute(), $birthTime->getSecond()), $year, $month, $day, 0, 0); diff --git a/src/eightchar/provider/impl/DefaultChildLimitProvider.php b/src/eightchar/provider/impl/DefaultChildLimitProvider.php index f940193..0cb9e49 100644 --- a/src/eightchar/provider/impl/DefaultChildLimitProvider.php +++ b/src/eightchar/provider/impl/DefaultChildLimitProvider.php @@ -46,9 +46,10 @@ function getInfo(SolarTime $birthTime, SolarTerm $term): ChildLimitInfo $sm = SolarMonth::fromYm($birthTime->getYear() + $year, $birthTime->getMonth())->next($month); $dc = $sm->getDayCount(); - if ($d > $dc) { + while ($d > $dc) { $d -= $dc; $sm = $sm->next(1); + $dc = $sm->getDayCount(); } return new ChildLimitInfo($birthTime, SolarTime::fromYmdHms($sm->getYear(), $sm->getMonth(), $d, $h, $mi, $birthTime->getSecond()), $year, $month, $day, $hour, $minute); diff --git a/src/sixtycycle/HeavenStem.php b/src/sixtycycle/HeavenStem.php index 77afa42..fdb2fa0 100644 --- a/src/sixtycycle/HeavenStem.php +++ b/src/sixtycycle/HeavenStem.php @@ -72,20 +72,12 @@ function getYinYang(): YinYang */ function getTenStar(HeavenStem $target): TenStar { - $hostElement = $this->getElement(); - $guestElement = $target->getElement(); - $index = 0; - $sameYinYang = $this->getYinYang()->equals($target->getYinYang()); - if ($hostElement->getReinforce()->equals($guestElement)) { - $index = 1; - } else if ($hostElement->getRestrain()->equals($guestElement)) { - $index = 2; - } else if ($guestElement->getRestrain()->equals($hostElement)) { - $index = 3; - } else if ($guestElement->getReinforce()->equals($hostElement)) { - $index = 4; + $targetIndex = $target->getIndex(); + $offset = $targetIndex - $this->index; + if ($this->index % 2 != 0 && $targetIndex % 2 == 0) { + $offset += 2; } - return TenStar::fromIndex($index * 2 + ($sameYinYang ? 0 : 1)); + return TenStar::fromIndex($offset); } /**