|
|
|
@ -10,7 +10,7 @@ var commandRegistry map[string]*Command
|
|
|
|
|
|
|
|
|
|
type Command struct {
|
|
|
|
|
name string
|
|
|
|
|
help string
|
|
|
|
|
summary string
|
|
|
|
|
arity int
|
|
|
|
|
variadic bool
|
|
|
|
|
handler func(*Connection, ...string)
|
|
|
|
@ -58,7 +58,7 @@ func (c CommandSet) Commands() []Command {
|
|
|
|
|
|
|
|
|
|
var helpCommand = Command{
|
|
|
|
|
name: "help",
|
|
|
|
|
help: "helpful things to help you",
|
|
|
|
|
summary: "helpful things to help you",
|
|
|
|
|
handler: func(conn *Connection, args ...string) {
|
|
|
|
|
msg := `
|
|
|
|
|
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)
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
conn.Printf("%v: %v\n", cmdName, cmd.help)
|
|
|
|
|
conn.Printf("%v: %v\n", cmdName, cmd.summary)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
@ -128,7 +128,7 @@ Location: {{.Location}}
|
|
|
|
|
|
|
|
|
|
var statusCommand = Command{
|
|
|
|
|
name: "status",
|
|
|
|
|
help: "display your current status",
|
|
|
|
|
summary: "display your current status",
|
|
|
|
|
handler: func(conn *Connection, args ...string) {
|
|
|
|
|
conn.ConnectionState.PrintStatus(conn)
|
|
|
|
|
},
|
|
|
|
@ -138,13 +138,13 @@ var statusCommand = Command{
|
|
|
|
|
// is weird and circular, this is a special case.
|
|
|
|
|
var commandsCommand = Command{
|
|
|
|
|
name: "commands",
|
|
|
|
|
help: "gives you a handy list of commands",
|
|
|
|
|
summary: "gives you a handy list of commands",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func BroadcastCommand(sys *System) Command {
|
|
|
|
|
return Command{
|
|
|
|
|
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) {
|
|
|
|
|
msg := strings.Join(args, " ")
|
|
|
|
|
b := NewBroadcast(sys, msg)
|
|
|
|
@ -173,7 +173,7 @@ func NearbyCommand(sys *System) Command {
|
|
|
|
|
}
|
|
|
|
|
return Command{
|
|
|
|
|
name: "nearby",
|
|
|
|
|
help: "list nearby star systems",
|
|
|
|
|
summary: "list nearby star systems",
|
|
|
|
|
arity: 0,
|
|
|
|
|
handler: handler,
|
|
|
|
|
}
|
|
|
|
@ -181,7 +181,7 @@ func NearbyCommand(sys *System) Command {
|
|
|
|
|
|
|
|
|
|
var winCommand = Command{
|
|
|
|
|
name: "win",
|
|
|
|
|
help: "win the game.",
|
|
|
|
|
summary: "win the game.",
|
|
|
|
|
debug: true,
|
|
|
|
|
handler: func(conn *Connection, args ...string) {
|
|
|
|
|
conn.Win("win-command")
|
|
|
|
@ -190,7 +190,7 @@ var winCommand = Command{
|
|
|
|
|
|
|
|
|
|
var playersCommand = Command{
|
|
|
|
|
name: "players",
|
|
|
|
|
help: "lists the connected players",
|
|
|
|
|
summary: "lists the connected players",
|
|
|
|
|
handler: func(conn *Connection, args ...string) {
|
|
|
|
|
for other, _ := range conn.game.connections {
|
|
|
|
|
conn.Printf("%v\n", other.Name())
|
|
|
|
@ -200,7 +200,7 @@ var playersCommand = Command{
|
|
|
|
|
|
|
|
|
|
var balCommand = Command{
|
|
|
|
|
name: "bal",
|
|
|
|
|
help: "displays your current balance in space duckets",
|
|
|
|
|
summary: "displays your current balance in space duckets",
|
|
|
|
|
handler: func(conn *Connection, args ...string) {
|
|
|
|
|
fmt.Fprintln(conn, conn.money)
|
|
|
|
|
},
|
|
|
|
|