|
|
@ -18,18 +18,13 @@ func Idle(sys *System) ConnectionState {
|
|
|
|
helpCommand,
|
|
|
|
helpCommand,
|
|
|
|
playersCommand,
|
|
|
|
playersCommand,
|
|
|
|
BroadcastCommand(sys),
|
|
|
|
BroadcastCommand(sys),
|
|
|
|
|
|
|
|
NearbyCommand(sys),
|
|
|
|
Command{
|
|
|
|
Command{
|
|
|
|
name: "goto",
|
|
|
|
name: "goto",
|
|
|
|
help: "travel between star systems",
|
|
|
|
help: "travel between star systems",
|
|
|
|
arity: 1,
|
|
|
|
arity: 1,
|
|
|
|
handler: i.travelTo,
|
|
|
|
handler: i.travelTo,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Command{
|
|
|
|
|
|
|
|
name: "nearby",
|
|
|
|
|
|
|
|
help: "list nearby star systems",
|
|
|
|
|
|
|
|
arity: 0,
|
|
|
|
|
|
|
|
handler: i.nearby,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
Command{
|
|
|
|
Command{
|
|
|
|
name: "bomb",
|
|
|
|
name: "bomb",
|
|
|
|
help: "bomb another star system",
|
|
|
|
help: "bomb another star system",
|
|
|
@ -84,22 +79,6 @@ func (i *IdleState) travelTo(c *Connection, args ...string) {
|
|
|
|
c.SetState(NewTravel(c, i.System, dest))
|
|
|
|
c.SetState(NewTravel(c, i.System, dest))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (i *IdleState) nearby(c *Connection, args ...string) {
|
|
|
|
|
|
|
|
neighbors, err := i.Nearby(25)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
log_error("unable to get neighbors: %v", err)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
c.Printf("--------------------------------------------------------------------------------\n")
|
|
|
|
|
|
|
|
c.Printf("%-4s %-20s %s\n", "id", "name", "distance")
|
|
|
|
|
|
|
|
c.Printf("--------------------------------------------------------------------------------\n")
|
|
|
|
|
|
|
|
for _, neighbor := range neighbors {
|
|
|
|
|
|
|
|
other := index[neighbor.id]
|
|
|
|
|
|
|
|
c.Printf("%-4d %-20s %v\n", other.id, other.name, neighbor.distance)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
c.Printf("--------------------------------------------------------------------------------\n")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (i *IdleState) bomb(c *Connection, args ...string) {
|
|
|
|
func (i *IdleState) bomb(c *Connection, args ...string) {
|
|
|
|
if c.bombs <= 0 {
|
|
|
|
if c.bombs <= 0 {
|
|
|
|
c.Printf("Cannot send bomb: no bombs left! Build more bombs!\n")
|
|
|
|
c.Printf("Cannot send bomb: no bombs left! Build more bombs!\n")
|
|
|
|