tPolish token display - scoreboard - Interactive scoreboard for CTF-like games
 (HTM) git clone git://git.z3bra.org/scoreboard.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
 (DIR) commit f54a4941d53b87921903199974c2b046d3757dfd
 (DIR) parent 3f2e8d5a04c80bf53ecdfc6c4d855e2816be1624
 (HTM) Author: Willy Goiffon <contact@z3bra.org>
       Date:   Tue, 22 Aug 2023 17:57:19 +0200
       
       Polish token display
       
       Diffstat:
         M main.go                             |      13 ++++++++-----
         M playerbox.go                        |      19 +++++++++----------
         M ui.go                               |       9 +++++++++
       
       3 files changed, 26 insertions(+), 15 deletions(-)
       ---
 (DIR) diff --git a/main.go b/main.go
       t@@ -33,10 +33,12 @@ const (
                BOARD_HEIGHT int = 15
                HTML string = "score.html"
                DB string = "score.db"
       -        TOKEN_REMINDER string = `TOKEN FOR %s: %s
       -This token will be requested when you submit flag #%d.
       -Save it carefully, and do not share it with anyone.
       -Good bye hunter. Good luck.
       +        TOKEN_REMINDER string = `
       +%s's token for flag #%d:
       +
       +🔑 %s
       +
       +Save it carefully, do not share it.
        `
        )
        
       t@@ -159,6 +161,7 @@ func main() {
                cyboard.html = *html
                cyboard.app = tview.NewApplication()
                cyboard.pages = tview.NewPages()
       +        //cyboard.frame = tview.NewFrame(tview.NewGrid())
                cyboard.board = tview.NewFlex()
                cyboard.player = &Player{ db: cyboard.db }
        
       t@@ -211,6 +214,6 @@ func main() {
                }
        
                if cyboard.player.token != "" && cyboard.flag < (len(cyboard.flag_ref)) {
       -                fmt.Printf(TOKEN_REMINDER, cyboard.player.name, cyboard.player.token, cyboard.flag + 1)
       +                fmt.Printf(TOKEN_REMINDER, cyboard.player.name, cyboard.flag + 1, cyboard.player.token)
                }
        }
 (DIR) diff --git a/playerbox.go b/playerbox.go
       t@@ -17,20 +17,19 @@ type PlayerBox struct {
        }
        
        const (
       -        SAVE_TOKEN string = `Token for flag #%d:
       +        TOKEN_WELCOME string = `%s, your progression has
       +been saved. To update it,
       +you will need this token:
        
       -%s
       +🔑%s
        
        Save it.
       -Do not share.
       -
       -
       -~~~
       +Do not share it.
        
        Tokens are single-use.
       -
       -A new one will be provided
       -when submitting next flag.
       +A new token is generated
       +and displayed each time
       +you submit a flag.
        `
        )
        
       t@@ -95,7 +94,7 @@ func PlayerBoxName(p *Player) *tview.TextView {
                                                }
                                                cyboard.HighlightBoard(p.ScoreRank())
                                                cyboard.GenerateHTML()
       -                                        cyboard.Popup("CONGRATULATIONS", fmt.Sprintf(SAVE_TOKEN, p.flag+1, p.token));
       +                                        cyboard.Popup("CONGRATULATIONS", fmt.Sprintf(TOKEN_WELCOME, p.name, p.token));
                                        } else {
                                                cyboard.Popup("NOPE", "Player name unavailable\nPlease pick another one")
                                        }
 (DIR) diff --git a/ui.go b/ui.go
       t@@ -89,6 +89,15 @@ func (a *Application) DrawBoard() {
                a.board.Clear().
                        SetDirection(tview.FlexRow).
                        AddItem(RankTable(0, -1, 0, true), BOARD_HEIGHT, 1, true)
       +
       +        // handle additional keys to terminate application
       +        a.board.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
       +                if event.Key() == tcell.KeyEscape || event.Rune() == 'q' {
       +                        a.app.Stop()
       +                        return nil
       +                }
       +                return event
       +        })
        }
        
        func (a *Application) HighlightBoard(line int) {