Add PlayerCode for enhanced score tracking and host validation logic in cooperative mode. Optimize UI for mobile devices with new responsive styles.
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 2m27s
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 2m27s
This commit is contained in:
@@ -161,27 +161,30 @@ func (g *Game) sendJoinRequest() {
|
||||
msg := WebSocketMessage{
|
||||
Type: "join",
|
||||
Payload: game.JoinRequest{
|
||||
Name: g.playerName,
|
||||
RoomID: g.roomID,
|
||||
GameMode: g.gameMode,
|
||||
IsHost: g.isHost,
|
||||
TeamName: g.teamName,
|
||||
Name: g.playerName,
|
||||
RoomID: g.roomID,
|
||||
GameMode: g.gameMode,
|
||||
IsHost: g.isHost,
|
||||
TeamName: g.teamName,
|
||||
PlayerCode: g.playerCode,
|
||||
},
|
||||
}
|
||||
g.sendWebSocketMessage(msg)
|
||||
log.Printf("➡️ JOIN gesendet über WebSocket: Name=%s, RoomID=%s", g.playerName, g.roomID)
|
||||
log.Printf("➡️ JOIN gesendet über WebSocket: Name=%s, RoomID=%s, PlayerCode=%s", g.playerName, g.roomID, g.playerCode)
|
||||
}
|
||||
|
||||
// sendStartRequest sendet Start-Request über WebSocket
|
||||
func (g *Game) sendStartRequest() {
|
||||
myID := g.getMyPlayerID()
|
||||
msg := WebSocketMessage{
|
||||
Type: "start",
|
||||
Payload: game.StartRequest{
|
||||
RoomID: g.roomID,
|
||||
RoomID: g.roomID,
|
||||
PlayerID: myID,
|
||||
},
|
||||
}
|
||||
g.sendWebSocketMessage(msg)
|
||||
log.Printf("▶️ START gesendet über WebSocket: RoomID=%s", g.roomID)
|
||||
log.Printf("▶️ START gesendet über WebSocket: RoomID=%s, PlayerID=%s", g.roomID, myID)
|
||||
}
|
||||
|
||||
// publishInput sendet Input über WebSocket
|
||||
@@ -255,21 +258,30 @@ func (g *Game) submitScore() {
|
||||
// Verwende Team-Name für Coop-Mode, sonst Player-Name
|
||||
displayName := name
|
||||
teamName := ""
|
||||
playerCodeToUse := g.playerCode
|
||||
|
||||
if g.gameMode == "coop" {
|
||||
g.stateMutex.Lock()
|
||||
teamName = g.gameState.TeamName
|
||||
hostPlayerCode := g.gameState.HostPlayerCode
|
||||
g.stateMutex.Unlock()
|
||||
|
||||
if teamName != "" {
|
||||
displayName = teamName
|
||||
}
|
||||
|
||||
// In Coop: Verwende Host's PlayerCode für Score
|
||||
if hostPlayerCode != "" {
|
||||
playerCodeToUse = hostPlayerCode
|
||||
log.Printf("🔑 Coop-Mode: Verwende Host PlayerCode für Score-Submission")
|
||||
}
|
||||
}
|
||||
|
||||
msg := WebSocketMessage{
|
||||
Type: "score_submit",
|
||||
Payload: game.ScoreSubmission{
|
||||
PlayerName: displayName,
|
||||
PlayerCode: g.playerCode,
|
||||
PlayerCode: playerCodeToUse,
|
||||
Name: displayName, // Für Kompatibilität
|
||||
Score: score,
|
||||
Mode: g.gameMode,
|
||||
@@ -279,5 +291,5 @@ func (g *Game) submitScore() {
|
||||
g.sendWebSocketMessage(msg)
|
||||
|
||||
g.scoreSubmitted = true
|
||||
log.Printf("📊 Score submitted: %s = %d (TeamName: %s)", displayName, score, teamName)
|
||||
log.Printf("📊 Score submitted: %s = %d (PlayerCode: %s, TeamName: %s)", displayName, score, playerCodeToUse, teamName)
|
||||
}
|
||||
|
||||
@@ -152,16 +152,17 @@ func (g *Game) connectToServer() {
|
||||
joinMsg := WebSocketMessage{
|
||||
Type: "join",
|
||||
Payload: game.JoinRequest{
|
||||
Name: g.playerName,
|
||||
RoomID: g.roomID,
|
||||
GameMode: g.gameMode,
|
||||
IsHost: g.isHost,
|
||||
TeamName: g.teamName,
|
||||
Name: g.playerName,
|
||||
RoomID: g.roomID,
|
||||
GameMode: g.gameMode,
|
||||
IsHost: g.isHost,
|
||||
TeamName: g.teamName,
|
||||
PlayerCode: g.playerCode,
|
||||
},
|
||||
}
|
||||
g.sendWebSocketMessage(joinMsg)
|
||||
|
||||
log.Printf("➡️ JOIN gesendet über WebSocket: Name=%s, RoomID=%s", g.playerName, g.roomID)
|
||||
log.Printf("➡️ JOIN gesendet über WebSocket: Name=%s, RoomID=%s, PlayerCode=%s", g.playerName, g.roomID, g.playerCode)
|
||||
}
|
||||
|
||||
// sendWebSocketMessage sendet eine Nachricht über WebSocket
|
||||
@@ -191,14 +192,16 @@ func (g *Game) sendInput(input game.ClientInput) {
|
||||
|
||||
// startGame sendet den Start-Befehl über WebSocket
|
||||
func (g *Game) startGame() {
|
||||
myID := g.getMyPlayerID()
|
||||
msg := WebSocketMessage{
|
||||
Type: "start",
|
||||
Payload: game.StartRequest{
|
||||
RoomID: g.roomID,
|
||||
RoomID: g.roomID,
|
||||
PlayerID: myID,
|
||||
},
|
||||
}
|
||||
g.sendWebSocketMessage(msg)
|
||||
log.Printf("▶️ START gesendet über WebSocket: RoomID=%s", g.roomID)
|
||||
log.Printf("▶️ START gesendet über WebSocket: RoomID=%s, PlayerID=%s", g.roomID, myID)
|
||||
}
|
||||
|
||||
// connectForLeaderboard verbindet für Leaderboard-Abfrage
|
||||
@@ -281,21 +284,30 @@ func (g *Game) submitScore() {
|
||||
// Verwende Team-Name für Coop-Mode, sonst Player-Name
|
||||
displayName := name
|
||||
teamName := ""
|
||||
playerCodeToUse := g.playerCode
|
||||
|
||||
if g.gameMode == "coop" {
|
||||
g.stateMutex.Lock()
|
||||
teamName = g.gameState.TeamName
|
||||
hostPlayerCode := g.gameState.HostPlayerCode
|
||||
g.stateMutex.Unlock()
|
||||
|
||||
if teamName != "" {
|
||||
displayName = teamName
|
||||
}
|
||||
|
||||
// In Coop: Verwende Host's PlayerCode für Score
|
||||
if hostPlayerCode != "" {
|
||||
playerCodeToUse = hostPlayerCode
|
||||
log.Printf("🔑 Coop-Mode: Verwende Host PlayerCode für Score-Submission")
|
||||
}
|
||||
}
|
||||
|
||||
msg := WebSocketMessage{
|
||||
Type: "score_submit",
|
||||
Payload: game.ScoreSubmission{
|
||||
PlayerName: displayName,
|
||||
PlayerCode: g.playerCode,
|
||||
PlayerCode: playerCodeToUse,
|
||||
Name: displayName, // Für Kompatibilität
|
||||
Score: score,
|
||||
Mode: g.gameMode,
|
||||
@@ -305,7 +317,7 @@ func (g *Game) submitScore() {
|
||||
g.sendWebSocketMessage(msg)
|
||||
|
||||
g.scoreSubmitted = true
|
||||
log.Printf("📊 Score submitted: %s = %d (TeamName: %s)", displayName, score, teamName)
|
||||
log.Printf("📊 Score submitted: %s = %d (PlayerCode: %s, TeamName: %s)", displayName, score, playerCodeToUse, teamName)
|
||||
}
|
||||
|
||||
// Dummy-Funktionen für Kompatibilität mit anderen Teilen des Codes
|
||||
|
||||
@@ -44,5 +44,33 @@ input[type=range]{width:100%;max-width:300px}
|
||||
#mute-btn:hover{background:rgba(255,255,255,.2);border-color:#fff}
|
||||
#rotate-overlay{display:none;position:fixed;top:0;left:0;width:100%;height:100%;background:#222;z-index:99999;color:#fff;flex-direction:column;align-items:center;justify-content:center;text-align:center}
|
||||
.icon{font-size:60px;margin-bottom:20px}
|
||||
/* Mobile First - Base Styles bereits für Mobile optimiert */
|
||||
@media screen and (max-width: 768px) {
|
||||
h1 { font-size: 20px; margin: 5px 0 15px; }
|
||||
button { font-size: 12px; padding: 12px 20px; margin: 8px; }
|
||||
.big-btn { font-size: 14px; padding: 14px 25px; }
|
||||
input[type=text] { font-size: 12px; padding: 10px; max-width: 280px; }
|
||||
.info-box { max-width: 280px; padding: 10px; font-size: 10px; }
|
||||
.info-box p { font-size: 11px; }
|
||||
.overlay-screen { padding: 10px; }
|
||||
#startScreen { flex-direction: column; gap: 20px; }
|
||||
.start-left, .start-right { max-width: 90%; flex: 1; }
|
||||
.center-box { max-width: 90%; }
|
||||
.leaderboard-box { max-width: 90%; padding: 10px; }
|
||||
.hall-of-fame-box { max-height: 200px; max-width: 90%; }
|
||||
.legal-bar { gap: 8px; }
|
||||
.legal-btn { font-size: 8px; padding: 6px 10px; }
|
||||
.back-btn { font-size: 10px; padding: 8px 16px; }
|
||||
}
|
||||
|
||||
@media screen and (max-width: 480px) {
|
||||
h1 { font-size: 16px; line-height: 1.2; }
|
||||
button { font-size: 10px; padding: 10px 16px; margin: 6px; }
|
||||
.big-btn { font-size: 12px; padding: 12px 20px; }
|
||||
input[type=text] { font-size: 11px; padding: 8px; max-width: 240px; }
|
||||
.overlay-screen { padding: 8px; }
|
||||
body, html { font-size: 11px; }
|
||||
}
|
||||
|
||||
@media screen and (orientation:portrait){#rotate-overlay{display:flex}#game-container{display:none!important}}
|
||||
@media (min-width:1024px){h1{font-size:48px}button{font-size:22px;padding:20px 40px}input[type=text]{max-width:450px;font-size:20px;padding:15px}.info-box{max-width:500px}.hall-of-fame-box{max-height:400px}}
|
||||
|
||||
Reference in New Issue
Block a user