diff options
author | Santo Cariotti <santo@dcariotti.me> | 2025-04-17 10:52:47 +0200 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2025-04-17 10:52:47 +0200 |
commit | 313c96613153d92e4964bef4d2469b09a9505597 (patch) | |
tree | 0b7e8e58f826a2ef4821145eb27b045cf760849c /pkg/ui/views/game_util.go | |
parent | 39a594829ebddc0bc06b92465241439f81fca205 (diff) |
Split views on subfiles
Diffstat (limited to 'pkg/ui/views/game_util.go')
-rw-r--r-- | pkg/ui/views/game_util.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/pkg/ui/views/game_util.go b/pkg/ui/views/game_util.go new file mode 100644 index 0000000..8e82fcf --- /dev/null +++ b/pkg/ui/views/game_util.go @@ -0,0 +1,28 @@ +package views + +import ( + tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/lipgloss" +) + +func (m GameModel) handleWindowSizeMsg(msg tea.WindowSizeMsg) (GameModel, tea.Cmd) { + m.width = msg.Width + m.height = msg.Height + listWidth := m.width / 4 + m.movesList.SetSize(listWidth, m.height/2) + return m, m.updateMovesListCmd() +} + +func (m GameModel) buildWindowContent(content string, formWidth int) string { + return lipgloss.JoinVertical( + lipgloss.Center, + windowStyle.Width(formWidth).Render(lipgloss.JoinVertical( + lipgloss.Center, + content, + )), + ) +} + +func (m GameModel) isMyTurn() bool { + return m.turn%2 == 0 && m.peer == "peer-2" || m.turn%2 == 1 && m.peer == "peer-1" +} |