Can't plant flower over existing flower.

This commit is contained in:
Sander Schobers 2020-05-11 15:27:22 +02:00
parent 9f19e4bd92
commit 905aad2afa
2 changed files with 10 additions and 0 deletions

View File

@ -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")

5
map.go
View File

@ -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,