@Test public void onPlayerDeath() { PlayerLives playerLives = mock(PlayerLives.class); GamePlayerStorage storage = mock(GamePlayerStorage.class); Respawn respawn = mock(Respawn.class); LivesDeathHandler livesDeathHandler = new LivesDeathHandler( playerLives, storage, respawn ); UUID uuid =UUID.randomUUID(); when(playerLives.decrementLives(eq(uuid))).thenReturn(3); GamePlayer player = mock(GamePlayer.class); when(storage.getPlayer(eq(uuid))).thenReturn(player); GamePlayerStatus playerStatus = mock(GamePlayerStatus.class); when(player.getStatus()).thenReturn(playerStatus); livesDeathHandler.onPlayerDeath(uuid); verify(respawn).markForRespawn(eq(player)); when(playerLives.decrementLives(eq(uuid))).thenReturn(0); livesDeathHandler.onPlayerDeath(uuid); verify(playerStatus).dropOut(); }
@Override public void onPlayerDeath(UUID playerId) { GamePlayer player = gamePlayerStorage.getPlayer(playerId); if (playerLives.decrementLives(playerId) == 0) { player.getStatus().dropOut(); } else { respawn.markForRespawn(player); } }
LivesDeathHandler implements PlayerDeathHandler { @Override public void onPlayerDeath(UUID playerId) { GamePlayer player = gamePlayerStorage.getPlayer(playerId); if (playerLives.decrementLives(playerId) == 0) { player.getStatus().dropOut(); } else { respawn.markForRespawn(player); } } }
LivesDeathHandler implements PlayerDeathHandler { @Override public void onPlayerDeath(UUID playerId) { GamePlayer player = gamePlayerStorage.getPlayer(playerId); if (playerLives.decrementLives(playerId) == 0) { player.getStatus().dropOut(); } else { respawn.markForRespawn(player); } }  }
LivesDeathHandler implements PlayerDeathHandler { @Override public void onPlayerDeath(UUID playerId) { GamePlayer player = gamePlayerStorage.getPlayer(playerId); if (playerLives.decrementLives(playerId) == 0) { player.getStatus().dropOut(); } else { respawn.markForRespawn(player); } }  @Override void onPlayerDeath(UUID playerId); }
LivesDeathHandler implements PlayerDeathHandler { @Override public void onPlayerDeath(UUID playerId) { GamePlayer player = gamePlayerStorage.getPlayer(playerId); if (playerLives.decrementLives(playerId) == 0) { player.getStatus().dropOut(); } else { respawn.markForRespawn(player); } }  @Override void onPlayerDeath(UUID playerId);  }