From 7cb92907980d510ab88f605526a2e9671b175c7e Mon Sep 17 00:00:00 2001 From: tolelom <98kimsungmin@naver.com> Date: Wed, 25 Mar 2026 13:21:04 +0900 Subject: [PATCH] feat: add Screen interface and Context for UI architecture Co-Authored-By: Claude Opus 4.6 (1M context) --- ui/context.go | 19 +++++++++++++++++++ ui/screen.go | 11 +++++++++++ 2 files changed, 30 insertions(+) create mode 100644 ui/context.go create mode 100644 ui/screen.go diff --git a/ui/context.go b/ui/context.go new file mode 100644 index 0000000..b6d3089 --- /dev/null +++ b/ui/context.go @@ -0,0 +1,19 @@ +package ui + +import ( + "github.com/tolelom/catacombs/game" + "github.com/tolelom/catacombs/store" +) + +// Context holds shared state accessible to all screens. +type Context struct { + Width int + Height int + Fingerprint string + PlayerName string + + Lobby *game.Lobby + Store *store.DB + Session *game.GameSession + RoomCode string +} diff --git a/ui/screen.go b/ui/screen.go new file mode 100644 index 0000000..a8ef666 --- /dev/null +++ b/ui/screen.go @@ -0,0 +1,11 @@ +package ui + +import tea "github.com/charmbracelet/bubbletea" + +// Screen represents an independent screen with its own Update and View logic. +// Update returns the next Screen (can return itself or a different screen for transitions) +// plus a tea.Cmd for async operations. +type Screen interface { + Update(msg tea.Msg, ctx *Context) (Screen, tea.Cmd) + View(ctx *Context) string +}