Skip to content

Commit

Permalink
feat: Add a winner screen when the game finishes
Browse files Browse the repository at this point in the history
Add a fancy ASCII art to be displayed along with the final results when
the game finishes.

Closes #5
  • Loading branch information
milonoir committed Oct 20, 2023
1 parent a13b86d commit 624e8a4
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 2 deletions.
19 changes: 17 additions & 2 deletions internal/client/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const (
titlePageName = "titlePage"
lobbyPageName = "lobbyPage"
gamePageName = "gamePage"
winPageName = "winPage"
errorPageName = "errorPage"
)

Expand Down Expand Up @@ -184,11 +185,25 @@ func (a *Application) initUI() {
a.srvStatus = ui.NewServerStatus()
gamePage.AddItem(a.srvStatus.GetTextView(), 4, 1, 1, 2, 1, 1, false)

//-------------------------------------------------- Win page
winPage := tview.NewGrid().
SetColumns(38, 0).
SetRows(0, 0)

// Congrats panel.
congrats := ui.NewCongratsPanel()
winPage.AddItem(congrats.GetTextView(), 0, 1, 1, 1, 1, 1, false)

// Business Club man logo.
logo := ui.NewLogoPanel()
winPage.AddItem(logo.GetTextView(), 0, 0, 2, 1, 1, 1, false)

// Setup pages and set pages as root.
a.pages.
AddPage(titlePageName, titlePage, true, true).
AddPage(titlePageName, titlePage, true, false).
AddPage(lobbyPageName, lobbyPage, true, false).
AddPage(gamePageName, gamePage, true, false)
AddPage(gamePageName, gamePage, true, false).
AddPage(winPageName, winPage, true, true)

a.app.SetRoot(a.pages, true)
}
Expand Down
40 changes: 40 additions & 0 deletions internal/client/ui/bc_man.ascii
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.:.:
.^.^7P~
..^!~G#.
^7?PBP
~PBPJ.
.~! JP7 ^:
7YPGG?:G7:JBBY!?~.
JGGGGJ5J~!YBGGG5GBG^
.GGGGG?57 7BGYJPGGGJY^
~5GGGG7Y: 757YGGGGGG!~:
JPGGGGGG~JGPGGGGGGBBBJ^
:J5GYGGPGYGGGGGGBBBG5~^??
~GGP5GJJGGGGGGGGY7: ^!7.
JGGGGGJPGGGPY7:. ..!?J7.
.GGGGGGGGGGGGJ~^::!GGY77.
!#BBBBBBBBBBBB5?PPBGB?.
JJBBBBBBBBBBP5GYJBBBB:
^Y7GGBBBBGGBBBBBBY7YPB^
~: ^^^Y#?JBBBBGGBBBBBBBGJ~:
G?:BBBBB5GBGY?5B55BBBBGBBG
.B7^BBBBBBBBPJ~J7.GBBBB5GBP
:#~~BBBBBBBBGGPP !#BB#Y5#?
^#^!#BBBBBBG7JGP :#BB#5J#!
^#^?#BBBB#GJ5Y?! .B#BBG!#^
~#:J#######BPJ~: .YP#B#!B:
~#:5##########B#: .PY#B#75.
^.~777?!Y######5 5?###?7
.B#B####^ JP###Y.
Y#JP###5 5####G
:##YYP55:P#####.
G&&B5.:P#&####~.
~&&&&!.#&&&&&&7!
Y&&#P#&&&&&&&!5
.P#BP&&&&&&#&&JB
~PY!J?~.?&5G&&##.
5Y^JP&&&:
:BB5Y#G7.
B@#B&5
G&&PPG
..:.
34 changes: 34 additions & 0 deletions internal/client/ui/congrats_panel.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package ui

import (
_ "embed"

"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)

//go:embed congratulations.ascii
var congratsArt string

type CongratsPanel struct {
tv *tview.TextView
}

func NewCongratsPanel() *CongratsPanel {
p := &CongratsPanel{
tv: tview.NewTextView(),
}

p.tv.
SetTextAlign(tview.AlignCenter).
SetTextColor(tcell.ColorGreen).
SetText(congratsArt)
p.tv.
SetBorderPadding(1, 0, 0, 0)

return p
}

func (p *CongratsPanel) GetTextView() *tview.TextView {
return p.tv
}
12 changes: 12 additions & 0 deletions internal/client/ui/congratulations.ascii
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.d8888b. 888 888 888 d8b 888
d88P Y88b 888 888 888 Y8P 888
888 888 888 888 888 888
888 .d88b. 88888b. .d88b. 888d888 8888b. 888888 888 888 888 8888b. 888888 888 .d88b. 88888b. .d8888b 888
888 d88""88b 888 "88b d88P"88b 888P" "88b 888 888 888 888 "88b 888 888 d88""88b 888 "88b 88K 888
888 888 888 888 888 888 888 888 888 .d888888 888 888 888 888 .d888888 888 888 888 888 888 888 "Y8888b. Y8P
Y88b d88P Y88..88P 888 888 Y88b 888 888 888 888 Y88b. Y88b 888 888 888 888 Y88b. 888 Y88..88P 888 888 X88 "
"Y8888P" "Y88P" 888 888 "Y88888 888 "Y888888 "Y888 "Y88888 888 "Y888888 "Y888 888 "Y88P" 888 888 88888P' 888
888
Y8b d88P
"Y88P"

34 changes: 34 additions & 0 deletions internal/client/ui/logo_panel.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package ui

import (
_ "embed"

"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)

//go:embed bc_man.ascii
var logoArt string

type LogoPanel struct {
tv *tview.TextView
}

func NewLogoPanel() *LogoPanel {
p := &LogoPanel{
tv: tview.NewTextView(),
}

p.tv.
SetTextAlign(tview.AlignCenter).
SetTextColor(tcell.ColorGrey).
SetText(logoArt)
p.tv.
SetBorderPadding(1, 0, 0, 0)

return p
}

func (p *LogoPanel) GetTextView() *tview.TextView {
return p.tv
}

0 comments on commit 624e8a4

Please sign in to comment.