-
Notifications
You must be signed in to change notification settings - Fork 0
/
oob.go
60 lines (57 loc) · 1.76 KB
/
oob.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
package main
import (
"github.com/steveoc64/republique5/db"
"strings"
"time"
"github.com/sirupsen/logrus"
rp "github.com/steveoc64/republique5/proto"
"github.com/steveoc64/republique5/republique"
)
func oob(log *logrus.Logger, game string) error {
if !strings.HasSuffix(game, ".db") {
game = game + ".db"
}
db, err := db.OpenReadDB(log, game)
if err != nil {
return err
}
data := &rp.Game{}
err = db.Load("game", "state", data)
if err != nil {
return err
}
println("Game:", game)
println("Date:", time.Unix(data.GameTime.Seconds, 0).UTC().Format(republique.DateTimeFormat))
print("Table: ", data.TableX, "x", data.TableY, " ft tabletop\n")
for _, team := range data.Scenario.GetTeams() {
println(" =============================================================================")
println(" Team", team.Name, "AccessCode =", team.AccessCode, "GameName =", team.GameName)
println("")
for _, player := range team.GetPlayers() {
println(" Player AccessCode =", player.GetAccessCode())
for _, commander := range player.GetCommanders() {
c := team.GetCommandByCommanderName(commander)
if c != nil {
println("")
print(" (", c.Id, ") ", c.Name, " - ", commander, ": ")
println("")
for _, unit := range c.Units {
print(" - (", unit.Id, ") ")
print(unit.LabelString())
}
for _, subCommand := range c.Subcommands {
print(" (", subCommand.Id, ") ", subCommand.Name, " - ", subCommand.CommanderName)
println("")
for _, unit := range subCommand.Units {
print(" - (", unit.Id, ") ")
println(unit.LabelString())
}
}
}
}
println("")
println(" -------------------------------------------------------------------------")
}
}
return nil
}