diff --git a/commands.go b/commands.go index 90059eb..4304ea8 100644 --- a/commands.go +++ b/commands.go @@ -37,11 +37,11 @@ var nearbyCommand = &Command{ return } fmt.Fprintf(conn, "--------------------------------------------------------------------------------\n") - fmt.Fprintf(conn, "%-4s %-20s %s\n", "id", "name", "travel time") + fmt.Fprintf(conn, "%-4s %-20s %s\n", "id", "name", "distance") fmt.Fprintf(conn, "--------------------------------------------------------------------------------\n") for _, neighbor := range neighbors { other := index[neighbor.id] - fmt.Fprintf(conn, "%-4d %-20s %v\n", other.id, other.name, system.TravelTimeTo(other)) + fmt.Fprintf(conn, "%-4d %-20s %v\n", other.id, other.name, neighbor.distance) } fmt.Fprintf(conn, "--------------------------------------------------------------------------------\n") }, diff --git a/connection.go b/connection.go index da2bd9c..c93b861 100644 --- a/connection.go +++ b/connection.go @@ -105,8 +105,19 @@ func (c *Connection) Tick(frame int64) { c.land() } case mining: - c.Deposit(options.miningRate) - log_info("%v", c.money) + sys := c.System() + if sys == nil { + log_error("a player is in the mining state with no system. what?") + break + } + if sys.money <= 0 { + fmt.Fprintf(c, "system %s is all out of space duckets.\n", sys.Label()) + c.StopMining() + } else { + c.Deposit(1) + sys.money -= 1 + log_info("%v", c.money) + } default: log_error("connection %v has invalid state wtf", c) } @@ -197,7 +208,7 @@ func (c *Connection) MadeKill(victim *Connection) { func (c *Connection) Mine() { switch c.state { case idle: - fmt.Fprintf(c, "now mining %s with a payout rate of %v\n", c.System().name, c.System().miningRate) + fmt.Fprintf(c, "now mining %s. %v space duckets remaining.\n", c.System().name, c.System().money) fmt.Fprintln(c, "(press enter to stop mining)") c.state = mining default: diff --git a/main.go b/main.go index 1952bfb..1b4e436 100644 --- a/main.go +++ b/main.go @@ -15,7 +15,8 @@ import ( var options struct { lightSpeed float64 frameRate int - miningRate int + moneySigma float64 + moneyMean float64 playerSpeed float64 bombSpeed float64 economic int @@ -115,8 +116,9 @@ func main() { func init() { flag.Float64Var(&options.lightSpeed, "light-speed", 0.01, "speed of light in parsecs per frame") flag.IntVar(&options.frameRate, "frame-rate", 100, "frame rate, in frames per second") - flag.IntVar(&options.miningRate, "mining-rate", 1, "mining rate, in duckets per frame") flag.Float64Var(&options.playerSpeed, "player-speed", 0.8, "player travel speed, relative to C, the speed of light") flag.Float64Var(&options.bombSpeed, "bomb-speed", 0.9, "bomb travel speed, relattive to C, the speed of light") flag.IntVar(&options.economic, "economic", 25000, "amount of money needed to win economic victory") + flag.Float64Var(&options.moneyMean, "money-mean", 10000, "mean amount of money on a system") + flag.Float64Var(&options.moneySigma, "money-sigma", 1500, "standard deviation in money per system") } diff --git a/system.go b/system.go index 9e26b0c..6aaed0c 100644 --- a/system.go +++ b/system.go @@ -19,9 +19,9 @@ type System struct { planets int name string players map[*Connection]bool - miningRate float64 colonizedBy *Connection distances []Ray + money int64 } func (s *System) Tick(frame int64) { @@ -246,7 +246,8 @@ func indexSystems() map[int]*System { } index[p.id] = &p nameIndex[p.name] = &p - p.miningRate = rand.Float64() + p.money = int64(rand.NormFloat64()*options.moneySigma + options.moneyMean) + log_info("seeded system %s with %v monies", p.Label(), p.money) } return index }