Skip to content

Commit e4a1446

Browse files
authored
Merge pull request #1 from fortune-fun/master
lgtm
2 parents 856b792 + 973ab01 commit e4a1446

18 files changed

Lines changed: 576 additions & 1668 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@
1010

1111
# Output of the go coverage tool, specifically when used with LiteIDE
1212
*.out
13+
go.sum
14+
.vscode
15+
.~lock.*.csv#

compress.go

Lines changed: 0 additions & 67 deletions
This file was deleted.

data.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package yi
2+
3+
import (
4+
"embed"
5+
"encoding/csv"
6+
"io/fs"
7+
)
8+
9+
//go:embed data
10+
var DataFiles embed.FS
11+
12+
func readData(f fs.File) ([][]string, error) {
13+
r := csv.NewReader(f)
14+
r.Comma = ','
15+
r.Comment = '#'
16+
17+
// skip first line
18+
if _, err := r.Read(); err != nil {
19+
return [][]string{}, err
20+
}
21+
22+
records, err := r.ReadAll()
23+
24+
if err != nil {
25+
return [][]string{}, err
26+
}
27+
28+
return records, nil
29+
}

data/64gua.csv

Lines changed: 65 additions & 0 deletions
Large diffs are not rendered by default.

data/81shu.csv

Lines changed: 82 additions & 0 deletions
Large diffs are not rendered by default.

data/8gua.csv

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
卦名,,,先天卦数,后天卦数,符号名称,二进(阳1),先天余数,五行,卦象代表,属性,五位,人事现象,身体部位,动物,地理位置,静物,季节,八门方位,紫白九星,天运九星,宅局九星,四吉凶位
2+
,0,,1,6,乾三连,7,1,阳金,,刚健,西北方,父、君,头、首,狮、马,观光区、较高处,珠宝、金玉,秋末,天门,六白,武曲,武曲,延年
3+
,1,,2,7,兑上缺,6,2,阴金,,喜悦,西方,少女,,,崩破之山地、泉,饮食用具、玩具,,惊门,七赤,破军,破军,绝命
4+
,2,,3,9,离中虚,5,3,阴火,,明丽,南方,中女,眼睛(血液系统),,炉灶、干旱地,字画、美术品,,景门,九紫,右弼,廉贞,五鬼
5+
,3,,4,3,震仰盂,4,4,阳木,,活动,东方,长男,足(神经系统),蜕鼠、蛇(龙),森林、闹区,木竹、乐器,,伤门,三碧,蚩尤,贪狼,生气
6+
,4,,5,4,巽下断,3,5,阴木,,进入,东南方,长女,,,果菜园、公园,木材、纤维品,春末,杜门,四禄,文昌,辅弼,伏位
7+
,5,,6,1,坎中满,2,6,阳水,,险陷,北方,中男,,,水边沼泽地,油、酒、醋、酱,,休门,一白,文曲,文曲,六煞
8+
,6,,7,8,艮覆碗,1,7,阴土,,停止,东北方,少男,,,丘陵、山路、墓园,石级、坟墓,多末,生门,八白,财帛,巨门,天医
9+
,7,,8,2,坤六断,0,0,阴土,,柔顺,西南方,,,,平地、山野、村落,水泥砖、瓦玉谷,夏末,鬼门,二黑,病符,禄存,祸害
10+
,,,,5,,,,,,,,,,,,,,,,,,

data/gua.data

-8.39 KB
Binary file not shown.

dayan.go

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package yi
2+
3+
import (
4+
"math/bits"
5+
"strconv"
6+
"strings"
7+
)
8+
9+
// DaYan ...
10+
type DaYan struct {
11+
Number int
12+
Lucky string
13+
NvMing string
14+
Max bool
15+
SkyNine string
16+
Comment string
17+
}
18+
19+
var daYanList map[int]*DaYan
20+
21+
func init() {
22+
daYanList = make(map[int]*DaYan)
23+
24+
file_81shu, err := DataFiles.Open("data/81shu.csv")
25+
if err != nil {
26+
panic(err)
27+
}
28+
29+
records, err := readData(file_81shu)
30+
31+
if err != nil {
32+
panic(err)
33+
}
34+
35+
for _, record := range records {
36+
bihua, err := strconv.ParseInt(record[0], 10, bits.UintSize)
37+
if err != nil {
38+
panic(err)
39+
}
40+
41+
var max bool = false
42+
maxstr := strings.TrimSpace(record[3])
43+
if maxstr == "最吉" {
44+
max = true
45+
}
46+
47+
dayan := DaYan{
48+
Number: int(bihua),
49+
Lucky: record[1],
50+
NvMing: record[2],
51+
Max: max,
52+
SkyNine: record[5],
53+
Comment: record[6],
54+
}
55+
56+
daYanList[dayan.Number-1] = &dayan
57+
}
58+
}
59+
60+
//IsNotSuitableSex 女性不宜此数
61+
func (dy DaYan) IsNotSuitableGirl() bool {
62+
return dy.NvMing == "凶"
63+
}
64+
65+
//IsMax 是否最大好运数
66+
func (dy DaYan) IsMax() bool {
67+
return dy.Max
68+
}
69+
70+
//GetDaYan 获取大衍之数
71+
func GetDaYan(idx int) DaYan {
72+
if idx <= 0 {
73+
panic("wrong idx")
74+
}
75+
i := (idx - 1) % 81
76+
77+
return *daYanList[i]
78+
}

docs/数理简介.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
周易卦爻成象都是自下而上(本项目记阳为0,阴为1)
3+
4+
阳为实线,阴为虚线,合之两仪
5+
6+
四象为下上两条线
7+
8+
八卦为下中上三条线,
9+
10+
先天八卦对应八个卦,
11+
12+
后天八卦在八卦基础上加上一个“中”成为九象,但是每项对应的数字发生了变化,变化的原因和“矩”的平衡性有关,
13+
14+
八卦再有下上两卦生成64卦,对应《周易》中64卦,
15+
16+
一个卦象有六条线,任何一个数对6取余(得0者记为6)得六爻之变数,
17+
对原有卦象取爻变(对应线取反)即得变卦,通常预示着所占卜之事的最终结果,
18+
19+
后边八卦由上下两卦生成八十一象,称为“矩”,与《老子》、《道德经》中81章对应,
20+
这部分,[《八卦九象和《老子》的创作方法、分章及章序》](https://zhuanlan.zhihu.com/p/90606767)有详述,
21+
22+
本项目对于81象吉凶以“大衍之数”冠名

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
module github.com/godcong/yi
1+
module yi
22

3-
go 1.12
3+
go 1.16
44

5-
require github.com/rakyll/statik v0.1.6
5+
replace github.com/godcong/yi => ../yi

0 commit comments

Comments
 (0)