diff --git a/bomb.go b/bomb.go index 91d2a07..068909a 100644 --- a/bomb.go +++ b/bomb.go @@ -53,11 +53,15 @@ type MakeBombState struct { func MakeBomb(s *System) ConnectionState { m := &MakeBombState{System: s} + m.CommandSuite = CommandSet{ + balCommand, + } return m } func (m *MakeBombState) Enter(c *Connection) { c.Printf("Making a bomb...\n") + c.money -= options.bombCost } func (m *MakeBombState) Tick(c *Connection, frame int64) ConnectionState { diff --git a/idle.go b/idle.go index c97abaf..b4e01fb 100644 --- a/idle.go +++ b/idle.go @@ -140,6 +140,10 @@ func (i *IdleState) scan(c *Connection, args ...string) { func (i *IdleState) maek(c *Connection, args ...string) { switch args[0] { case "bomb": + if c.money < options.bombCost { + c.Printf("Not enough money! Bombs costs %v but you only have %v space duckets. Mine more space duckets!\n", options.bombCost, c.money) + return + } c.SetState(MakeBomb(i.System)) default: c.Printf("I don't know how to make a %v.\n", args[0]) diff --git a/main.go b/main.go index 59e10bb..54f4031 100644 --- a/main.go +++ b/main.go @@ -11,18 +11,19 @@ import ( ) var options struct { + bombCost int bombSpeed float64 debug bool economic int - frameRate int frameLength time.Duration + frameRate int lightSpeed float64 makeBombTime time.Duration moneyMean float64 moneySigma float64 playerSpeed float64 - respawnTime time.Duration respawnFrames int64 + respawnTime time.Duration speckPath string } @@ -116,4 +117,5 @@ func init() { flag.StringVar(&options.speckPath, "speck-path", "/projects/exo/expl.speck", "path to exoplanet speck file") flag.DurationVar(&options.respawnTime, "respawn-time", 60*time.Second, "time for player respawn") flag.DurationVar(&options.makeBombTime, "bomb-time", 5*time.Second, "time it takes to make a bomb") + flag.IntVar(&options.bombCost, "bomb-cost", 500, "price of a bomb") }