forked from EndlessCheng/mahjong-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
executable file
·101 lines (84 loc) · 2.45 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package main
import (
"flag"
"github.com/EndlessCheng/mahjong-helper/util"
"github.com/EndlessCheng/mahjong-helper/util/model"
"math/rand"
"strings"
"time"
)
var (
considerOldYaku bool
isMajsoul bool
isTenhou bool
isAnalysis bool
isInteractive bool
showImproveDetail bool
showAgariAboveShanten1 bool
showScore bool
showAllYakuTypes bool
humanDoraTiles string
port int
)
func init() {
rand.Seed(time.Now().UnixNano())
flag.BoolVar(&considerOldYaku, "old", false, "允许古役")
flag.BoolVar(&isMajsoul, "majsoul", false, "雀魂助手")
flag.BoolVar(&isTenhou, "tenhou", false, "天凤助手")
flag.BoolVar(&isAnalysis, "analysis", false, "分析模式")
flag.BoolVar(&isInteractive, "interactive", false, "交互模式")
flag.BoolVar(&isInteractive, "i", false, "同 -interactive")
flag.BoolVar(&showImproveDetail, "detail", false, "显示改良细节")
flag.BoolVar(&showAgariAboveShanten1, "agari", false, "显示听牌前的估计和率")
flag.BoolVar(&showAgariAboveShanten1, "a", false, "同 -agari")
flag.BoolVar(&showScore, "score", false, "显示局收支")
flag.BoolVar(&showScore, "s", false, "同 -score")
flag.BoolVar(&showAllYakuTypes, "yaku", false, "显示所有役种")
flag.BoolVar(&showAllYakuTypes, "y", false, "同 -yaku")
flag.StringVar(&humanDoraTiles, "dora", "", "指定哪些牌是宝牌")
flag.StringVar(&humanDoraTiles, "d", "", "同 -dora")
flag.IntVar(&port, "port", 12121, "指定服务端口")
flag.IntVar(&port, "p", 12121, "同 -port")
}
const (
platformTenhou = 0
platformMajsoul = 1
defaultPlatform = platformTenhou
)
var platforms = map[int]string{
platformTenhou: "天凤",
platformMajsoul: "雀魂",
}
func welcome() int {
return 0
}
func main() {
flag.Parse()
if version != versionDev {
go checkNewVersion(version)
}
util.SetConsiderOldYaku(considerOldYaku)
humanTiles := strings.Join(flag.Args(), " ")
humanTilesInfo := &model.HumanTilesInfo{
HumanTiles: humanTiles,
HumanDoraTiles: humanDoraTiles,
}
var err error
switch {
case isMajsoul:
err = runServer(true, port)
case isTenhou || isAnalysis:
err = runServer(false, port)
case isInteractive: // 交互模式
err = interact(humanTilesInfo)
case len(flag.Args()) > 0: // 静态分析
_, err = analysisHumanTiles(humanTilesInfo)
default: // 服务器模式
choose := welcome()
isHTTPS := choose == platformMajsoul
err = runServer(isHTTPS, port)
}
if err != nil {
errorExit(err)
}
}