package com.example.boidelov3.games.papelito;

import org.junit.Test;
import static org.junit.Assert.*;

/**
 * Tests unitaires pour la classe PapelitoPlayer.
 * Couvre la gestion des joueurs, leurs rôles, votes et état de jeu.
 */
public class PapelitoPlayerTest {

    // =============================
    // Constructor tests
    // =============================

    @Test
    public void constructorWithNameOnly_initializesCorrectly() {
        PapelitoPlayer player = new PapelitoPlayer("Alice");

        assertEquals("Player name should be Alice", "Alice", player.getName());
        assertNull("Role should be null initially", player.getRole());
        assertNull("Secret word should be null initially", player.getSecretWord());
        assertTrue("Player should be alive initially", player.isAlive());
        assertEquals("Initial votes should be 0", 0, player.getVotesReceived());
    }

    @Test
    public void constructorWithFullParameters_initializesCorrectly() {
        PapelitoPlayer.Role role = PapelitoPlayer.Role.UNDERCOVER;
        String secretWord = "chaise";

        PapelitoPlayer player = new PapelitoPlayer("Bob", role, secretWord);

        assertEquals("Player name should be Bob", "Bob", player.getName());
        assertEquals("Role should be UNDERCOVER", role, player.getRole());
        assertEquals("Secret word should be set", secretWord, player.getSecretWord());
        assertTrue("Player should be alive initially", player.isAlive());
        assertEquals("Initial votes should be 0", 0, player.getVotesReceived());
    }

    @Test
    public void constructorWithNullName_allowsNull() {
        PapelitoPlayer player = new PapelitoPlayer(null);

        assertNull("Player name should be null", player.getName());
        assertNull("Role should be null initially", player.getRole());
        assertNull("Secret word should be null initially", player.getSecretWord());
        assertTrue("Player should be alive initially", player.isAlive());
        assertEquals("Initial votes should be 0", 0, player.getVotesReceived());
    }

    // =============================
    // Role tests
    // =============================

    @Test
    public void isMrWhite_withMrWhiteRole_returnsTrue() {
        PapelitoPlayer player = new PapelitoPlayer("Test", PapelitoPlayer.Role.MR_WHITE, "secret");
        assertTrue("isMrWhite() should return true for MR_WHITE role", player.isMrWhite());
    }

    @Test
    public void isMrWhite_withCivilRole_returnsFalse() {
        PapelitoPlayer player = new PapelitoPlayer("Test", PapelitoPlayer.Role.CIVIL, "secret");
        assertFalse("isMrWhite() should return false for CIVIL role", player.isMrWhite());
    }

    @Test
    public void isMrWhite_withNullRole_returnsFalse() {
        PapelitoPlayer player = new PapelitoPlayer("Test");
        player.setRole(null);
        assertFalse("isMrWhite() should return false for null role", player.isMrWhite());
    }

    @Test
    public void isUndercover_withUndercoverRole_returnsTrue() {
        PapelitoPlayer player = new PapelitoPlayer("Test", PapelitoPlayer.Role.UNDERCOVER, "secret");
        assertTrue("isUndercover() should return true for UNDERCOVER role", player.isUndercover());
    }

    @Test
    public void isUndercover_withCivilRole_returnsFalse() {
        PapelitoPlayer player = new PapelitoPlayer("Test", PapelitoPlayer.Role.CIVIL, "secret");
        assertFalse("isUndercover() should return false for CIVIL role", player.isUndercover());
    }

    @Test
    public void isUndercover_withNullRole_returnsFalse() {
        PapelitoPlayer player = new PapelitoPlayer("Test");
        player.setRole(null);
        assertFalse("isUndercover() should return false for null role", player.isUndercover());
    }

    @Test
    public void isCivil_withCivilRole_returnsTrue() {
        PapelitoPlayer player = new PapelitoPlayer("Test", PapelitoPlayer.Role.CIVIL, "secret");
        assertTrue("isCivil() should return true for CIVIL role", player.isCivil());
    }

    @Test
    public void isCivil_withUndercoverRole_returnsFalse() {
        PapelitoPlayer player = new PapelitoPlayer("Test", PapelitoPlayer.Role.UNDERCOVER, "secret");
        assertFalse("isCivil() should return false for UNDERCOVER role", player.isCivil());
    }

    @Test
    public void isCivil_withMrWhiteRole_returnsFalse() {
        PapelitoPlayer player = new PapelitoPlayer("Test", PapelitoPlayer.Role.MR_WHITE, "secret");
        assertFalse("isCivil() should return false for MR_WHITE role", player.isCivil());
    }

    @Test
    public void isCivil_withNullRole_returnsFalse() {
        PapelitoPlayer player = new PapelitoPlayer("Test");
        player.setRole(null);
        assertFalse("isCivil() should return false for null role", player.isCivil());
    }

    @Test
    public void roleMethods_mutuallyExclusive() {
        PapelitoPlayer player = new PapelitoPlayer("Test", PapelitoPlayer.Role.UNDERCOVER, "secret");

        assertTrue("Player should be undercover", player.isUndercover());
        assertFalse("Player should not be civil", player.isCivil());
        assertFalse("Player should not be Mr. White", player.isMrWhite());
    }

    @Test
    public void roleMethods_allRolesWork() {
        PapelitoPlayer player1 = new PapelitoPlayer("Player1", PapelitoPlayer.Role.CIVIL, "mot1");
        PapelitoPlayer player2 = new PapelitoPlayer("Player2", PapelitoPlayer.Role.UNDERCOVER, "mot2");
        PapelitoPlayer player3 = new PapelitoPlayer("Player3", PapelitoPlayer.Role.MR_WHITE, "mot3");

        assertTrue("Civil player should be civil", player1.isCivil());
        assertFalse("Civil player should not be undercover", player1.isUndercover());
        assertFalse("Civil player should not be Mr. White", player1.isMrWhite());

        assertFalse("Undercover player should not be civil", player2.isCivil());
        assertTrue("Undercover player should be undercover", player2.isUndercover());
        assertFalse("Undercover player should not be Mr. White", player2.isMrWhite());

        assertFalse("Mr. White should not be civil", player3.isCivil());
        assertFalse("Mr. White should not be undercover", player3.isUndercover());
        assertTrue("Mr. White should be Mr. White", player3.isMrWhite());
    }

    // =============================
    // Voting tests
    // =============================

    @Test
    public void addVote_incrementsVotesReceived() {
        PapelitoPlayer player = new PapelitoPlayer("Test");

        assertEquals("Initial votes should be 0", 0, player.getVotesReceived());
        player.addVote();
        assertEquals("After one vote, votes should be 1", 1, player.getVotesReceived());
    }

    @Test
    public void addVote_multipleVotes_accumulates() {
        PapelitoPlayer player = new PapelitoPlayer("Test");

        player.addVote();
        player.addVote();
        player.addVote();
        player.addVote();
        player.addVote();

        assertEquals("After 5 votes, votes should be 5", 5, player.getVotesReceived());
    }

    @Test
    public void addVote_zeroVotes() {
        PapelitoPlayer player = new PapelitoPlayer("Test");

        assertEquals("Initial votes should be 0", 0, player.getVotesReceived());
        // Don't add any votes
        assertEquals("Votes should remain 0", 0, player.getVotesReceived());
    }

    @Test
    public void resetVotes_setsVotesToZero() {
        PapelitoPlayer player = new PapelitoPlayer("Test");

        // Add some votes first
        player.addVote();
        player.addVote();
        player.addVote();
        assertEquals("After 3 votes, votes should be 3", 3, player.getVotesReceived());

        // Reset votes
        player.resetVotes();
        assertEquals("After reset, votes should be 0", 0, player.getVotesReceived());
    }

    @Test
    public void resetVotes_whenAlreadyZero() {
        PapelitoPlayer player = new PapelitoPlayer("Test");

        assertEquals("Initial votes should be 0", 0, player.getVotesReceived());
        player.resetVotes();
        assertEquals("After reset when already 0, votes should still be 0", 0, player.getVotesReceived());
    }

    @Test
    public void getVotesReceived_returnsCorrectCount() {
        PapelitoPlayer player = new PapelitoPlayer("Test");

        assertEquals("Initial votes should be 0", 0, player.getVotesReceived());

        player.addVote();
        assertEquals("After 1 vote, votes should be 1", 1, player.getVotesReceived());

        player.addVote();
        assertEquals("After 2 votes, votes should be 2", 2, player.getVotesReceived());

        player.addVote();
        assertEquals("After 3 votes, votes should be 3", 3, player.getVotesReceived());
    }

    @Test
    public void voting_worksWithMultiplePlayers() {
        PapelitoPlayer player1 = new PapelitoPlayer("Player1");
        PapelitoPlayer player2 = new PapelitoPlayer("Player2");
        PapelitoPlayer player3 = new PapelitoPlayer("Player3");

        // Player1 gets 3 votes
        player1.addVote();
        player1.addVote();
        player1.addVote();

        // Player2 gets 1 vote
        player2.addVote();

        // Player3 gets 0 votes
        // Don't add any votes to player3

        assertEquals("Player1 should have 3 votes", 3, player1.getVotesReceived());
        assertEquals("Player2 should have 1 vote", 1, player2.getVotesReceived());
        assertEquals("Player3 should have 0 votes", 0, player3.getVotesReceived());
    }

    @Test
    public void addVote_afterReset() {
        PapelitoPlayer player = new PapelitoPlayer("Test");

        // Add some votes
        player.addVote();
        player.addVote();
        assertEquals("After 2 votes, should be 2", 2, player.getVotesReceived());

        // Reset
        player.resetVotes();
        assertEquals("After reset, should be 0", 0, player.getVotesReceived());

        // Add more votes
        player.addVote();
        player.addVote();
        player.addVote();
        assertEquals("After 3 more votes, should be 3", 3, player.getVotesReceived());
    }

    @Test
    public void addVote_largeNumberOfVotes() {
        PapelitoPlayer player = new PapelitoPlayer("Test");

        // Add many votes
        for (int i = 0; i < 100; i++) {
            player.addVote();
        }

        assertEquals("After 100 votes, should be 100", 100, player.getVotesReceived());
    }

    // =============================
    // Elimination tests
    // =============================

    @Test
    public void eliminate_setsIsAliveToFalse() {
        PapelitoPlayer player = new PapelitoPlayer("Test");

        assertTrue("Player should be alive initially", player.isAlive());
        player.eliminate();
        assertFalse("Player should not be alive after elimination", player.isAlive());
    }

    @Test
    public void eliminate_canBeCalledMultipleTimes() {
        PapelitoPlayer player = new PapelitoPlayer("Test");

        assertTrue("Player should be alive initially", player.isAlive());

        // Eliminate multiple times
        player.eliminate();
        assertFalse("Player should not be alive after first elimination", player.isAlive());

        player.eliminate();
        assertFalse("Player should still not be alive after second elimination", player.isAlive());

        player.eliminate();
        assertFalse("Player should still not be alive after third elimination", player.isAlive());
    }

    @Test
    public void isAlive_afterEliminate_returnsFalse() {
        PapelitoPlayer player = new PapelitoPlayer("Test");

        assertTrue("Player should be alive initially", player.isAlive());
        player.eliminate();
        assertFalse("isAlive() should return false after eliminate", player.isAlive());
    }

    @Test
    public void eliminate_preservesOtherState() {
        PapelitoPlayer player = new PapelitoPlayer("Test", PapelitoPlayer.Role.UNDERCOVER, "secret");

        // Set some state
        player.addVote();
        player.addVote();
        player.setRole(PapelitoPlayer.Role.CIVIL);
        player.setSecretWord("newSecret");

        assertTrue("Player should be alive before elimination", player.isAlive());

        // Eliminate
        player.eliminate();

        // Verify other state is preserved
        assertFalse("Player should not be alive", player.isAlive());
        assertEquals("Name should be preserved", "Test", player.getName());
        assertEquals("Role should be preserved", PapelitoPlayer.Role.CIVIL, player.getRole());
        assertEquals("Secret word should be preserved", "newSecret", player.getSecretWord());
        assertEquals("Votes should be preserved", 2, player.getVotesReceived());
    }

    @Test
    public void setAlive_canReviveEliminatedPlayer() {
        PapelitoPlayer player = new PapelitoPlayer("Test");

        // Eliminate player
        player.eliminate();
        assertFalse("Player should not be alive after elimination", player.isAlive());

        // Revive player
        player.setAlive(true);
        assertTrue("Player should be alive after revival", player.isAlive());
    }

    @Test
    public void setAlive_canKillAlivePlayer() {
        PapelitoPlayer player = new PapelitoPlayer("Test");

        assertTrue("Player should be alive initially", player.isAlive());

        // Kill player
        player.setAlive(false);
        assertFalse("Player should not be alive after setting alive to false", player.isAlive());
    }

    @Test
    public void aliveState_independentBetweenPlayers() {
        PapelitoPlayer player1 = new PapelitoPlayer("Player1");
        PapelitoPlayer player2 = new PapelitoPlayer("Player2");

        assertTrue("Both players should be alive initially", player1.isAlive());
        assertTrue("Both players should be alive initially", player2.isAlive());

        // Eliminate only player1
        player1.eliminate();

        assertFalse("Player1 should not be alive", player1.isAlive());
        assertTrue("Player2 should still be alive", player2.isAlive());
    }

    // =============================
    // Secret word tests
    // =============================

    @Test
    public void setSecretWord_and_getSecretWord() {
        PapelitoPlayer player = new PapelitoPlayer("Test");

        assertNull("Secret word should be null initially", player.getSecretWord());

        String secretWord = "testSecret";
        player.setSecretWord(secretWord);
        assertEquals("Secret word should be set correctly", secretWord, player.getSecretWord());
    }

    @Test
    public void getSecretWord_beforeSet_returnsNull() {
        PapelitoPlayer player = new PapelitoPlayer("Test");
        assertNull("Secret word should be null before setting", player.getSecretWord());
    }

    @Test
    public void setSecretWord_multipleTimes() {
        PapelitoPlayer player = new PapelitoPlayer("Test");

        player.setSecretWord("firstSecret");
        assertEquals("First secret word should be set", "firstSecret", player.getSecretWord());

        player.setSecretWord("secondSecret");
        assertEquals("Second secret word should replace first", "secondSecret", player.getSecretWord());

        player.setSecretWord("thirdSecret");
        assertEquals("Third secret word should replace second", "thirdSecret", player.getSecretWord());
    }

    @Test
    public void setSecretWord_emptyString() {
        PapelitoPlayer player = new PapelitoPlayer("Test");

        player.setSecretWord("");
        assertEquals("Empty string should be allowed", "", player.getSecretWord());
    }

    @Test
    public void setSecretWord_specialCharacters() {
        PapelitoPlayer player = new PapelitoPlayer("Test");

        String specialWord = "mot_avec_des_accents_é_à_ç_œ_â";
        player.setSecretWord(specialWord);
        assertEquals("Special characters should be preserved", specialWord, player.getSecretWord());
    }

    @Test
    public void setSecretWord_withConstructor() {
        String secretWord = "constructorSecret";
        PapelitoPlayer player = new PapelitoPlayer("Test", PapelitoPlayer.Role.CIVIL, secretWord);

        assertEquals("Secret word should be set via constructor", secretWord, player.getSecretWord());
    }

    @Test
    public void setSecretWord_nullAllowed() {
        PapelitoPlayer player = new PapelitoPlayer("Test");

        // Set a secret word first
        player.setSecretWord("someSecret");
        assertEquals("Secret word should be set", "someSecret", player.getSecretWord());

        // Set to null
        player.setSecretWord(null);
        assertNull("Secret word should be settable to null", player.getSecretWord());
    }

    @Test
    public void secretWord_independentBetweenPlayers() {
        PapelitoPlayer player1 = new PapelitoPlayer("Player1");
        PapelitoPlayer player2 = new PapelitoPlayer("Player2");

        player1.setSecretWord("secret1");
        player2.setSecretWord("secret2");

        assertEquals("Player1 should have its own secret", "secret1", player1.getSecretWord());
        assertEquals("Player2 should have its own secret", "secret2", player2.getSecretWord());
    }

    // =============================
    // toString tests
    // =============================

    @Test
    public void toString_withRole_includesRoleDisplayName() {
        PapelitoPlayer player = new PapelitoPlayer("Test", PapelitoPlayer.Role.UNDERCOVER, "secret");

        String toString = player.toString();

        assertTrue("toString should contain player name", toString.contains("Test"));
        assertTrue("toString should contain role display name", toString.contains("Undercover"));
        assertTrue("toString should have correct format", toString.matches("Test \\(Undercover\\)"));
    }

    @Test
    public void toString_withCivilRole() {
        PapelitoPlayer player = new PapelitoPlayer("Test", PapelitoPlayer.Role.CIVIL, "secret");

        String toString = player.toString();

        assertTrue("toString should contain Civil role", toString.contains("Civil"));
        assertTrue("toString should have correct format", toString.matches("Test \\(Civil\\)"));
    }

    @Test
    public void toString_withMrWhiteRole() {
        PapelitoPlayer player = new PapelitoPlayer("Test", PapelitoPlayer.Role.MR_WHITE, "secret");

        String toString = player.toString();

        assertTrue("toString should contain Mr. White role", toString.contains("Mr. White"));
        assertTrue("toString should have correct format", toString.matches("Test \\(Mr\\. White\\)"));
    }

    @Test
    public void toString_withNullRole_showsQuestionMark() {
        PapelitoPlayer player = new PapelitoPlayer("Test");
        player.setRole(null);

        String toString = player.toString();

        assertTrue("toString should contain player name", toString.contains("Test"));
        assertTrue("toString should show question mark for null role", toString.contains("?"));
        assertTrue("toString should have correct format", toString.matches("Test \\(\\?\\)"));
    }

    @Test
    public void toString_formatConsistency() {
        PapelitoPlayer player1 = new PapelitoPlayer("Player1", PapelitoPlayer.Role.CIVIL, "secret1");
        PapelitoPlayer player2 = new PapelitoPlayer("Player2", PapelitoPlayer.Role.UNDERCOVER, "secret2");
        PapelitoPlayer player3 = new PapelitoPlayer("Player3");
        player3.setRole(null);

        String toString1 = player1.toString();
        String toString2 = player1.toString();

        assertEquals("toString should be consistent", toString1, toString2);
        assertTrue("Format should be 'name (role)'", toString1.matches("Player1 \\(Civil\\)"));

        assertTrue("Player2 format should be 'Player2 (Undercover)'",
                player2.toString().matches("Player2 \\(Undercover\\)"));
        assertTrue("Player3 format should be 'Player3 (?)'",
                player3.toString().matches("Player3 \\(\\?\\)"));
    }

    @Test
    public void toString_withSpecialCharactersInName() {
        PapelitoPlayer player = new PapelitoPlayer("José éàï", PapelitoPlayer.Role.CIVIL, "secret");

        String toString = player.toString();

        assertTrue("toString should contain special characters in name", toString.contains("José éàï"));
        assertTrue("toString should contain role", toString.contains("Civil"));
    }

    @Test
    public void toString_withSpacesInName() {
        PapelitoPlayer player = new PapelitoPlayer("Anna Marie", PapelitoPlayer.Role.UNDERCOVER, "secret");

        String toString = player.toString();

        assertTrue("toString should contain spaces in name", toString.contains("Anna Marie"));
        assertTrue("toString should contain role", toString.contains("Undercover"));
    }

    @Test
    public void toString_identifiesPlayerCorrectly() {
        PapelitoPlayer player = new PapelitoPlayer("TestPlayer", PapelitoPlayer.Role.MR_WHITE, "secret");

        String toString = player.toString();

        assertTrue("toString should identify the player uniquely", toString.contains("TestPlayer"));
        assertTrue("toString should show the role", toString.contains("Mr. White"));
    }

    @Test
    public void toString_allRolesHaveCorrectDisplayNames() {
        PapelitoPlayer civil = new PapelitoPlayer("Civil", PapelitoPlayer.Role.CIVIL, "secret");
        PapelitoPlayer undercover = new PapelitoPlayer("Undercover", PapelitoPlayer.Role.UNDERCOVER, "secret");
        PapelitoPlayer mrWhite = new PapelitoPlayer("MrWhite", PapelitoPlayer.Role.MR_WHITE, "secret");

        assertTrue("Civil role should display 'Civil'", civil.toString().contains("Civil"));
        assertTrue("Undercover role should display 'Undercover'", undercover.toString().contains("Undercover"));
        assertTrue("Mr. White role should display 'Mr. White'", mrWhite.toString().contains("Mr. White"));
    }

    // =============================
    // Integration tests
    // =============================

    @Test
    public void fullGameScenario() {
        // Create players with different roles
        PapelitoPlayer civil = new PapelitoPlayer("Civil", PapelitoPlayer.Role.CIVIL, "table");
        PapelitoPlayer undercover = new PapelitoPlayer("Undercover", PapelitoPlayer.Role.UNDERCOVER, "chaise");
        PapelitoPlayer mrWhite = new PapelitoPlayer("MrWhite", PapelitoPlayer.Role.MR_WHITE, null);

        // Verify initial state
        assertTrue("All players should be alive initially", civil.isAlive() && undercover.isAlive() && mrWhite.isAlive());
        assertEquals("All players should have 0 votes initially", 0, civil.getVotesReceived() + undercover.getVotesReceived() + mrWhite.getVotesReceived());

        // Simulate voting
        civil.addVote();
        civil.addVote();
        civil.addVote();  // Civil gets 3 votes

        undercover.addVote();  // Undercover gets 1 vote
        // MrWhite gets 0 votes

        // Verify voting results
        assertEquals("Civil should have 3 votes", 3, civil.getVotesReceived());
        assertEquals("Undercover should have 1 vote", 1, undercover.getVotesReceived());
        assertEquals("MrWhite should have 0 votes", 0, mrWhite.getVotesReceived());

        // Eliminate player with most votes (Civil)
        civil.eliminate();
        assertFalse("Civil should not be alive after elimination", civil.isAlive());
        assertTrue("Undercover should still be alive", undercover.isAlive());
        assertTrue("MrWhite should still be alive", mrWhite.isAlive());

        // Verify toString still works after elimination
        assertTrue("Civil toString should show eliminated state", civil.toString().contains("Civil"));
        assertTrue("Undercover toString should show role", undercover.toString().contains("Undercover"));
        assertTrue("MrWhite toString should show role", mrWhite.toString().contains("Mr. White"));
    }

    @Test
    public void roleMethodsWorkAfterStateChanges() {
        PapelitoPlayer player = new PapelitoPlayer("Test", PapelitoPlayer.Role.UNDERCOVER, "secret");

        // Verify role methods initially
        assertTrue("Should be undercover initially", player.isUndercover());
        assertFalse("Should not be civil initially", player.isCivil());
        assertFalse("Should not be Mr. White initially", player.isMrWhite());

        // Change role
        player.setRole(PapelitoPlayer.Role.CIVIL);

        // Verify role methods after change
        assertFalse("Should not be undercover after role change", player.isUndercover());
        assertTrue("Should be civil after role change", player.isCivil());
        assertFalse("Should not be Mr. White after role change", player.isMrWhite());

        // Change role again
        player.setRole(PapelitoPlayer.Role.MR_WHITE);

        // Verify role methods after second change
        assertFalse("Should not be undercover after second role change", player.isUndercover());
        assertFalse("Should not be civil after second role change", player.isCivil());
        assertTrue("Should be Mr. White after second role change", player.isMrWhite());
    }

    @Test
    public void constructorNullSafety() {
        // Test constructor with various name inputs
        PapelitoPlayer player1 = new PapelitoPlayer("A");
        PapelitoPlayer player2 = new PapelitoPlayer("VeryLongNameThatMightBeUsedInGame");
        PapelitoPlayer player3 = new PapelitoPlayer("Name with spaces and numbers 123");

        assertEquals("Single character name", "A", player1.getName());
        assertEquals("Long name", "VeryLongNameThatMightBeUsedInGame", player2.getName());
        assertEquals("Name with spaces and numbers", "Name with spaces and numbers 123", player3.getName());
    }

    @Test
    public void allPropertiesIndependentBetweenInstances() {
        PapelitoPlayer player1 = new PapelitoPlayer("Player1", PapelitoPlayer.Role.UNDERCOVER, "secret1");
        PapelitoPlayer player2 = new PapelitoPlayer("Player2", PapelitoPlayer.Role.CIVIL, "secret2");

        // Modify player1
        player1.addVote();
        player1.addVote();
        player1.eliminate();
        player1.setSecretWord("newSecret1");
        player1.setRole(PapelitoPlayer.Role.MR_WHITE);

        // Verify player2 is unaffected
        assertEquals("Player2 name should be unchanged", "Player2", player2.getName());
        assertEquals("Player2 role should be unchanged", PapelitoPlayer.Role.CIVIL, player2.getRole());
        assertEquals("Player2 secret word should be unchanged", "secret2", player2.getSecretWord());
        assertTrue("Player2 should still be alive", player2.isAlive());
        assertEquals("Player2 votes should be 0", 0, player2.getVotesReceived());
        assertFalse("Player2 should not be Mr. White", player2.isMrWhite());
        assertTrue("Player2 should be civil", player2.isCivil());
        assertFalse("Player2 should not be undercover", player2.isUndercover());

        // Verify player1 has the modified values
        assertEquals("Player1 name should be unchanged", "Player1", player1.getName());
        assertEquals("Player1 role should be Mr. White", PapelitoPlayer.Role.MR_WHITE, player1.getRole());
        assertEquals("Player1 secret word should be updated", "newSecret1", player1.getSecretWord());
        assertFalse("Player1 should not be alive", player1.isAlive());
        assertEquals("Player1 votes should be 2", 2, player1.getVotesReceived());
        assertTrue("Player1 should be Mr. White", player1.isMrWhite());
        assertFalse("Player1 should not be civil", player1.isCivil());
        assertFalse("Player1 should not be undercover", player1.isUndercover());
    }
}