bombs are now consumables

pull/5/head
Jordan Orelli 10 years ago
parent 6f001cf6ba
commit 962c3bd108

@ -23,6 +23,8 @@ var infoCommand = &Command{
help: "gives you some info about your current position", help: "gives you some info about your current position",
handler: func(conn *Connection, args ...string) { handler: func(conn *Connection, args ...string) {
fmt.Fprintf(conn, "current planet: %s\n", conn.System().name) 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", name: "bomb",
help: "bombs a system, with a big space bomb", help: "bombs a system, with a big space bomb",
handler: func(conn *Connection, args ...string) { 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, " ") dest_name := strings.Join(args, " ")
to, ok := nameIndex[dest_name] to, ok := nameIndex[dest_name]
if ok { 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) { func bomb(conn *Connection, to *System) {
conn.bombs -= 1
delay := conn.System().TimeTo(to) delay := conn.System().TimeTo(to)
delay = time.Duration(int64(float64(delay/time.Nanosecond) * 1.1)) delay = time.Duration(int64(float64(delay/time.Nanosecond) * 1.1))
After(delay, func() { After(delay, func() {

@ -23,12 +23,14 @@ type Connection struct {
money int64 money int64
mining bool mining bool
colonies []*System colonies []*System
bombs int
} }
func NewConnection(conn net.Conn) *Connection { func NewConnection(conn net.Conn) *Connection {
c := &Connection{ c := &Connection{
Conn: conn, Conn: conn,
Reader: bufio.NewReader(conn), Reader: bufio.NewReader(conn),
bombs: 1,
} }
connected[c] = true connected[c] = true
return c return c

@ -78,7 +78,10 @@ func (s *System) Bombed(bomber *Connection) {
conn.Die() conn.Die()
bomber.MadeKill(conn) 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 { for id, _ := range index {
if id == s.id { if id == s.id {

Loading…
Cancel
Save