diff --git a/bomb.go b/bomb.go index cffacaa..3ce601f 100644 --- a/bomb.go +++ b/bomb.go @@ -11,6 +11,7 @@ type Bomb struct { origin *System target *System start time.Time + done bool fti int64 // frames to impact } @@ -30,13 +31,15 @@ func NewBomb(from *Connection, to *System) *Bomb { } func (b *Bomb) Dead() bool { - return b.fti <= 0 + return b.done } func (b *Bomb) Tick(frame int64) { b.fti -= 1 if b.fti <= 0 { b.target.Bombed(b.player) + b.done = true + log_info("bomb went off on %s", b.target.Label()) } } diff --git a/connection.go b/connection.go index c93b861..9565332 100644 --- a/connection.go +++ b/connection.go @@ -77,7 +77,7 @@ func (c *Connection) Login() { log_error("unable to create player record: %v", err) } fmt.Fprintf(c, "you look new around these parts, %s.\n", player.name) - fmt.Fprintf(c, `if you'd like a description of how to play, type the "help" command`) + fmt.Fprintf(c, `if you'd like a description of how to play, type the "help" command\n`) c.player = player } else { c.player = player @@ -94,13 +94,11 @@ func (c *Connection) Dead() bool { func (c *Connection) Tick(frame int64) { // fuck - switch c.state { case idle: case dead: case inTransit: c.travelRemaining -= 1 - log_info("player %s has remaining travel: %v", c.PlayerName(), c.travelRemaining) if c.travelRemaining == 0 { c.land() } @@ -116,7 +114,6 @@ func (c *Connection) Tick(frame int64) { } else { c.Deposit(1) sys.money -= 1 - log_info("%v", c.money) } default: log_error("connection %v has invalid state wtf", c) @@ -124,9 +121,11 @@ func (c *Connection) Tick(frame int64) { } func (c *Connection) TravelTo(dest *System) { - fmt.Fprintf(c, "traveling to: %s\n", dest.Label()) dist := c.System().DistanceTo(dest) c.travelRemaining = int64(dist / (options.lightSpeed * options.playerSpeed)) + t := time.Duration(c.travelRemaining) * (time.Second / time.Duration(options.frameRate)) + fmt.Fprintf(c, "traveling to: %s. ETA: %v\n", dest.Label(), t) + c.location.Leave(c) c.location = nil c.dest = dest c.state = inTransit // fuck everything about this @@ -135,6 +134,7 @@ func (c *Connection) TravelTo(dest *System) { func (c *Connection) land() { fmt.Fprintf(c, "you have arrived at %v\n", c.dest.Label()) c.location = c.dest + c.location.Arrive(c) c.dest = nil c.state = idle } @@ -199,6 +199,10 @@ func (c *Connection) NextBomb() time.Duration { } func (c *Connection) MadeKill(victim *Connection) { + if c == victim { + log_info("player %s commited suicide.", c.PlayerName()) + return + } c.kills += 1 if c.kills == 3 { c.Win("military") diff --git a/system.go b/system.go index 6aaed0c..6fe2db5 100644 --- a/system.go +++ b/system.go @@ -41,15 +41,15 @@ func (s *System) Reset() { func (s *System) Arrive(conn *Connection) { conn.SetSystem(s) - log_info("player %s has arrived at system %s", conn.PlayerName(), s.name) + log_info("player %s has arrived at system %s", conn.PlayerName(), s.Label()) if s.players == nil { s.players = make(map[*Connection]bool, 8) } s.players[conn] = true if s.planets == 1 { - fmt.Fprintf(conn, "you are in the system %s. There is %d planet here.\n", s.name, s.planets) + fmt.Fprintf(conn, "you are in the system %s. There is %d planet here.\n", s.Label(), s.planets) } else { - fmt.Fprintf(conn, "you are in the system %s. There are %d planets here.\n", s.name, s.planets) + fmt.Fprintf(conn, "you are in the system %s. There are %d planets here.\n", s.Label(), s.planets) } }