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 3 import ( 4 "fmt" 5 "strings" 6 "time" 7 ··· 9 "github.com/charmbracelet/lipgloss" 10 11 "battleship-arena/internal/storage" 12 - ) 13 - 14 - const ( 15 - sshPort = "2222" 16 - host = "0.0.0.0" 17 ) 18 19 var titleStyle = lipgloss.NewStyle(). ··· 29 submissions []storage.Submission 30 leaderboard []storage.LeaderboardEntry 31 matches []storage.MatchResult 32 } 33 34 func InitialModel(username string, width, height int) model { 35 return model{ 36 username: username, 37 width: width, 38 height: height, 39 submissions: []storage.Submission{}, 40 leaderboard: []storage.LeaderboardEntry{}, 41 } 42 } 43 ··· 77 78 // Upload instructions 79 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))) 81 b.WriteString("\n\n") 82 83 // Show submissions
··· 2 3 import ( 4 "fmt" 5 + "os" 6 "strings" 7 "time" 8 ··· 10 "github.com/charmbracelet/lipgloss" 11 12 "battleship-arena/internal/storage" 13 ) 14 15 var titleStyle = lipgloss.NewStyle(). ··· 25 submissions []storage.Submission 26 leaderboard []storage.LeaderboardEntry 27 matches []storage.MatchResult 28 + externalURL string 29 + sshPort string 30 } 31 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 + 50 return model{ 51 username: username, 52 width: width, 53 height: height, 54 submissions: []storage.Submission{}, 55 leaderboard: []storage.LeaderboardEntry{}, 56 + externalURL: externalURL, 57 + sshPort: sshPort, 58 } 59 } 60 ··· 94 95 // Upload instructions 96 infoStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("86")) 97 + b.WriteString(infoStyle.Render(fmt.Sprintf("Upload via: scp -P %s memory_functions_yourname.cpp %s@%s:~/", m.sshPort, m.username, m.externalURL))) 98 b.WriteString("\n\n") 99 100 // Show submissions