a geicko-2 based round robin ranking system designed to test c++ battleship submissions battleship.dunkirk.sh

fix: use BATTLESHIP_EXTERNAL_URL for SSH upload instructions

dunkirk.sh 35860410 9964c20e

verified
+23 -6
+23 -6
internal/tui/model.go
··· 2 2 3 3 import ( 4 4 "fmt" 5 + "os" 5 6 "strings" 6 7 "time" 7 8 ··· 9 10 "github.com/charmbracelet/lipgloss" 10 11 11 12 "battleship-arena/internal/storage" 12 - ) 13 - 14 - const ( 15 - sshPort = "2222" 16 - host = "0.0.0.0" 17 13 ) 18 14 19 15 var titleStyle = lipgloss.NewStyle(). ··· 29 25 submissions []storage.Submission 30 26 leaderboard []storage.LeaderboardEntry 31 27 matches []storage.MatchResult 28 + externalURL string 29 + sshPort string 32 30 } 33 31 34 32 func InitialModel(username string, width, height int) model { 33 + externalURL := os.Getenv("BATTLESHIP_EXTERNAL_URL") 34 + if externalURL == "" { 35 + externalURL = "localhost" 36 + } 37 + // Strip http:// or https:// prefix to get just the hostname 38 + externalURL = strings.TrimPrefix(externalURL, "http://") 39 + externalURL = strings.TrimPrefix(externalURL, "https://") 40 + // Strip port if present 41 + if idx := strings.Index(externalURL, ":"); idx != -1 { 42 + externalURL = externalURL[:idx] 43 + } 44 + 45 + sshPort := os.Getenv("BATTLESHIP_SSH_PORT") 46 + if sshPort == "" { 47 + sshPort = "2222" 48 + } 49 + 35 50 return model{ 36 51 username: username, 37 52 width: width, 38 53 height: height, 39 54 submissions: []storage.Submission{}, 40 55 leaderboard: []storage.LeaderboardEntry{}, 56 + externalURL: externalURL, 57 + sshPort: sshPort, 41 58 } 42 59 } 43 60 ··· 77 94 78 95 // Upload instructions 79 96 infoStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("86")) 80 - b.WriteString(infoStyle.Render(fmt.Sprintf("Upload via: scp -P %s memory_functions_yourname.cpp %s@%s:~/", sshPort, m.username, host))) 97 + b.WriteString(infoStyle.Render(fmt.Sprintf("Upload via: scp -P %s memory_functions_yourname.cpp %s@%s:~/", m.sshPort, m.username, m.externalURL))) 81 98 b.WriteString("\n\n") 82 99 83 100 // Show submissions