Skip to content

Commit

Permalink
v1.1.2 优化十神计算逻辑;修复获取起运时间报错的问题。
Browse files Browse the repository at this point in the history
  • Loading branch information
6tail committed Aug 19, 2024
1 parent c8d49c4 commit 2fe8030
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 19 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@
3. 新增:天干五合、地支六合、地支六害。
4. 修复:获取当年第几周报错的问题。
5. 优化:性能。

## [1.1.2] - 2024-08-19
1. 优化:十神计算逻辑。
2. 修复:获取起运时间报错的问题。
8 changes: 4 additions & 4 deletions src/culture/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function next(int $n): static
}

/**
* 我生者(生)
* 我生者
*
* @return Element 五行
*/
Expand All @@ -49,7 +49,7 @@ function getReinforce(): static
}

/**
* 我克者(克)
* 我克者
*
* @return Element 五行
*/
Expand All @@ -59,7 +59,7 @@ function getRestrain(): static
}

/**
* 生我者(泄)
* 生我者
*
* @return Element 五行
*/
Expand All @@ -69,7 +69,7 @@ function getReinforced(): static
}

/**
* 克我者(耗)
* 克我者
*
* @return Element 五行
*/
Expand Down
3 changes: 2 additions & 1 deletion src/eightchar/provider/impl/China95ChildLimitProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/eightchar/provider/impl/DefaultChildLimitProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 5 additions & 13 deletions src/sixtycycle/HeavenStem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 2fe8030

Please sign in to comment.