bomb counter goes down again

slack
Jordan Orelli 10 years ago
parent 060609470a
commit 1f94135775

@ -201,15 +201,10 @@ var bombCommand = &Command{
name: "bomb",
help: "bombs a system, with a big space bomb",
handler: func(conn *Connection, args ...string) {
if conn.bombs < 1 {
fmt.Fprintf(conn, "no more bombs left! build more bombs!\n")
return
}
dest_name := strings.Join(args, " ")
to, ok := nameIndex[dest_name]
if ok {
currentGame.Register(NewBomb(conn, to))
conn.SendBomb(to)
return
}
@ -224,11 +219,7 @@ var bombCommand = &Command{
fmt.Fprintf(conn, `oh dear, there doesn't seem to be a system with id %d\n`, id_n)
return
}
if !conn.CanBomb() {
fmt.Fprintf(conn, "weapons are still reloading. Can bomb again in %v\n", conn.NextBomb())
return
}
currentGame.Register(NewBomb(conn, to))
conn.SendBomb(to)
},
}

@ -121,6 +121,22 @@ func (c *Connection) TravelTo(dest *System) {
c.state = inTransit // fuck everything about this
}
func (c *Connection) SendBomb(target *System) {
if c.bombs <= 0 {
fmt.Fprintln(c, "cannot send bomb: no bombs left")
return
}
if time.Since(c.lastBomb) < 5*time.Second {
fmt.Fprintln(c, "cannod send bomb: bombs are reloading")
return
}
c.bombs -= 1
c.lastBomb = time.Now()
bomb := NewBomb(c, target)
currentGame.Register(bomb)
fmt.Fprintf(c, "sending bomb to system %v\n", target.Label())
}
func (c *Connection) land() {
fmt.Fprintf(c, "you have arrived at %v\n", c.dest.Label())
c.location = c.dest
@ -176,10 +192,6 @@ func (c *Connection) CanScan() bool {
return time.Since(c.lastScan) > 1*time.Minute
}
func (c *Connection) CanBomb() bool {
return time.Since(c.lastBomb) > 15*time.Second
}
func (c *Connection) NextScan() time.Duration {
return -time.Since(c.lastScan.Add(time.Minute))
}

Loading…
Cancel
Save