mining colonies no longer generate revenue when dead

pull/5/head
Jordan Orelli 10 years ago
parent 38f26291a8
commit 28681b15a6

@ -201,7 +201,7 @@ var colonizeCommand = &Command{
fn = func() { fn = func() {
reward := int64(rand.NormFloat64()*5.0 + 100.0*system.miningRate) reward := int64(rand.NormFloat64()*5.0 + 100.0*system.miningRate)
if system.colonizedBy != nil { if system.colonizedBy != nil {
system.colonizedBy.money += reward system.colonizedBy.Deposit(reward)
fmt.Fprintf(system.colonizedBy, "mining colony on %s pays you %d space duckets. total: %d space duckets.\n", system.name, reward, system.colonizedBy.money) fmt.Fprintf(system.colonizedBy, "mining colony on %s pays you %d space duckets. total: %d space duckets.\n", system.name, reward, system.colonizedBy.money)
} }
After(5*time.Second, fn) After(5*time.Second, fn)
@ -214,7 +214,7 @@ var colonizeCommand = &Command{
} }
if conn.money > 2000 { if conn.money > 2000 {
conn.money -= 2000 conn.Withdraw(2000)
system.colonizedBy = conn system.colonizedBy = conn
fmt.Fprintf(conn, "set up a mining colony on %s\n", conn.System().name) fmt.Fprintf(conn, "set up a mining colony on %s\n", conn.System().name)
After(5*time.Second, fn) After(5*time.Second, fn)
@ -279,7 +279,7 @@ var mkBombCommand = &Command{
fmt.Fprintf(conn, "not enough money! Bombs cost 800 space duckets to build, you only have %d in the bank.\n", conn.money) fmt.Fprintf(conn, "not enough money! Bombs cost 800 space duckets to build, you only have %d in the bank.\n", conn.money)
return return
} }
conn.money -= 800 conn.Withdraw(800)
conn.bombs += 1 conn.bombs += 1
fmt.Fprintf(conn, "built a bomb!\n") fmt.Fprintf(conn, "built a bomb!\n")
fmt.Fprintf(conn, "bombs: %d\n", conn.bombs) fmt.Fprintf(conn, "bombs: %d\n", conn.bombs)

@ -96,10 +96,16 @@ func (c *Connection) InTransit() bool {
func (c *Connection) RecordScan() { func (c *Connection) RecordScan() {
c.lastScan = time.Now() c.lastScan = time.Now()
After(1*time.Minute, func() {
fmt.Fprintln(c, "scanner ready")
})
} }
func (c *Connection) RecordBomb() { func (c *Connection) RecordBomb() {
c.lastBomb = time.Now() c.lastBomb = time.Now()
After(1500*time.Millisecond, func() {
fmt.Fprintln(c, "bomb arsenal reloaded")
})
} }
func (c *Connection) CanScan() bool { func (c *Connection) CanScan() bool {
@ -141,11 +147,25 @@ func (c *Connection) IsMining() bool {
} }
func (c *Connection) Payout() { func (c *Connection) Payout() {
if c.dead {
return
}
reward := int64(rand.NormFloat64()*5.0 + 100.0*c.System().miningRate) reward := int64(rand.NormFloat64()*5.0 + 100.0*c.System().miningRate)
c.money += reward c.Deposit(reward)
fmt.Fprintf(c, "mined: %d space duckets. total: %d\n", reward, c.money) fmt.Fprintf(c, "mined: %d space duckets. total: %d\n", reward, c.money)
} }
func (c *Connection) Withdraw(n int64) {
c.money -= n
}
func (c *Connection) Deposit(n int64) {
c.money += n
if c.money >= 25000 {
c.Win()
}
}
func (c *Connection) Win() { func (c *Connection) Win() {
for conn, _ := range connected { for conn, _ := range connected {
fmt.Fprintf(conn, "player %s has won.\n", c.PlayerName()) fmt.Fprintf(conn, "player %s has won.\n", c.PlayerName())

Loading…
Cancel
Save