rename command help to summary

master
Jordan Orelli 6 years ago
parent aa6bd1ca9e
commit 15015a9d5b

@ -10,7 +10,7 @@ var commandRegistry map[string]*Command
type Command struct { type Command struct {
name string name string
help string summary string
arity int arity int
variadic bool variadic bool
handler func(*Connection, ...string) handler func(*Connection, ...string)
@ -57,8 +57,8 @@ func (c CommandSet) Commands() []Command {
} }
var helpCommand = Command{ var helpCommand = Command{
name: "help", name: "help",
help: "helpful things to help you", summary: "helpful things to help you",
handler: func(conn *Connection, args ...string) { handler: func(conn *Connection, args ...string) {
msg := ` msg := `
Exocolonus is a game of cunning text-based, real-time strategy. You play as Exocolonus is a game of cunning text-based, real-time strategy. You play as
@ -98,7 +98,7 @@ are farther away take longer to communicate with.
conn.Printf("no such command: %v\n", cmdName) conn.Printf("no such command: %v\n", cmdName)
continue continue
} }
conn.Printf("%v: %v\n", cmdName, cmd.help) conn.Printf("%v: %v\n", cmdName, cmd.summary)
} }
}, },
} }
@ -127,8 +127,8 @@ Location: {{.Location}}
`)) `))
var statusCommand = Command{ var statusCommand = Command{
name: "status", name: "status",
help: "display your current status", summary: "display your current status",
handler: func(conn *Connection, args ...string) { handler: func(conn *Connection, args ...string) {
conn.ConnectionState.PrintStatus(conn) conn.ConnectionState.PrintStatus(conn)
}, },
@ -137,14 +137,14 @@ var statusCommand = Command{
// this isn't a real command it just puts command in the list of commands, this // this isn't a real command it just puts command in the list of commands, this
// is weird and circular, this is a special case. // is weird and circular, this is a special case.
var commandsCommand = Command{ var commandsCommand = Command{
name: "commands", name: "commands",
help: "gives you a handy list of commands", summary: "gives you a handy list of commands",
} }
func BroadcastCommand(sys *System) Command { func BroadcastCommand(sys *System) Command {
return Command{ return Command{
name: "broadcast", name: "broadcast",
help: "broadcast a message for all systems to hear", summary: "broadcast a message for all systems to hear",
handler: func(c *Connection, args ...string) { handler: func(c *Connection, args ...string) {
msg := strings.Join(args, " ") msg := strings.Join(args, " ")
b := NewBroadcast(sys, msg) b := NewBroadcast(sys, msg)
@ -173,24 +173,24 @@ func NearbyCommand(sys *System) Command {
} }
return Command{ return Command{
name: "nearby", name: "nearby",
help: "list nearby star systems", summary: "list nearby star systems",
arity: 0, arity: 0,
handler: handler, handler: handler,
} }
} }
var winCommand = Command{ var winCommand = Command{
name: "win", name: "win",
help: "win the game.", summary: "win the game.",
debug: true, debug: true,
handler: func(conn *Connection, args ...string) { handler: func(conn *Connection, args ...string) {
conn.Win("win-command") conn.Win("win-command")
}, },
} }
var playersCommand = Command{ var playersCommand = Command{
name: "players", name: "players",
help: "lists the connected players", summary: "lists the connected players",
handler: func(conn *Connection, args ...string) { handler: func(conn *Connection, args ...string) {
for other, _ := range conn.game.connections { for other, _ := range conn.game.connections {
conn.Printf("%v\n", other.Name()) conn.Printf("%v\n", other.Name())
@ -199,8 +199,8 @@ var playersCommand = Command{
} }
var balCommand = Command{ var balCommand = Command{
name: "bal", name: "bal",
help: "displays your current balance in space duckets", summary: "displays your current balance in space duckets",
handler: func(conn *Connection, args ...string) { handler: func(conn *Connection, args ...string) {
fmt.Fprintln(conn, conn.money) fmt.Fprintln(conn, conn.money)
}, },

@ -84,7 +84,7 @@ func (c *Connection) ListCommands() {
sort.Strings(names) sort.Strings(names)
for _, name := range names { for _, name := range names {
cmd := c.GetCommand(name) cmd := c.GetCommand(name)
c.Printf("%-20s%s\n", name, cmd.help) c.Printf("%-20s%s\n", name, cmd.summary)
} }
c.Printf("\n") c.Printf("\n")
} }

@ -20,37 +20,37 @@ func Idle(sys *System) ConnectionState {
NearbyCommand(sys), NearbyCommand(sys),
Command{ Command{
name: "goto", name: "goto",
help: "travel between star systems", summary: "travel between star systems",
arity: 1, arity: 1,
handler: i.travelTo, handler: i.travelTo,
}, },
Command{ Command{
name: "bomb", name: "bomb",
help: "bomb another star system", summary: "bomb another star system",
arity: 1, arity: 1,
handler: i.bomb, handler: i.bomb,
}, },
Command{ Command{
name: "mine", name: "mine",
help: "mine the current system for resources", summary: "mine the current system for resources",
arity: 0, arity: 0,
handler: i.mine, handler: i.mine,
}, },
Command{ Command{
name: "info", name: "info",
help: "gives you information about the current star system", summary: "gives you information about the current star system",
arity: 0, arity: 0,
handler: i.info, handler: i.info,
}, },
Command{ Command{
name: "scan", name: "scan",
help: "scans the galaxy for signs of life", summary: "scans the galaxy for signs of life",
arity: 0, arity: 0,
handler: i.scan, handler: i.scan,
}, },
Command{ Command{
name: "make", name: "make",
help: "makes things", summary: "makes things",
handler: i.maek, handler: i.maek,
}, },
} }

@ -58,7 +58,7 @@ func (st *LobbyState) Enter(c *Connection) {
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
for { for {
c.Printf("\n\nwhat is your name, adventurer?\n") c.Printf("\n\nWhat is your name, adventurer?\n")
name, err := c.ReadString('\n') name, err := c.ReadString('\n')
if err == nil { if err == nil {
name = strings.TrimSpace(name) name = strings.TrimSpace(name)
@ -99,7 +99,7 @@ func (st *LobbyState) PrintStatus(c *Connection) {
var newGameCommand = Command{ var newGameCommand = Command{
name: "new", name: "new",
help: "starts a new game", summary: "starts a new game",
arity: 0, arity: 0,
variadic: false, variadic: false,
handler: func(c *Connection, args ...string) { handler: func(c *Connection, args ...string) {
@ -118,7 +118,7 @@ var newGameCommand = Command{
var joinGameCommand = Command{ var joinGameCommand = Command{
name: "join", name: "join",
help: "joins an existing game", summary: "joins an existing game",
arity: 1, arity: 1,
variadic: false, variadic: false,
handler: func(c *Connection, args ...string) { handler: func(c *Connection, args ...string) {

@ -19,13 +19,13 @@ func Mine(sys *System) ConnectionState {
NearbyCommand(sys), NearbyCommand(sys),
Command{ Command{
name: "stop", name: "stop",
help: "stops mining", summary: "stops mining",
arity: 0, arity: 0,
handler: m.stop, handler: m.stop,
}, },
Command{ Command{
name: "info", name: "info",
help: "gives you information about the current mining operation", summary: "gives you information about the current mining operation",
arity: 0, arity: 0,
handler: m.info, handler: m.info,
}, },

@ -26,14 +26,14 @@ func NewTravel(c *Connection, start, dest *System) ConnectionState {
balCommand, balCommand,
Command{ Command{
name: "progress", name: "progress",
help: "displays how far you are along your travel", summary: "displays how far you are along your travel",
arity: 0, arity: 0,
handler: t.progress, handler: t.progress,
}, },
Command{ Command{
name: "eta", name: "eta",
help: "displays estimated time of arrival", summary: "displays estimated time of arrival",
arity: 0, arity: 0,
handler: func(c *Connection, args ...string) { handler: func(c *Connection, args ...string) {
c.Printf("%v\n", t.remaining()) c.Printf("%v\n", t.remaining())
}, },

Loading…
Cancel
Save