diff --git a/game.go b/game.go index ccff2ea..ada276e 100644 --- a/game.go +++ b/game.go @@ -163,6 +163,11 @@ func (g *Game) Load() { func (g *Game) Pause() { g.setSpeed(GameSpeedPaused) } func (g *Game) PlantFlower(id string, tile Point) { + if g.Terrain.HasFlower(tile) { + // TODO: notify user it tried to plant on tile with flower? + return + } + flower, ok := g.Herbarium.Find(id) if !ok { log.Println("user was able to plant a flower that doesn't exist") diff --git a/map.go b/map.go index cb63b79..3d9dcd5 100644 --- a/map.go +++ b/map.go @@ -24,6 +24,11 @@ func (m *Map) DigFlower(pos Point) string { return flower.ID } +func (m *Map) HasFlower(pos Point) bool { + _, ok := m.Flowers[pos] + return ok +} + func (m *Map) NewFlower(pos Point, id string, traits FlowerTraits) Flower { flower := Flower{ ID: id,