From 905aad2afac1e12e42a9b7b955bdf5c892838694 Mon Sep 17 00:00:00 2001 From: Sander Schobers Date: Mon, 11 May 2020 15:27:22 +0200 Subject: [PATCH] Can't plant flower over existing flower. --- game.go | 5 +++++ map.go | 5 +++++ 2 files changed, 10 insertions(+) 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,