diff --git a/internal/solitaire/solitaire.go b/internal/solitaire/solitaire.go index 2a5c059..358fe7d 100644 --- a/internal/solitaire/solitaire.go +++ b/internal/solitaire/solitaire.go @@ -2,6 +2,7 @@ package solitaire import ( "github.com/brianstrauch/solitaire-tui/pkg" + tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" ) @@ -36,10 +37,7 @@ var deckTypes = []deckType{ type Solitaire struct { decks []*pkg.Deck selected *index - - mouse tea.MouseMsg - windowHeight int - maxHeight int + mouse tea.MouseMsg } type index struct { @@ -73,7 +71,7 @@ func New() *Solitaire { } func (s *Solitaire) Init() tea.Cmd { - return nil + return tea.ClearScreen } func (s *Solitaire) Update(msg tea.Msg) (tea.Model, tea.Cmd) { @@ -83,8 +81,6 @@ func (s *Solitaire) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case "q", "ctrl+c", "esc": return s, tea.Quit } - case tea.WindowSizeMsg: - s.windowHeight = msg.Height case tea.MouseMsg: switch msg.Type { case tea.MouseLeft: @@ -93,12 +89,7 @@ func (s *Solitaire) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } case tea.MouseRelease: if s.mouse.Type == tea.MouseLeft && msg.X == s.mouse.X && msg.Y == s.mouse.Y { - height := lipgloss.Height(s.View()) - if height > s.maxHeight { - s.maxHeight = height - } - y := msg.Y - (s.windowHeight - s.maxHeight) - s.click(msg.X, y) + s.click(msg.X, msg.Y) } s.mouse = msg } diff --git a/pkg/card.go b/pkg/card.go index d800c82..09b5a66 100644 --- a/pkg/card.go +++ b/pkg/card.go @@ -33,14 +33,14 @@ func NewCard(value, suit int) *Card { func (c *Card) View() string { color := lipgloss.AdaptiveColor{Light: "#000000", Dark: "#FFFFFF"} - if c.IsSelected { - color = lipgloss.AdaptiveColor{Light: "#FFFF00", Dark: "#FFFF00"} - } - if !c.IsVisible { return viewCard("╱", "", color) } + if c.IsSelected { + color = lipgloss.AdaptiveColor{Light: "#FFFF00", Dark: "#00FFFF"} + } + style := lipgloss.NewStyle().Foreground(c.Color()) return viewCard(" ", style.Render(c.String()), color) } @@ -50,10 +50,10 @@ func (c *Card) Flip() { } func (c *Card) Color() lipgloss.AdaptiveColor { - if c.Suit == 1 || c.Suit == 2 { - return lipgloss.AdaptiveColor{Light: "#FF0000", Dark: "#FF0000"} + if c.Suit == 0 || c.Suit == 3 { + return lipgloss.AdaptiveColor{Light: "#000000", Dark: "#FFFFFF"} } else { - return lipgloss.AdaptiveColor{Light: "#000000", Dark: "#888888"} + return lipgloss.AdaptiveColor{Light: "#FF0000", Dark: "#FF0000"} } }