diff --git a/bomb.go b/bomb.go index 068909a..1ea91bc 100644 --- a/bomb.go +++ b/bomb.go @@ -54,7 +54,10 @@ type MakeBombState struct { func MakeBomb(s *System) ConnectionState { m := &MakeBombState{System: s} m.CommandSuite = CommandSet{ + BroadcastCommand(s), balCommand, + helpCommand, + playersCommand, } return m } diff --git a/commands.go b/commands.go index fa19da9..3c8e0f5 100644 --- a/commands.go +++ b/commands.go @@ -112,17 +112,18 @@ var commandsCommand = Command{ }, } -// var broadcastCommand = &Command{ -// name: "broadcast", -// help: "broadcast a message for all systems to hear", -// handler: func(conn *Connection, args ...string) { -// msg := strings.Join(args, " ") -// system := conn.System() -// b := NewBroadcast(system, msg) -// log_info("player %s send broadcast from system %s: %v\n", conn.Name(), system.Label(), msg) -// currentGame.Register(b) -// }, -// } +func BroadcastCommand(sys *System) Command { + return Command{ + name: "broadcast", + help: "broadcast a message for all systems to hear", + handler: func(c *Connection, args ...string) { + msg := strings.Join(args, " ") + b := NewBroadcast(sys, msg) + log_info("player %s send broadcast from system %v: %v\n", c.Name(), sys, msg) + currentGame.Register(b) + }, + } +} // var colonizeCommand = &Command{ // name: "colonize", diff --git a/idle.go b/idle.go index b4e01fb..5f1b0cc 100644 --- a/idle.go +++ b/idle.go @@ -17,6 +17,7 @@ func Idle(sys *System) ConnectionState { balCommand, helpCommand, playersCommand, + BroadcastCommand(sys), Command{ name: "goto", help: "travel between star systems", diff --git a/mining.go b/mining.go index 87a419f..9df85e8 100644 --- a/mining.go +++ b/mining.go @@ -16,6 +16,7 @@ func Mine(sys *System) ConnectionState { balCommand, helpCommand, playersCommand, + BroadcastCommand(sys), Command{ name: "stop", help: "stops mining",