mirror of
https://github.com/maaslalani/gambit.git
synced 2024-11-24 08:22:12 +02:00
feat: styling
This commit is contained in:
parent
5ea9a96daa
commit
c3bd0dca7c
@ -6,6 +6,7 @@ import (
|
|||||||
|
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
tea "github.com/charmbracelet/bubbletea"
|
||||||
"github.com/maaslalani/gambit/game"
|
"github.com/maaslalani/gambit/game"
|
||||||
|
"github.com/maaslalani/gambit/style"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NoteMsg is a message that is sent to the client when a message is added to
|
// NoteMsg is a message that is sent to the client when a message is added to
|
||||||
@ -109,10 +110,19 @@ func (r *SharedGame) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
// View implements bubble tea model.
|
// View implements bubble tea model.
|
||||||
func (r *SharedGame) View() string {
|
func (r *SharedGame) View() string {
|
||||||
s := strings.Builder{}
|
s := strings.Builder{}
|
||||||
s.WriteString(r.game.View())
|
|
||||||
if r.note != "" {
|
turn := "Black's move"
|
||||||
s.WriteString("\n")
|
if *r.whiteToMove {
|
||||||
s.WriteString(r.note)
|
turn = "White's move"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.WriteString(r.game.View())
|
||||||
|
|
||||||
|
s.WriteRune('\n')
|
||||||
|
s.WriteString(fmt.Sprintf(" %s %s", style.Title("Gambit"), turn))
|
||||||
|
s.WriteRune('\n')
|
||||||
|
s.WriteString(style.Faint(fmt.Sprintf(" Room %s as %s playing %s", r.player.room.id, r.player.session.User(), r.player.ptype)))
|
||||||
|
s.WriteRune('\n')
|
||||||
|
|
||||||
return s.String()
|
return s.String()
|
||||||
}
|
}
|
||||||
|
@ -12,3 +12,5 @@ var Cyan = fg("6")
|
|||||||
var Faint = fg("8")
|
var Faint = fg("8")
|
||||||
var Magenta = fg("5")
|
var Magenta = fg("5")
|
||||||
var Red = fg("1")
|
var Red = fg("1")
|
||||||
|
|
||||||
|
var Title = NewStyle().Foreground(Color("5")).Italic(true).Render
|
||||||
|
Loading…
Reference in New Issue
Block a user