summaryrefslogtreecommitdiff
path: root/pkg/ui/views/play_util.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/ui/views/play_util.go')
-rw-r--r--pkg/ui/views/play_util.go31
1 files changed, 30 insertions, 1 deletions
diff --git a/pkg/ui/views/play_util.go b/pkg/ui/views/play_util.go
index c57f331..b2f70b5 100644
--- a/pkg/ui/views/play_util.go
+++ b/pkg/ui/views/play_util.go
@@ -21,7 +21,13 @@ func (m *PlayModel) handleError(msg error) (tea.Model, tea.Cmd) {
return m, nil
}
-func formatGamesForPage(games []database.Game, altCodeStyle lipgloss.Style) []string {
+var (
+ winIcon = lipgloss.NewStyle().Foreground(lipgloss.Color("#f1c40f")).Render("🏆")
+ loseIcon = lipgloss.NewStyle().Foreground(lipgloss.Color("#895129")).Render("💩")
+ drawIcon = lipgloss.NewStyle().Foreground(lipgloss.Color("#bdc3c7")).Render("🤝")
+)
+
+func formatGamesForPage(userID int, games []database.Game, altCodeStyle lipgloss.Style) []string {
var gamesStrings []string
gamesStrings = append(gamesStrings, "Games list")
@@ -34,6 +40,28 @@ func formatGamesForPage(games []database.Game, altCodeStyle lipgloss.Style) []st
for i, game := range games {
indexStr := altCodeStyle.Render(fmt.Sprintf("[%d] ", i))
+ icon := " "
+
+ if game.Outcome != "*" {
+ if len(game.Outcome) >= 2 {
+ if game.Outcome[0:2] == "1-" {
+ if game.Player1.ID == userID {
+ icon = winIcon
+ } else {
+ icon = loseIcon
+ }
+ } else if game.Outcome[0:2] == "0-" {
+ if game.Player2 != nil && game.Player2.ID == userID {
+ icon = winIcon
+ } else {
+ icon = loseIcon
+ }
+ } else {
+ icon = drawIcon
+ }
+ }
+ }
+
nameStr := game.Name
dateStr := game.UpdatedAt.Format("2006-01-02 15:04")
@@ -44,6 +72,7 @@ func formatGamesForPage(games []database.Game, altCodeStyle lipgloss.Style) []st
indexStr,
nameStr,
paddingStr,
+ icon,
lipgloss.NewStyle().Foreground(lipgloss.Color("#d35400")).Render(dateStr),
)
gamesStrings = append(gamesStrings, line)