公众授权版:normal · 1000 次 · 有效期至 2026-12-31
副本编号 LY-20261007-AC63(水印指纹已嵌入) 含 README、.gitignore;排除 .DS_Store / __pycache__ / .pytest_cache
This commit is contained in:
Vendored
+80
@@ -0,0 +1,80 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import List, Union
|
||||
|
||||
from tyme4py import LoopTyme
|
||||
from tyme4py.culture import Direction, Element
|
||||
|
||||
|
||||
class Dipper(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) -> Dipper:
|
||||
return cls(name)
|
||||
|
||||
@classmethod
|
||||
def from_index(cls, index: int) -> Dipper:
|
||||
return cls(index)
|
||||
|
||||
def next(self, n: int) -> Dipper:
|
||||
return Dipper(self.next_index(n))
|
||||
|
||||
|
||||
class NineStar(LoopTyme):
|
||||
"""九星"""
|
||||
NAMES: List[str] = ['一', '二', '三', '四', '五', '六', '七', '八', '九']
|
||||
"""名称"""
|
||||
COLORS: 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) -> NineStar:
|
||||
return cls(name)
|
||||
|
||||
@classmethod
|
||||
def from_index(cls, index: int) -> NineStar:
|
||||
return cls(index)
|
||||
|
||||
def next(self, n: int) -> NineStar:
|
||||
return NineStar(self.next_index(n))
|
||||
|
||||
def get_color(self) -> str:
|
||||
"""
|
||||
颜色
|
||||
:return: 颜色
|
||||
"""
|
||||
return self.COLORS[self.get_index()]
|
||||
|
||||
def get_element(self) -> Element:
|
||||
"""
|
||||
五行
|
||||
:return: 五行
|
||||
"""
|
||||
return self.get_direction().get_element()
|
||||
|
||||
def get_dipper(self) -> Dipper:
|
||||
"""
|
||||
北斗九星
|
||||
:return: 北斗九星
|
||||
"""
|
||||
return Dipper(self.get_index())
|
||||
|
||||
def get_direction(self) -> Direction:
|
||||
"""
|
||||
方位
|
||||
:return: 方位
|
||||
"""
|
||||
return Direction(self.get_index())
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f'{self.get_name()}{self.get_color()}{self.get_element().get_name()}'
|
||||
Reference in New Issue
Block a user