def test_MultipleMafiaMembers_MustAgreeOnWhoToKill(): player1 = createVillager('test1') player2 = createVillager('test2') mafia1 = createMafia('mafia1') mafia2 = createMafia('mafia2') state = Game() state.state = GameStates.NIGHT state.players = [player1, player2, createVillager(), createVillager(), mafia1, mafia2] systemUnderTest = getInstance(state) #mafia 1 wants to kill player 1 systemUnderTest.transition(Actions.MURDER, player1.id, mafia1.id) assert state.state == GameStates.NIGHT assert player1.state == PlayerStates.ALIVE #mafia 2 wants to kill player 2 systemUnderTest.transition(Actions.MURDER, player2.id, mafia2.id) assert state.state == GameStates.NIGHT assert player1.state == PlayerStates.ALIVE assert player2.state == PlayerStates.ALIVE #mafia 1 decides to agree and kill player2 instead systemUnderTest.transition(Actions.MURDER, player2.id, mafia1.id) assert state.state == GameStates.DAY assert player2.state == PlayerStates.DEAD
def test_GameStateNight_MurderAction_StateIsDayPlayerDead(): player = createVillager('test') mafia = createMafia('mafia') state = Game() state.state = GameStates.NIGHT state.players = [player, createVillager(), createVillager(), mafia] systemUnderTest = getInstance(state) systemUnderTest.transition(Actions.MURDER, player.id, mafia.id) assert state.state == GameStates.DAY assert player.state == PlayerStates.DEAD
def test_GameStateNight_MurderResultsInVillagerCountEqualingMafia_StateIsGameOver(): player = createVillager('test') mafia = createMafia('mafia') state = Game() state.state = GameStates.NIGHT state.players = [player, createVillager(), mafia] systemUnderTest = getInstance(state) systemUnderTest.transition(Actions.MURDER, player.id, mafia.id) assert state.state == GameStates.GAME_OVER assert player.state == PlayerStates.DEAD
def test_CanNotCastVoteIfOnTrial(): state = Game() state.state = GameStates.TRIAL systemUnderTest = getInstance(state) mafia = createMafia('test') villager1 = createVillager('v1') villager2 = createVillager('v2') mafia.state = PlayerStates.ON_TRIAL state.players = [mafia, villager1, villager2] systemUnderTest.transition(Actions.GUILTY, executor=mafia.id) assert mafia.vote == None
def test_DeadManCanNotAccuse(): state = Game() state.state = GameStates.DAY systemUnderTest = getInstance(state) dead_player = createVillager('test') live_player = createVillager('v1') dead_player.state=PlayerStates.DEAD state.players = [dead_player, live_player] result = systemUnderTest.transition(Actions.ACCUSE, live_player.id, dead_player.id) assert state.state == GameStates.DAY assert result == False
def test_GameStateDay_OneAccuseAction_StateIsStillDay(): state = Game() state.state = GameStates.DAY systemUnderTest = getInstance(state) accused = createVillager('test') p1 = createVillager('p1') p2 = createVillager('p2') state.players = [accused, p1, p2] systemUnderTest.transition(Actions.ACCUSE, accused.id, p1.id) assert state.state == GameStates.DAY assert accused.state == PlayerStates.ALIVE
def test_VillagerCanNotMurder(): player1 = createVillager('test1') player2 = createVillager('test1') mafia = createMafia('mafia') state = Game() state.state = GameStates.NIGHT state.players = [player1, player2, mafia] systemUnderTest = getInstance(state) systemUnderTest.transition(Actions.MURDER, player2.id, player1.id) assert state.state == GameStates.NIGHT assert player2.state == PlayerStates.ALIVE
def test_GameStateDay_TwoAccuseActions_StateIsTrialPlayerIsOnTrial(): state = Game() state.state = GameStates.DAY systemUnderTest = getInstance(state) accused = createVillager('test') p1 = createVillager('p1') p2 = createVillager('p2') state.players = [accused, p1, p2] systemUnderTest.transition(Actions.ACCUSE, accused.id, p1.id) systemUnderTest.transition(Actions.ACCUSE, accused.id, p2.id) assert state.state == GameStates.TRIAL assert accused.state == PlayerStates.ON_TRIAL
def test_GameStateTrial_LastMafiaMemberFoundGuilty_StateIsGameOver(): state = Game() state.state = GameStates.TRIAL systemUnderTest = getInstance(state) mafia = createMafia('test') villager1 = createVillager('v1') villager2 = createVillager('v2') mafia.state = PlayerStates.ON_TRIAL state.players = [mafia, villager1, villager2] systemUnderTest.transition(Actions.GUILTY, executor='v1') systemUnderTest.transition(Actions.GUILTY, executor='v2') assert state.state == GameStates.GAME_OVER assert mafia.state == PlayerStates.DEAD
def test_GameStateTrial_FoundGuiltyAction_StateIsNightPlayerOnTrialIsDead(): state = Game() state.state = GameStates.TRIAL systemUnderTest = getInstance(state) player = createVillager('test') villager1 = createVillager('v1') villager2 = createVillager('v2') mafia = createMafia('m') player.state = PlayerStates.ON_TRIAL state.players = [player, villager2, villager1, mafia] systemUnderTest.transition(Actions.NOT_GUILTY, executor='v1') systemUnderTest.transition(Actions.GUILTY, executor='v2') systemUnderTest.transition(Actions.GUILTY, executor='m') assert state.state == GameStates.NIGHT assert player.state == PlayerStates.DEAD
def test_GameStateMarshalling_RemovePlayerAction_PlayerRemoved(): state = Game() state.state = GameStates.MARSHALLING systemUnderTest = getInstance(state) player = createVillager('test') state.players = [player] success = systemUnderTest.transition(Actions.REMOVE_PLAYER, executor=player.id) assert player not in state.players assert success
def test_GameStateTrial_FoundNotGuiltyAction_StateIsDayPlayerOnTrialIsAlive(): state = Game() state.state = GameStates.TRIAL systemUnderTest = getInstance(state) player = createVillager('test') villager1 = createVillager('v1') villager2 = createVillager('v2') villager3 = createVillager('v3') villager3.state = PlayerStates.DEAD mafia = createMafia('m') player.state = PlayerStates.ON_TRIAL state.players = [player, villager2, villager1, mafia, villager3] systemUnderTest.transition(Actions.GUILTY, executor='m') assert state.state == GameStates.TRIAL systemUnderTest.transition(Actions.NOT_GUILTY, executor='v1') assert state.state == GameStates.TRIAL systemUnderTest.transition(Actions.NOT_GUILTY, executor='v2') assert state.state == GameStates.DAY assert player.state == PlayerStates.ALIVE