scan shows shield energy

slack
Jordan Orelli 10 years ago
parent b03b607235
commit 5b827b036e

@ -177,10 +177,10 @@ func (c *Connection) Name() string {
} }
func (c *Connection) RecordScan() { func (c *Connection) RecordScan() {
fmt.Fprintln(c, "scanning known systems for signs of life") c.Printf("scanning known systems for signs of life\n")
c.lastScan = time.Now() c.lastScan = time.Now()
time.AfterFunc(1*time.Minute, func() { time.AfterFunc(options.scanTime, func() {
fmt.Fprintln(c, "scanner ready") c.Printf("scanner ready\n")
}) })
} }
@ -192,11 +192,11 @@ func (c *Connection) RecordBomb() {
} }
func (c *Connection) CanScan() bool { func (c *Connection) CanScan() bool {
return time.Since(c.lastScan) > 1*time.Minute return time.Since(c.lastScan) > options.scanTime
} }
func (c *Connection) NextScan() time.Duration { func (c *Connection) NextScan() time.Duration {
return -time.Since(c.lastScan.Add(time.Minute)) return -time.Since(c.lastScan.Add(options.scanTime))
} }
func (c *Connection) NextBomb() time.Duration { func (c *Connection) NextBomb() time.Duration {

@ -27,6 +27,7 @@ var options struct {
playerSpeed float64 playerSpeed float64
respawnFrames int64 respawnFrames int64
respawnTime time.Duration respawnTime time.Duration
scanTime time.Duration
speckPath string speckPath string
startBombs int startBombs int
startMoney int startMoney int
@ -128,4 +129,5 @@ func init() {
flag.IntVar(&options.startBombs, "start-bombs", 0, "number of bombs a player has at game start") flag.IntVar(&options.startBombs, "start-bombs", 0, "number of bombs a player has at game start")
flag.IntVar(&options.startMoney, "start-money", 1000, "amount of money a player has to start") flag.IntVar(&options.startMoney, "start-money", 1000, "amount of money a player has to start")
flag.DurationVar(&options.makeShieldTime, "shield-time", 15*time.Second, "time it takes to make a shield") flag.DurationVar(&options.makeShieldTime, "shield-time", 15*time.Second, "time it takes to make a shield")
flag.DurationVar(&options.scanTime, "scan-recharge", 1*time.Minute, "time it takes for scanners to recharge")
} }

@ -19,6 +19,8 @@ type scanResult struct {
dist float64 dist float64
players map[*Connection]bool players map[*Connection]bool
colonizedBy *Connection colonizedBy *Connection
shielded bool
shieldEnergy float64
} }
func (r *scanResult) Empty() bool { func (r *scanResult) Empty() bool {
@ -75,6 +77,10 @@ func (s *scan) hitSystem(sys *System, dist float64) scanResult {
system: sys, system: sys,
colonizedBy: sys.colonizedBy, colonizedBy: sys.colonizedBy,
dist: dist * 2.0, dist: dist * 2.0,
shielded: sys.Shield != nil,
}
if sys.Shield != nil {
r.shieldEnergy = sys.Shield.energy
} }
if sys.players != nil { if sys.players != nil {
r.players = make(map[*Connection]bool, len(sys.players)) r.players = make(map[*Connection]bool, len(sys.players))
@ -97,6 +103,10 @@ func (s *scan) echos() {
} }
s.origin.NotifyInhabitants("results from scan of %v:\n", res.system) s.origin.NotifyInhabitants("results from scan of %v:\n", res.system)
s.origin.NotifyInhabitants("\tdistance: %v\n", s.origin.DistanceTo(res.system)) s.origin.NotifyInhabitants("\tdistance: %v\n", s.origin.DistanceTo(res.system))
s.origin.NotifyInhabitants("\tshielded: %v\n", res.shielded)
if res.shielded {
s.origin.NotifyInhabitants("\tshield energy: %v\n", res.shieldEnergy)
}
inhabitants := res.playerNames() inhabitants := res.playerNames()
if inhabitants != nil { if inhabitants != nil {
s.origin.NotifyInhabitants("\tinhabitants: %v\n", inhabitants) s.origin.NotifyInhabitants("\tinhabitants: %v\n", inhabitants)
@ -104,5 +114,6 @@ func (s *scan) echos() {
if res.colonizedBy != nil { if res.colonizedBy != nil {
s.origin.NotifyInhabitants("\tcolonized by: %v\n", res.colonizedBy.Name()) s.origin.NotifyInhabitants("\tcolonized by: %v\n", res.colonizedBy.Name())
} }
} }
} }

Loading…
Cancel
Save