tImprove flag submission popup text - scoreboard - Interactive scoreboard for CTF-like games
 (HTM) git clone git://git.z3bra.org/scoreboard.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
 (DIR) commit 352b4c819d43e2300a993307af95ca065138c504
 (DIR) parent 0583b478d7eb27b51500a835a73d7a1e56ea8415
 (HTM) Author: Willy Goiffon <contact@z3bra.org>
       Date:   Thu,  3 Oct 2024 14:01:45 +0200
       
       Improve flag submission popup text
       
       Diffstat:
         M main.go                             |      14 +++++++++++++-
         M player.go                           |       6 ++++--
       
       2 files changed, 17 insertions(+), 3 deletions(-)
       ---
 (DIR) diff --git a/main.go b/main.go
       t@@ -39,6 +39,13 @@ Save it carefully, do not share it.
        
          🔑%s
        `
       +        FLAG_SUBMITTED string = `[::-]
       +You found a flag
       +worth [::b]%d[::-] points!
       +
       +
       +%s
       +`
        )
        
        type Flag struct {
       t@@ -180,7 +187,12 @@ func main() {
                                        scoreboard.HighlightBoard(scoreboard.player.Rank() + 1)
                                        scoreboard.pages.RemovePage("token")
                                        scoreboard.GenerateHTML()
       -                                scoreboard.Popup("CONGRATULATIONS", fmt.Sprintf("[::-]Badge: [::b]%s[::-]\nScore: [::b]%d[::-]\n", scoreboard.flag.badge, scoreboard.flag.score))
       +                                collection := strings.Replace(scoreboard.player.BadgeStr(),
       +                                        scoreboard.flag.badge,
       +                                        fmt.Sprintf("[::l]%s[::-]", scoreboard.flag.badge), -1)
       +                                scoreboard.Popup("CONGRATULATIONS",
       +                                        fmt.Sprintf(FLAG_SUBMITTED,
       +                                        scoreboard.flag.score, collection))
                                })
        
                                scoreboard.pages.AddAndSwitchToPage("token", page, true)
 (DIR) diff --git a/player.go b/player.go
       t@@ -175,12 +175,12 @@ func (p *Player) FlagsStr() string {
        func (p *Player) BadgeStr() string {
                var badges strings.Builder
        
       -        badges.WriteString("[-::-]\n")
       +        badges.WriteString("[-::-]")
                for n, f := range p.flags {
                        if n > 0 && n % 8 == 0 {
                                badges.WriteString("\n")
                        }
       -                badges.WriteString(fmt.Sprintf("%s", f.badge))
       +                badges.WriteString(fmt.Sprintf(`%s`, f.badge))
                }
        
                return badges.String();
       t@@ -236,6 +236,8 @@ func (p *Player) Submit(flag Flag) error {
                        }
                }
        
       +        p.flags = append(p.flags, flag)
       +
                return nil
        }