diff options
Diffstat (limited to 'go/ui/hoverable.go')
| -rw-r--r-- | go/ui/hoverable.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/go/ui/hoverable.go b/go/ui/hoverable.go index c70340bb..75c04fe8 100644 --- a/go/ui/hoverable.go +++ b/go/ui/hoverable.go @@ -1,6 +1,7 @@ package ui import ( + "golang.org/x/exp/slices" "muhq.space/muhqs-game/go/game" ) @@ -31,7 +32,11 @@ func (h *hoverWidget) showHint(x, y int) { } h.c.AddWidget(hint) + oldReset := h.reset h.reset = func() { + if oldReset != nil { + oldReset() + } h.c.RemoveWidget(hint) } } @@ -97,6 +102,27 @@ func (h *hoverPermInfo) init(mv *MapView, c *Collection) { return nil } + if unit, ok := obj.(*game.Unit); ok { + reachableRange := unit.Attack.MaxRange() + unit.Movement.Range + movable := unit.MoveRangeTiles() + for _, t := range movable { + mv.AddHighlightTile(t, HighlightMovementColor) + } + + // TODO: only show actually reachable tiles + attackable := game.TilesInRange(mv.gameState.Map(), perm, reachableRange) + for _, t := range attackable { + if slices.Contains(movable, t) { + continue + } + mv.AddHighlightTile(t, HighlightAttackColor) + } + + h.reset = func() { + mv.ClearTileHighlights() + } + } + hint := NewPermInfo(x+TILE_WIDTH, y, perm) wx, wy := x, y |
