diff --git a/system.go b/system.go index 8f87435..dfc17e0 100644 --- a/system.go +++ b/system.go @@ -150,19 +150,47 @@ func randomSystem() (*System, error) { return planet, nil } +type scanResults struct { + life bool +} + +func (r *scanResults) negative() bool { + return !r.life +} + +func (r *scanResults) String() string { + if r.negative() { + return "negative" + } + if r.life { + return "life detected" + } + return "(none)" +} + func scanSystem(id int, reply int) { system := index[id] source := index[reply] delay := system.TimeTo(source) log_info("scan hit %s from %s after traveling for %v", system.name, source.name, delay) + + system.EachConn(func(conn *Connection) { + fmt.Fprintf(conn, "scan detected from %s\n", source.name) + }) + results := &scanResults{ + life: len(system.players) > 0, + } After(delay, func() { - deliverReply(source.id, system.id) + deliverReply(source.id, system.id, results) }) } -func deliverReply(id int, echo int) { +func deliverReply(id int, echo int, results *scanResults) { system := index[id] source := index[echo] delay := system.TimeTo(source) log_info("echo received at %s reflected from %s after traveling for %v", system.name, source.name, delay) + system.EachConn(func(conn *Connection) { + fmt.Fprintf(conn, "scan results from %s (%v away): %v\n", source.name, delay, results) + }) } diff --git a/work.go b/work.go index dc28e4a..bf1ce9f 100644 --- a/work.go +++ b/work.go @@ -68,7 +68,6 @@ func RunQueue() { if future.ts.After(time.Now()) { time.Sleep(future.ts.Sub(time.Now())) } - log_info("performing work") future.work() } }