Jeu de test, optimisation correction de bug
This commit is contained in:
@@ -4,7 +4,54 @@
|
|||||||
"Bash(tree:*)",
|
"Bash(tree:*)",
|
||||||
"Bash(./gradlew:*)",
|
"Bash(./gradlew:*)",
|
||||||
"Bash(dir:*)",
|
"Bash(dir:*)",
|
||||||
"Bash(timeout:*)"
|
"Bash(timeout:*)",
|
||||||
|
"WebSearch",
|
||||||
|
"Bash(git rm:*)",
|
||||||
|
"Bash(python:*)",
|
||||||
|
"Bash(gradlew.bat build:*)",
|
||||||
|
"Bash(gradlew.bat assembleDebug:*)",
|
||||||
|
"Bash(cmd.exe /c \"gradlew.bat assembleDebug 2>&1\")",
|
||||||
|
"Bash(cmd.exe:*)",
|
||||||
|
"Bash(./gradlew.bat assembleDebug:*)",
|
||||||
|
"Bash(git add:*)",
|
||||||
|
"Bash(git commit:*)",
|
||||||
|
"Bash(git push:*)",
|
||||||
|
"mcp__plugin_serena_serena__initial_instructions",
|
||||||
|
"mcp__plugin_serena_serena__list_dir",
|
||||||
|
"mcp__plugin_serena_serena__activate_project",
|
||||||
|
"mcp__plugin_serena_serena__get_symbols_overview",
|
||||||
|
"mcp__plugin_serena_serena__find_symbol",
|
||||||
|
"mcp__plugin_serena_serena__read_file",
|
||||||
|
"mcp__plugin_serena_serena__create_text_file",
|
||||||
|
"mcp__plugin_serena_serena__replace_content",
|
||||||
|
"Bash(adb:*)",
|
||||||
|
"mcp__plugin_serena_serena__search_for_pattern",
|
||||||
|
"Bash(mkdir:*)",
|
||||||
|
"Bash(.\\\\gradlew.bat:*)",
|
||||||
|
"Bash(Select-String -Pattern \"error|Error|BUILD|FAILED|SUCCESS\")",
|
||||||
|
"Bash(Select-Object:*)",
|
||||||
|
"Bash(rm:*)",
|
||||||
|
"Bash(findstr /i \"\\\\.java$\")",
|
||||||
|
"Bash(findstr:*)",
|
||||||
|
"Bash(.\\\\gradlew.bat test:*)",
|
||||||
|
"Bash(./gradlew.bat test)",
|
||||||
|
"Bash(./gradlew.bat test --tests \"*QuestionCategoryTest*\")",
|
||||||
|
"Bash(./gradlew.bat test:*)",
|
||||||
|
"Bash(wc:*)",
|
||||||
|
"Bash(./gradlew.bat:*)",
|
||||||
|
"mcp__plugin_serena_serena__replace_symbol_body",
|
||||||
|
"mcp__plugin_serena_serena__think_about_collected_information",
|
||||||
|
"mcp__plugin_serena_serena__find_file",
|
||||||
|
"Bash(gradlew test:*)",
|
||||||
|
"Bash(cat app/build/reports/tests/testDebugUnitTest/index.html)",
|
||||||
|
"Bash(Select-String:*)",
|
||||||
|
"Bash(gh pr view:*)",
|
||||||
|
"Bash(cmd:*)",
|
||||||
|
"Bash(git restore:*)",
|
||||||
|
"Bash(git config:*)",
|
||||||
|
"mcp__plugin_serena_serena__check_onboarding_performed",
|
||||||
|
"Bash(powershell:*)",
|
||||||
|
"mcp__plugin_serena_serena__execute_shell_command"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+8
@@ -4,6 +4,14 @@
|
|||||||
<selectionStates>
|
<selectionStates>
|
||||||
<SelectionState runConfigName="Unnamed">
|
<SelectionState runConfigName="Unnamed">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
|
<DropdownSelection timestamp="2026-01-16T22:28:09.607776900Z">
|
||||||
|
<Target type="DEFAULT_BOOT">
|
||||||
|
<handle>
|
||||||
|
<DeviceId pluginId="PhysicalDevice" identifier="serial=3B15B701VS600000" />
|
||||||
|
</handle>
|
||||||
|
</Target>
|
||||||
|
</DropdownSelection>
|
||||||
|
<DialogSelection />
|
||||||
</SelectionState>
|
</SelectionState>
|
||||||
</selectionStates>
|
</selectionStates>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ dependencies {
|
|||||||
implementation 'androidx.constraintlayout:constraintlayout:2.2.0'
|
implementation 'androidx.constraintlayout:constraintlayout:2.2.0'
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
testImplementation 'org.mockito:mockito-core:5.7.0'
|
testImplementation 'org.mockito:mockito-core:5.7.0'
|
||||||
|
testImplementation 'org.robolectric:robolectric:4.11.1'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
|
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
|
||||||
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
|
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
|
||||||
|
|||||||
@@ -72,7 +72,7 @@
|
|||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
|
|
||||||
<!-- Legacy Activities (to be removed) -->
|
<!-- Legacy Activities (to be removed) -->
|
||||||
$1
|
<!-- Legacy activities placeholder -->
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.boidelov3.Jeux"
|
android:name="com.example.boidelov3.Jeux"
|
||||||
|
|||||||
@@ -1320,7 +1320,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 163,
|
"id": 163,
|
||||||
"question": "Ceux qui ont un_permis de conduire",
|
"question": "Ceux qui ont un permis de conduire",
|
||||||
"gorger": 1,
|
"gorger": 1,
|
||||||
"distribution": true,
|
"distribution": true,
|
||||||
"recois": true
|
"recois": true
|
||||||
@@ -1337,6 +1337,166 @@
|
|||||||
"gorger": 3,
|
"gorger": 3,
|
||||||
"distribution": true,
|
"distribution": true,
|
||||||
"recois": true
|
"recois": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 166,
|
||||||
|
"question": "Ceux qui ont un TikTok avec plus de 1000 abonnés",
|
||||||
|
"gorger": 2,
|
||||||
|
"distribution": true,
|
||||||
|
"recois": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 167,
|
||||||
|
"question": "<J1> doit parler avec un <variante> pendant <manches> manches",
|
||||||
|
"gorger": 0,
|
||||||
|
"variante": [
|
||||||
|
"accent allemand",
|
||||||
|
"accent belge",
|
||||||
|
"accent suisse",
|
||||||
|
"accent canadien"
|
||||||
|
],
|
||||||
|
"arret": "Plus d'accent !"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 168,
|
||||||
|
"question": "Le/La plus 'marabout' du groupe (celui/celle qui a toujours des remèdes)",
|
||||||
|
"gorger": 2,
|
||||||
|
"distribution": false,
|
||||||
|
"recois": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 169,
|
||||||
|
"question": "Ceux qui ont déjà été bloqués sur les réseaux sociaux",
|
||||||
|
"gorger": 3,
|
||||||
|
"distribution": true,
|
||||||
|
"recois": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 170,
|
||||||
|
"question": "Ceux qui ont leur permis de conduire",
|
||||||
|
"gorger": 1,
|
||||||
|
"distribution": true,
|
||||||
|
"recois": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 171,
|
||||||
|
"question": "<J1> doit faire rire <J2> en 30 secondes. Si échec : 5 gorgées",
|
||||||
|
"gorger": 0,
|
||||||
|
"recois": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 172,
|
||||||
|
"question": "Les fans de K-Pop",
|
||||||
|
"gorger": 3,
|
||||||
|
"distribution": true,
|
||||||
|
"recois": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 173,
|
||||||
|
"question": "Ceux qui ont déjà fait du covoiturage avec des inconnus",
|
||||||
|
"gorger": 2,
|
||||||
|
"distribution": true,
|
||||||
|
"recois": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 174,
|
||||||
|
"question": "<J1> doit mimer <variante> pendant que les autres devinent. 30 secondes, 3 gorgées par échec",
|
||||||
|
"gorger": 0,
|
||||||
|
"variante": [
|
||||||
|
"un chat",
|
||||||
|
"un chien",
|
||||||
|
"une voiture",
|
||||||
|
"un téléphone",
|
||||||
|
"un avion"
|
||||||
|
],
|
||||||
|
"arret": "Fin du mime !"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 175,
|
||||||
|
"question": "Le/La plus 'intello' du groupe (vote à main levée)",
|
||||||
|
"gorger": 3,
|
||||||
|
"distribution": false,
|
||||||
|
"recois": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 176,
|
||||||
|
"question": "Ceux qui ont déjà participé à un marathon ou semi-marathon",
|
||||||
|
"gorger": 2,
|
||||||
|
"distribution": true,
|
||||||
|
"recois": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 177,
|
||||||
|
"question": "Jeu du NI : Tous ceux qui ont un <variante> sur eux doivent boire 2 gorgées",
|
||||||
|
"gorger": 0,
|
||||||
|
"variante": [
|
||||||
|
"stylo",
|
||||||
|
"post-it",
|
||||||
|
"mèche",
|
||||||
|
"alliance",
|
||||||
|
"bracelet"
|
||||||
|
],
|
||||||
|
"arret": "Fin du jeu du NI !"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 178,
|
||||||
|
"question": "Ceux qui ont déjà fait une surprise-party à quelqu'un",
|
||||||
|
"gorger": 2,
|
||||||
|
"distribution": true,
|
||||||
|
"recois": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 179,
|
||||||
|
"question": "<J1> doit compléter chaque phrase de <J2> par 'oui chef' pendant <manches> manches",
|
||||||
|
"gorger": 0,
|
||||||
|
"arret": "Plus de 'oui chef' !"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 180,
|
||||||
|
"question": "Le/La plus 'sportif/sportive' du groupe",
|
||||||
|
"gorger": 2,
|
||||||
|
"distribution": false,
|
||||||
|
"recois": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 181,
|
||||||
|
"question": "Ceux qui ont un compte sur onlyfans",
|
||||||
|
"gorger": 4,
|
||||||
|
"distribution": true,
|
||||||
|
"recois": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 182,
|
||||||
|
"question": "<J1> doit choisir entre <variante>. Le perdant boit 3 gorgées",
|
||||||
|
"gorger": 0,
|
||||||
|
"variante": [
|
||||||
|
"Instagram et TikTok",
|
||||||
|
"Netflix et Disney+",
|
||||||
|
"Pizza et Burger",
|
||||||
|
"Chat et Chien",
|
||||||
|
"Montagne et Mer"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 183,
|
||||||
|
"question": "Ceux qui ont déjà fait un regretté post-soirée (message à un ex)",
|
||||||
|
"gorger": 4,
|
||||||
|
"distribution": true,
|
||||||
|
"recois": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 184,
|
||||||
|
"question": "Le/La plus 'organisé' du groupe",
|
||||||
|
"gorger": 2,
|
||||||
|
"distribution": false,
|
||||||
|
"recois": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 185,
|
||||||
|
"question": "Ceux qui ont déjà été coincés dans un ascenseur",
|
||||||
|
"gorger": 3,
|
||||||
|
"distribution": true,
|
||||||
|
"recois": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
+40
-6
@@ -22,6 +22,7 @@ import com.example.boidelov3.R;
|
|||||||
import com.example.boidelov3.data.PlayerStats;
|
import com.example.boidelov3.data.PlayerStats;
|
||||||
import com.example.boidelov3.data.QuestionCategory;
|
import com.example.boidelov3.data.QuestionCategory;
|
||||||
import com.example.boidelov3.data.QuestionRepository;
|
import com.example.boidelov3.data.QuestionRepository;
|
||||||
|
import com.example.boidelov3.game.GameEngine;
|
||||||
import com.example.boidelov3.Question;
|
import com.example.boidelov3.Question;
|
||||||
import com.example.boidelov3.Questions;
|
import com.example.boidelov3.Questions;
|
||||||
import com.example.boidelov3.utils.ErrorHandler;
|
import com.example.boidelov3.utils.ErrorHandler;
|
||||||
@@ -65,8 +66,8 @@ public class BoideloClassicGameActivity extends AppCompatActivity {
|
|||||||
private Map<String, PlayerStats> playerStatsMap;
|
private Map<String, PlayerStats> playerStatsMap;
|
||||||
|
|
||||||
// Services
|
// Services
|
||||||
// private SoundManager soundManager; // TODO: Fix SoundManager constructor
|
private com.example.boidelov3.utils.SoundManager soundManager;
|
||||||
// private GameEngine gameEngine; // TODO: Fix GameEngine
|
private GameEngine gameEngine;
|
||||||
private QuestionRepository questionRepository;
|
private QuestionRepository questionRepository;
|
||||||
|
|
||||||
// Random
|
// Random
|
||||||
@@ -165,8 +166,8 @@ public class BoideloClassicGameActivity extends AppCompatActivity {
|
|||||||
* Initialise les services
|
* Initialise les services
|
||||||
*/
|
*/
|
||||||
private void initServices() {
|
private void initServices() {
|
||||||
// soundManager = new SoundManager(this); // TODO: Fix SoundManager
|
soundManager = com.example.boidelov3.utils.SoundManager.getInstance(this);
|
||||||
// gameEngine = new GameEngine(); // TODO: Fix GameEngine
|
gameEngine = new GameEngine();
|
||||||
questionRepository = new QuestionRepository(this);
|
questionRepository = new QuestionRepository(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +180,16 @@ public class BoideloClassicGameActivity extends AppCompatActivity {
|
|||||||
Questions q = result.getData();
|
Questions q = result.getData();
|
||||||
questions = q != null && q.getQuestions() != null ? q.getQuestions() : new ArrayList<>();
|
questions = q != null && q.getQuestions() != null ? q.getQuestions() : new ArrayList<>();
|
||||||
} else {
|
} else {
|
||||||
|
android.util.Log.e("BoideloClassicGame", "Erreur lors du chargement des questions: " + result.getError());
|
||||||
questions = new ArrayList<>();
|
questions = new ArrayList<>();
|
||||||
|
|
||||||
|
// Afficher une erreur à l'utilisateur
|
||||||
|
new androidx.appcompat.app.AlertDialog.Builder(this)
|
||||||
|
.setTitle("Erreur de chargement")
|
||||||
|
.setMessage("Impossible de charger les questions. Veuillez réinstaller l'application.")
|
||||||
|
.setPositiveButton("Fermer", (dialog, which) -> finish())
|
||||||
|
.setCancelable(false)
|
||||||
|
.show();
|
||||||
}
|
}
|
||||||
questionsAvecManches = new ArrayList<>();
|
questionsAvecManches = new ArrayList<>();
|
||||||
}
|
}
|
||||||
@@ -261,6 +271,9 @@ public class BoideloClassicGameActivity extends AppCompatActivity {
|
|||||||
private void handleGameEnd() {
|
private void handleGameEnd() {
|
||||||
isFinishingGame = true;
|
isFinishingGame = true;
|
||||||
|
|
||||||
|
// Sauvegarder les stats avant de terminer
|
||||||
|
saveGameStats();
|
||||||
|
|
||||||
// Prépare les stats pour l'activité de fin
|
// Prépare les stats pour l'activité de fin
|
||||||
Intent intent = new Intent(this, EndGameActivity.class);
|
Intent intent = new Intent(this, EndGameActivity.class);
|
||||||
intent.putExtra("PLAYER_STATS", new ArrayList<>(playerStatsMap.values()));
|
intent.putExtra("PLAYER_STATS", new ArrayList<>(playerStatsMap.values()));
|
||||||
@@ -329,6 +342,8 @@ public class BoideloClassicGameActivity extends AppCompatActivity {
|
|||||||
*/
|
*/
|
||||||
private void displayNewQuestion() {
|
private void displayNewQuestion() {
|
||||||
if (questions == null || questions.isEmpty()) {
|
if (questions == null || questions.isEmpty()) {
|
||||||
|
android.util.Log.e("BoideloClassicGame", "Aucune question disponible - fin du jeu");
|
||||||
|
handleGameEnd();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,7 +387,15 @@ public class BoideloClassicGameActivity extends AppCompatActivity {
|
|||||||
* Affiche la notification de fin de manche
|
* Affiche la notification de fin de manche
|
||||||
*/
|
*/
|
||||||
private void showMancheEndNotification() {
|
private void showMancheEndNotification() {
|
||||||
// TODO: Implémenter la notification de fin de manche
|
if (soundManager != null) {
|
||||||
|
soundManager.playManche();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vibration pour feedback haptique
|
||||||
|
BoideloAnimationUtils.triggerErrorHaptic(this);
|
||||||
|
|
||||||
|
// Afficher un message toast pour informer les joueurs
|
||||||
|
android.widget.Toast.makeText(this, "⏱️ Manche terminée!", android.widget.Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -958,7 +981,18 @@ public class BoideloClassicGameActivity extends AppCompatActivity {
|
|||||||
* Sauvegarde les stats du jeu
|
* Sauvegarde les stats du jeu
|
||||||
*/
|
*/
|
||||||
private void saveGameStats() {
|
private void saveGameStats() {
|
||||||
// TODO: Implémenter la sauvegarde des stats
|
if (questionRepository != null && playerStatsMap != null) {
|
||||||
|
// Calculer le total des questions posées
|
||||||
|
int totalQuestionsPlayed = totalQuestionsAsked;
|
||||||
|
int playersCount = toutlesjoueurs != null ? toutlesjoueurs.size() : 0;
|
||||||
|
|
||||||
|
// Sauvegarder dans SharedPreferences via le repository
|
||||||
|
questionRepository.saveGameStats(totalQuestionsPlayed, playersCount);
|
||||||
|
|
||||||
|
android.util.Log.d("BoideloClassicGame",
|
||||||
|
"Stats sauvegardées: " + totalQuestionsPlayed + " questions, " +
|
||||||
|
playersCount + " joueurs");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -101,6 +101,8 @@ public class GameSelectionActivity extends AppCompatActivity implements GameAdap
|
|||||||
public void onItemClick(GameInfo gameInfo) {
|
public void onItemClick(GameInfo gameInfo) {
|
||||||
if (!gameInfo.isAvailable()) {
|
if (!gameInfo.isAvailable()) {
|
||||||
// Afficher un message "Coming soon"
|
// Afficher un message "Coming soon"
|
||||||
|
android.widget.Toast.makeText(this, gameInfo.getName() + " - Bientôt disponible!",
|
||||||
|
android.widget.Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +117,9 @@ public class GameSelectionActivity extends AppCompatActivity implements GameAdap
|
|||||||
startActivity(new Intent(this, com.example.boidelov3.games.papelito.PapelitoSetupActivity.class));
|
startActivity(new Intent(this, com.example.boidelov3.games.papelito.PapelitoSetupActivity.class));
|
||||||
break;
|
break;
|
||||||
case RULES:
|
case RULES:
|
||||||
// TODO: Implémenter RulesListActivity
|
// À implémenter: RulesListActivity
|
||||||
|
android.widget.Toast.makeText(this, "Règles de jeux - Bientôt disponible!",
|
||||||
|
android.widget.Toast.LENGTH_SHORT).show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import android.util.Log;
|
|||||||
|
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.Base64;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classe utilitaire pour la gestion sécurisée des clés API et configuration sensible.
|
* Classe utilitaire pour la gestion sécurisée des clés API et configuration sensible.
|
||||||
@@ -188,12 +187,25 @@ public class SecureConfig {
|
|||||||
* @return Le hash de la clé
|
* @return Le hash de la clé
|
||||||
*/
|
*/
|
||||||
public String hashApiKey(String apiKey) {
|
public String hashApiKey(String apiKey) {
|
||||||
|
if (apiKey == null) {
|
||||||
|
Log.w(TAG, "Tentative de hasher une clé API null");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (apiKey.trim().isEmpty()) {
|
||||||
|
Log.w(TAG, "Tentative de hasher une clé API vide");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||||
byte[] hash = digest.digest(apiKey.getBytes("UTF-8"));
|
byte[] hash = digest.digest(apiKey.getBytes("UTF-8"));
|
||||||
return Base64.getEncoder().encodeToString(hash);
|
return android.util.Base64.encodeToString(hash, android.util.Base64.NO_WRAP);
|
||||||
} catch (Exception e) {
|
} catch (java.security.NoSuchAlgorithmException e) {
|
||||||
Log.e(TAG, "Erreur lors du hash de la clé", e);
|
Log.e(TAG, "SHA-256 non disponible sur cet appareil - hash impossible", e);
|
||||||
|
return null;
|
||||||
|
} catch (java.io.UnsupportedEncodingException e) {
|
||||||
|
Log.e(TAG, "UTF-8 encoding non supporté - impossible", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -207,7 +219,7 @@ public class SecureConfig {
|
|||||||
public String generateSecureToken(int length) {
|
public String generateSecureToken(int length) {
|
||||||
byte[] token = new byte[length];
|
byte[] token = new byte[length];
|
||||||
secureRandom.nextBytes(token);
|
secureRandom.nextBytes(token);
|
||||||
return Base64.getEncoder().encodeToString(token);
|
return android.util.Base64.encodeToString(token, android.util.Base64.NO_WRAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<string name="pseudo">Pseudo</string>
|
<string name="pseudo">Pseudo</string>
|
||||||
<string name="nom">Nom</string>
|
<string name="nom">Nom</string>
|
||||||
<string name="c_ki">C\'est qui</string>
|
<string name="c_ki">C\'est qui</string>
|
||||||
<string name="komment_il_s_appel">comment il s\'appelle</string>
|
<string name="comment_il_s_appelle">Comment il s\'appelle</string>
|
||||||
<string name="who">who</string>
|
<string name="who">who</string>
|
||||||
<string name="joueur">Joueur</string>
|
<string name="joueur">Joueur</string>
|
||||||
<string name="prenom">Prénom</string>
|
<string name="prenom">Prénom</string>
|
||||||
|
|||||||
@@ -340,21 +340,42 @@ public class PapelitoGameTest {
|
|||||||
List<String> playerNames = Arrays.asList("Alice", "Bob", "Charlie", "David", "Eve");
|
List<String> playerNames = Arrays.asList("Alice", "Bob", "Charlie", "David", "Eve");
|
||||||
game.setupGame(playerNames, 3);
|
game.setupGame(playerNames, 3);
|
||||||
|
|
||||||
// Kill 2 civils using game method
|
// Set game state to voting
|
||||||
game.setGameState(PapelitoGame.GameState.VOTING);
|
game.setGameState(PapelitoGame.GameState.VOTING);
|
||||||
PapelitoPlayer civil1 = game.getAlivePlayers().get(0);
|
|
||||||
PapelitoPlayer civil2 = game.getAlivePlayers().get(1);
|
|
||||||
PapelitoPlayer civil3 = game.getAlivePlayers().get(2);
|
|
||||||
PapelitoPlayer undercover1 = game.getAlivePlayers().get(3);
|
|
||||||
PapelitoPlayer undercover2 = game.getAlivePlayers().get(4);
|
|
||||||
|
|
||||||
|
// Find actual civils and undercovers (roles are assigned randomly)
|
||||||
|
PapelitoPlayer civil1 = null;
|
||||||
|
PapelitoPlayer civil2 = null;
|
||||||
|
PapelitoPlayer undercover1 = null;
|
||||||
|
PapelitoPlayer undercover2 = null;
|
||||||
|
PapelitoPlayer undercover3 = null;
|
||||||
|
|
||||||
|
for (PapelitoPlayer player : game.getAlivePlayers()) {
|
||||||
|
if (player.isCivil()) {
|
||||||
|
if (civil1 == null) civil1 = player;
|
||||||
|
else if (civil2 == null) civil2 = player;
|
||||||
|
} else if (player.isUndercover()) {
|
||||||
|
if (undercover1 == null) undercover1 = player;
|
||||||
|
else if (undercover2 == null) undercover2 = player;
|
||||||
|
else if (undercover3 == null) undercover3 = player;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// We should have 2 civils and 3 undercovers
|
||||||
|
assertNotNull("Should have at least 1 civil", civil1);
|
||||||
|
assertNotNull("Should have at least 2 civils", civil2);
|
||||||
|
assertNotNull("Should have at least 1 undercover", undercover1);
|
||||||
|
assertNotNull("Should have at least 2 undercovers", undercover2);
|
||||||
|
assertNotNull("Should have at least 3 undercovers", undercover3);
|
||||||
|
|
||||||
|
// Eliminate both civils
|
||||||
game.vote(undercover1, civil1);
|
game.vote(undercover1, civil1);
|
||||||
game.eliminateMostVoted();
|
game.eliminateMostVoted();
|
||||||
|
|
||||||
game.vote(undercover2, civil2);
|
game.vote(undercover2, civil2);
|
||||||
game.eliminateMostVoted();
|
game.eliminateMostVoted();
|
||||||
|
|
||||||
// Act
|
// Act - Now we have 0 civils and 3 undercovers
|
||||||
boolean result = game.checkGameOver();
|
boolean result = game.checkGameOver();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
|||||||
Reference in New Issue
Block a user