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() {
fmt.Fprintln(c, "scanning known systems for signs of life")
c.Printf("scanning known systems for signs of life\n")
c.lastScan = time.Now()
time.AfterFunc(1*time.Minute, func() {
fmt.Fprintln(c, "scanner ready")
time.AfterFunc(options.scanTime, func() {
c.Printf("scanner ready\n")
})
}
@ -192,11 +192,11 @@ func (c *Connection) RecordBomb() {
}
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 {
return -time.Since(c.lastScan.Add(time.Minute))
return -time.Since(c.lastScan.Add(options.scanTime))
}
func (c *Connection) NextBomb() time.Duration {

@ -27,6 +27,7 @@ var options struct {
playerSpeed float64
respawnFrames int64
respawnTime time.Duration
scanTime time.Duration
speckPath string
startBombs 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.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.scanTime, "scan-recharge", 1*time.Minute, "time it takes for scanners to recharge")
}

@ -15,10 +15,12 @@ type scan struct {
}
type scanResult struct {
system *System
dist float64
players map[*Connection]bool
colonizedBy *Connection
system *System
dist float64
players map[*Connection]bool
colonizedBy *Connection
shielded bool
shieldEnergy float64
}
func (r *scanResult) Empty() bool {
@ -75,6 +77,10 @@ func (s *scan) hitSystem(sys *System, dist float64) scanResult {
system: sys,
colonizedBy: sys.colonizedBy,
dist: dist * 2.0,
shielded: sys.Shield != nil,
}
if sys.Shield != nil {
r.shieldEnergy = sys.Shield.energy
}
if sys.players != nil {
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("\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()
if inhabitants != nil {
s.origin.NotifyInhabitants("\tinhabitants: %v\n", inhabitants)
@ -104,5 +114,6 @@ func (s *scan) echos() {
if res.colonizedBy != nil {
s.origin.NotifyInhabitants("\tcolonized by: %v\n", res.colonizedBy.Name())
}
}
}

Loading…
Cancel
Save