fix(android): brancher les classements sur les vrais IDs Play Jeux

La console Play génère les IDs de leaderboard (format CgkI…), contrairement
à l'hypothèse de la spec : l'app demandait des boards questions_N inexistants,
d'où un chargement infini et des scores silencieusement perdus. Remplacer le
mapping par la table des vrais IDs (GameConfig.leaderboardId() devient
nullable, null = pas de board) et logguer les échecs GMS jusqu'ici avalés
par runCatching. Spec corrigée en conséquence (§6, §7).
This commit is contained in:
herel committed 2026-08-31 23:11:22 +02:00
1 parent b7c958cd5b
commit 853541d41b
5 files changed
+60 -14

No files matched your search

@@ -2,6 +2,7 @@ package com.livrets.androidApp
import android.app.Activity
import android.content.Intent
import android.util.Log
import com.google.android.gms.games.PlayGames
import com.livrets.games.GamesServices
import kotlinx.coroutines.Dispatchers
@@ -16,19 +17,20 @@ class PlayGamesServices(
override suspend fun signIn(): Boolean = withContext(Dispatchers.IO) {
runCatching {
PlayGames.getGamesSignInClient(activity).signIn().await().isAuthenticated
}.getOrDefault(false)
}.onFailure { Log.w(TAG, "Échec connexion Play Jeux", it) }.getOrDefault(false)
}
override suspend fun isSignedIn(): Boolean = withContext(Dispatchers.IO) {
runCatching {
PlayGames.getGamesSignInClient(activity).isAuthenticated().await().isAuthenticated
}.getOrDefault(false)
}.onFailure { Log.w(TAG, "Échec vérification connexion Play Jeux", it) }
.getOrDefault(false)
}
override suspend fun playerDisplayName(): String? = withContext(Dispatchers.IO) {
runCatching {
PlayGames.getPlayersClient(activity).currentPlayer.await().displayName
}.getOrNull()
}.onFailure { Log.w(TAG, "Échec récupération du joueur", it) }.getOrNull()
}
override suspend fun submitScore(leaderboardId: String, score: Long): Boolean =
@@ -38,7 +40,8 @@ class PlayGamesServices(
.submitScoreImmediate(leaderboardId, score)
.await()
true
}.getOrDefault(false)
}.onFailure { Log.w(TAG, "Échec envoi du score au board $leaderboardId", it) }
.getOrDefault(false)
}
override suspend fun showLeaderboard(leaderboardId: String) {
@@ -47,8 +50,13 @@ class PlayGamesServices(
PlayGames.getLeaderboardsClient(activity)
.getLeaderboardIntent(leaderboardId)
.await()
}.getOrNull()
}.onFailure { Log.w(TAG, "Échec ouverture du board $leaderboardId", it) }
.getOrNull()
} ?: return
launchIntent(intent)
}
private companion object {
const val TAG = "PlayGamesServices"
}
}