forked from wcp1231/mahjong-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
majsoul_live.go
34 lines (28 loc) · 914 Bytes
/
majsoul_live.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
package main
import (
"fmt"
"time"
"github.com/EndlessCheng/mahjong-helper/util"
"strconv"
)
// 观战基本信息
type majsoulLiveRecordBaseInfo struct {
UUID string `json:"uuid"`
StartTime int64 `json:"start_time"`
GameConfig *majsoulGameConfig `json:"game_config"`
Players []_majsoulRecordAccount `json:"players"`
SeatList []int `json:"seat_list"`
}
func (i *majsoulLiveRecordBaseInfo) String() string {
const timeFormat = "2006-01-02 15:04:05"
output := fmt.Sprintf("%s\n开始于 %s\n\n", i.UUID, time.Unix(i.StartTime, 0).Format(timeFormat))
maxAccountID := 0
for _, account := range i.Players {
maxAccountID = util.MaxInt(maxAccountID, account.AccountID)
}
accountShownWidth := len(strconv.Itoa(maxAccountID))
for _, account := range i.Players {
output += fmt.Sprintf("%*d %s\n", accountShownWidth, account.AccountID, account.Nickname)
}
return output
}