You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
434 B
Go

package sim
import (
"time"
)
type stageOfGrowth int
const (
unborn stageOfGrowth = iota
planted
sapling
unripe
ripe
overripe
rotting
dead
)
type potato struct {
planted time.Duration
stage stageOfGrowth
}
func (p *potato) update(e *entity, dt time.Duration) {
if p.stage > unborn {
p.planted += dt
}
}
type percent int
func (p *potato) progress() percent {
if p.stage <= unborn {
return 0
}
return 100
}