diff --git a/game.go b/game.go index a8dc2ee..1ebee93 100644 --- a/game.go +++ b/game.go @@ -261,7 +261,12 @@ func (g *Game) TogglePause(ctx ui.Context) { } } -func (g *Game) Tool() Tool { return g.tool } +func (g *Game) Tool() Tool { + if g.tool == nil { + return &NoTool{} + } + return g.tool +} func (g *Game) ToolChanged() ui.EventHandler { return &g.toolChanged } diff --git a/gamecontrols.go b/gamecontrols.go index 5295dfb..b06d711 100644 --- a/gamecontrols.go +++ b/gamecontrols.go @@ -195,7 +195,7 @@ func (c *GameControls) Handle(ctx ui.Context, event ui.Event) bool { case ui.KeyR: c.dialogs.ShowResearch(ctx) case ui.KeyEscape: - if c.game.Tool() == nil { + if c.game.Tool().Type() == "none" { c.dialogs.ShowIntro(ctx) } else { c.game.CancelTool(ctx) diff --git a/herbarium.go b/herbarium.go index 59f8465..cb713d1 100644 --- a/herbarium.go +++ b/herbarium.go @@ -31,7 +31,7 @@ func (h *Herbarium) Reset() { }) h.Add("loosestrife", FlowerDescriptor{ Name: "Loosestrife", - Description: "A simple flower that will spread in temperate and wet climates.", + Description: "A simple flower that will spread in temperate and damp climates.", IconTemplate: "flower-loosestrife-%s", BuyPrice: 100, SellPrice: 20, diff --git a/terrainrenderer.go b/terrainrenderer.go index af30997..510cfdd 100644 --- a/terrainrenderer.go +++ b/terrainrenderer.go @@ -106,6 +106,41 @@ func (r *terrainRenderer) Handle(ctx ui.Context, event ui.Event) bool { r.isometric.PanTile(geom.PtF32(1, -1)) } } + + if r.hover != nil && r.game.Tool().Type() == "plant-flower" { + terrain := r.game.Terrain + temp := func() string { + temp := terrain.Temp.Value(r.hover.X, r.hover.Y) + switch { + case temp < .3: + return "very cold" + case temp < .4: + return "cold" + case temp > .7: + return "very hot" + case temp > .6: + return "hot" + default: + return "moderate" + } + }() + humid := func() string { + humid := terrain.Humid.Value(r.hover.X, r.hover.Y) + switch { + case humid < .3: + return " and very arid" + case humid < .4: + return " and arid" + case humid > .7: + return " and very damp" + case humid > .6: + return " and damp" + default: + return "" + } + }() + ctx.ShowTooltip(fmt.Sprintf("It is %s%s over here", temp, humid)) + } return false } diff --git a/tools.go b/tools.go index d8b8f5a..8393b4d 100644 --- a/tools.go +++ b/tools.go @@ -17,6 +17,12 @@ func (t *PlantFlowerTool) ClickedTile(game *Game, tile geom.Point) { game.PlantFlower(t.FlowerID, tile) } +type NoTool struct{} + +func (t *NoTool) Type() string { return "none" } + +func (t *NoTool) ClickedTile(*Game, geom.Point) {} + type ShovelTool struct{} func (t *ShovelTool) Type() string { return "shovel" }