diff --git a/game.go b/game.go index ada276e..12149d9 100644 --- a/game.go +++ b/game.go @@ -114,7 +114,15 @@ func (g *Game) Dig(tile Point) { if !ok { return } - g.Balance += desc.SellPrice + adjacent := g.Terrain.FlowersOnAdjacentTiles(tile) + switch adjacent { + case 3: + g.Balance += (desc.SellPrice * 3 / 2) // 50% bonus + case 4: + g.Balance += (desc.SellPrice * 2) // 100% bonus + default: + g.Balance += desc.SellPrice + } } func (g *Game) New() { diff --git a/map.go b/map.go index 3d9dcd5..d585564 100644 --- a/map.go +++ b/map.go @@ -15,6 +15,23 @@ func (m *Map) AddFlower(pos Point, id string, traits FlowerTraits) { m.Flowers[pos] = m.NewFlower(pos, id, traits) } +func (m *Map) FlowersOnAdjacentTiles(pos Point) int { + var count int + if _, ok := m.Flowers[Pt(pos.X+1, pos.Y)]; ok { + count++ + } + if _, ok := m.Flowers[Pt(pos.X-1, pos.Y)]; ok { + count++ + } + if _, ok := m.Flowers[Pt(pos.X, pos.Y+1)]; ok { + count++ + } + if _, ok := m.Flowers[Pt(pos.X, pos.Y-1)]; ok { + count++ + } + return count +} + func (m *Map) DigFlower(pos Point) string { flower, ok := m.Flowers[pos] if !ok {