-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
153 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace com\tyme\culture\ren; | ||
|
||
|
||
use com\tyme\culture\Element; | ||
use com\tyme\culture\Luck; | ||
use com\tyme\LoopTyme; | ||
|
||
/** | ||
* 小六壬 | ||
* @author 6tail | ||
* @package com\tyme\culture\ren | ||
*/ | ||
class MinorRen extends LoopTyme | ||
{ | ||
static array $NAMES = ['大安', '留连', '速喜', '赤口', '小吉', '空亡']; | ||
|
||
protected function __construct(int $index = null, string $name = null) | ||
{ | ||
if ($index !== null) { | ||
parent::__construct(self::$NAMES, $index); | ||
} else if ($name !== null) { | ||
parent::__construct(self::$NAMES, null, $name); | ||
} | ||
} | ||
|
||
static function fromIndex(int $index): static | ||
{ | ||
return new static($index); | ||
} | ||
|
||
static function fromName(string $name): static | ||
{ | ||
return new static(null, $name); | ||
} | ||
|
||
function next(int $n): static | ||
{ | ||
return self::fromIndex($this->nextIndex($n)); | ||
} | ||
|
||
/** | ||
* 吉凶 | ||
* @return Luck 吉凶 | ||
*/ | ||
function getLuck(): Luck | ||
{ | ||
return Luck::fromIndex($this->index % 2); | ||
} | ||
|
||
/** | ||
* 五行 | ||
* @return Element 五行 | ||
*/ | ||
function getElement(): Element | ||
{ | ||
return Element::fromIndex([0, 4, 1, 3, 0, 2][$this->index]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters