Added bonusses when flower is adjacent to more flowers
This commit is contained in:
parent
013fe4bdb6
commit
c926ae2ef9
10
game.go
10
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() {
|
||||
|
17
map.go
17
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user