Files
ZiPingEightChar/vendor/tyme4py/culture/star/twelve.py
T
moxiaonian d9da4301cd 公众授权版:normal · 1000 次 · 有效期至 2026-12-31
副本编号 LY-20261007-AC63(水印指纹已嵌入)
含 README、.gitignore;排除 .DS_Store / __pycache__ / .pytest_cache
2026-10-07 17:29:52 +08:00

62 lines
1.6 KiB
Python

# -*- coding:utf-8 -*-
from __future__ import annotations
from typing import List, Union
from tyme4py import LoopTyme
from tyme4py.culture import Luck
class TwelveStar(LoopTyme):
"""黄道黑道十二神"""
NAMES: List[str] = ['青龙', '明堂', '天刑', '朱雀', '金匮', '天德', '白虎', '玉堂', '天牢', '玄武', '司命', '勾陈']
"""名称"""
def __init__(self, index_or_name: Union[int, str]):
super().__init__(self.NAMES, index_or_name)
@classmethod
def from_name(cls, name: str) -> TwelveStar:
return cls(name)
@classmethod
def from_index(cls, index: int) -> TwelveStar:
return cls(index)
def next(self, n: int) -> TwelveStar:
return TwelveStar(self.next_index(n))
def get_ecliptic(self) -> Ecliptic:
"""
黄道黑道
:return: 黄道黑道
"""
return Ecliptic([0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1][self.get_index()])
class Ecliptic(LoopTyme):
"""黄道黑道就两种,依次为:黄道、黑道。"""
NAMES: List[str] = ["黄道", "黑道"]
"""名称"""
def __init__(self, index_or_name: Union[int, str]):
super().__init__(self.NAMES, index_or_name)
@classmethod
def from_name(cls, name: str) -> Ecliptic:
return cls(name)
@classmethod
def from_index(cls, index: int) -> Ecliptic:
return cls(index)
def next(self, n: int) -> Ecliptic:
return Ecliptic(self.next_index(n))
def get_luck(self) -> Luck:
"""
吉凶
:return: 吉凶
"""
return Luck(self.get_index())