forked from EndlessCheng/mahjong-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tenhou_test.go
executable file
·90 lines (82 loc) · 2.03 KB
/
tenhou_test.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
package main
import (
"testing"
"github.com/EndlessCheng/mahjong-helper/util"
"github.com/EndlessCheng/mahjong-helper/util/model"
)
func Test_parseTenhouMeld(t *testing.T) {
d := &tenhouRoundData{}
for _, s := range []string{
"43595",
"17511",
} {
t.Log(d._parseTenhouMeld(s))
}
}
func TestAnalysisTilesRisk(t *testing.T) {
debugMode = true
d := newGame(&tenhouRoundData{})
handsTiles34, _, err := util.StrToTiles34("123456789m 123456789p 123456789s 1234567z")
if err != nil {
t.Fatal(err)
}
globalDiscardTiles34, _, err := util.StrToTiles34("22m 158p 123789s 6z")
if err != nil {
t.Fatal(err)
}
for i, c := range handsTiles34 {
if c == 0 {
continue
}
d.leftCounts[i] -= c
if d.leftCounts[c] < 0 {
t.Fatal("参数有误: ", util.Mahjong[c])
}
}
for i, c := range globalDiscardTiles34 {
if c == 0 {
continue
}
d.leftCounts[i] -= c
if d.leftCounts[c] < 0 {
t.Fatal("参数有误: ", util.Mahjong[c])
}
d.globalDiscardTiles = append(d.globalDiscardTiles, i)
}
d.players[1].isReached = true
d.players[1].reachTileAtGlobal = 0
d.players[1].discardTiles = []int{1, 1, 1, 1, 12, 4, 5, 6}
d.players[2].isReached = true
d.players[2].reachTileAtGlobal = 7
d.players[2].discardTiles = []int{1, 1, 1, 1, 1}
d.players[3].discardTiles = []int{1, 1, 1, 1, 1}
d.players[3].melds = make([]*model.Meld, 2)
d.players[3].meldDiscardsAt = []int{2, 3}
d.players[3].latestDiscardAtGlobal = 10
table := d.analysisTilesRisk()
table.printWithHands(handsTiles34, d.leftCounts)
}
func TestReg(t *testing.T) {
d := &tenhouRoundData{
msg: &tenhouMessage{
Tag: "T123",
},
}
t.Log(d.IsSelfDraw() == true)
d.msg.Tag = "TATA"
t.Log(d.IsSelfDraw() == false)
d.msg.Tag = "T"
t.Log(d.IsSelfDraw() == false)
d.msg.Tag = "T1234"
t.Log(d.IsSelfDraw() == false)
d.msg.Tag = "D123"
t.Log(d.IsDiscard() == true)
d.msg.Tag = "E123"
t.Log(d.IsDiscard() == true)
d.msg.Tag = "EAAA"
t.Log(d.IsDiscard() == false)
d.msg.Tag = "E"
t.Log(d.IsDiscard() == false)
d.msg.Tag = "E123123"
t.Log(d.IsDiscard() == false)
}