|
|
@ -7,7 +7,6 @@ import (
|
|
|
|
|
|
|
|
|
|
|
|
type IdleState struct {
|
|
|
|
type IdleState struct {
|
|
|
|
CommandSuite
|
|
|
|
CommandSuite
|
|
|
|
NopEnter
|
|
|
|
|
|
|
|
NopExit
|
|
|
|
NopExit
|
|
|
|
*System
|
|
|
|
*System
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -16,7 +15,6 @@ func Idle(sys *System) ConnectionState {
|
|
|
|
i := &IdleState{System: sys}
|
|
|
|
i := &IdleState{System: sys}
|
|
|
|
i.CommandSuite = CommandSet{
|
|
|
|
i.CommandSuite = CommandSet{
|
|
|
|
balCommand,
|
|
|
|
balCommand,
|
|
|
|
commandsCommand,
|
|
|
|
|
|
|
|
helpCommand,
|
|
|
|
helpCommand,
|
|
|
|
playersCommand,
|
|
|
|
playersCommand,
|
|
|
|
Command{
|
|
|
|
Command{
|
|
|
@ -49,10 +47,20 @@ func Idle(sys *System) ConnectionState {
|
|
|
|
arity: 0,
|
|
|
|
arity: 0,
|
|
|
|
handler: i.info,
|
|
|
|
handler: i.info,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
Command{
|
|
|
|
|
|
|
|
name: "scan",
|
|
|
|
|
|
|
|
help: "scans the galaxy for signs of life",
|
|
|
|
|
|
|
|
arity: 0,
|
|
|
|
|
|
|
|
handler: i.scan,
|
|
|
|
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return i
|
|
|
|
return i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (i *IdleState) Enter(c *Connection) {
|
|
|
|
|
|
|
|
i.System.Arrive(c)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (i *IdleState) String() string {
|
|
|
|
func (i *IdleState) String() string {
|
|
|
|
return fmt.Sprintf("idle on %v", i.System)
|
|
|
|
return fmt.Sprintf("idle on %v", i.System)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -115,3 +123,11 @@ func (i *IdleState) mine(c *Connection, args ...string) {
|
|
|
|
func (i *IdleState) info(c *Connection, args ...string) {
|
|
|
|
func (i *IdleState) info(c *Connection, args ...string) {
|
|
|
|
c.Printf("Currently idle on system %v\n", i.System)
|
|
|
|
c.Printf("Currently idle on system %v\n", i.System)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (i *IdleState) scan(c *Connection, args ...string) {
|
|
|
|
|
|
|
|
if time.Since(c.lastScan) < 1*time.Minute {
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
c.Printf("Scanning the galaxy for signs of life...\n")
|
|
|
|
|
|
|
|
currentGame.Register(NewScan(i.System))
|
|
|
|
|
|
|
|
}
|
|
|
|