diff --git a/commands.go b/commands.go index 905c676..d80d0d2 100644 --- a/commands.go +++ b/commands.go @@ -23,6 +23,8 @@ var infoCommand = &Command{ help: "gives you some info about your current position", handler: func(conn *Connection, args ...string) { fmt.Fprintf(conn, "current planet: %s\n", conn.System().name) + fmt.Fprintf(conn, "bombs: %d\n", conn.bombs) + fmt.Fprintf(conn, "money: %d space duckets\n", conn.money) }, } @@ -236,6 +238,11 @@ 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 { @@ -262,7 +269,24 @@ var bombCommand = &Command{ }, } +var mkBombCommand = &Command{ + name: "mkbomb", + help: "make a bomb. Costs 800 space duckets", + handler: func(conn *Connection, args ...string) { + if conn.money < 800 { + fmt.Fprintf(conn, "not enough money! Bombs cost 800 space duckets to build, you only have %d in the bank.\n", conn.money) + return + } + conn.money -= 800 + conn.bombs += 1 + fmt.Fprintf(conn, "built a bomb!\n") + fmt.Fprintf(conn, "bombs: %d\n", conn.bombs) + fmt.Fprintf(conn, "money: %d space duckets\n", conn.money) + }, +} + func bomb(conn *Connection, to *System) { + conn.bombs -= 1 delay := conn.System().TimeTo(to) delay = time.Duration(int64(float64(delay/time.Nanosecond) * 1.1)) After(delay, func() { diff --git a/session.go b/session.go index 0216e21..2bf0c20 100644 --- a/session.go +++ b/session.go @@ -23,12 +23,14 @@ type Connection struct { money int64 mining bool colonies []*System + bombs int } func NewConnection(conn net.Conn) *Connection { c := &Connection{ Conn: conn, Reader: bufio.NewReader(conn), + bombs: 1, } connected[c] = true return c diff --git a/system.go b/system.go index 770f706..88ee3a4 100644 --- a/system.go +++ b/system.go @@ -78,7 +78,10 @@ func (s *System) Bombed(bomber *Connection) { conn.Die() bomber.MadeKill(conn) }) - s.colonizedBy = nil + if s.colonizedBy != nil { + fmt.Fprintf(s.colonizedBy, "your mining colony on %s has been destroyed!\n", s.name) + s.colonizedBy = nil + } for id, _ := range index { if id == s.id {