systems now have a limited amount of mining resources

I did away with the whole mining rate thing.
slack
Jordan Orelli 10 years ago
parent e7472a6d10
commit 9daf5b2786

@ -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")
},

@ -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:

@ -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")
}

@ -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
}

Loading…
Cancel
Save