@Test public void whenTeleportSinglePlayerThenTeleported() { runAssertions((teams, teamGameMap) -> { TeamPlayer gamePlayer = mock(TeamPlayer.class); UUID uuid = UUID.randomUUID(); when(playerStorage.getPlayer(eq(uuid))).thenReturn(gamePlayer); when(gamePlayer.getTeam()).thenReturn(teams.get(0)); teamGameMap.teleportPlayer(uuid); verify(gamePlayer).teleport(argThat(location -> configuredTeamLocations.get(gamePlayer.getTeam()).contains(location))); }); }
@Override public void teleportPlayer(UUID playerId) { TeamPlayer player = teamPlayerRepository.getPlayer(playerId); List<Location> locations = computeLocationsForTeam(player.getTeam()); player.teleport(locations.get(ThreadLocalRandom.current().nextInt(locations.size()))); }
TeamGameMap extends AbstractGameMap { @Override public void teleportPlayer(UUID playerId) { TeamPlayer player = teamPlayerRepository.getPlayer(playerId); List<Location> locations = computeLocationsForTeam(player.getTeam()); player.teleport(locations.get(ThreadLocalRandom.current().nextInt(locations.size()))); } }
TeamGameMap extends AbstractGameMap { @Override public void teleportPlayer(UUID playerId) { TeamPlayer player = teamPlayerRepository.getPlayer(playerId); List<Location> locations = computeLocationsForTeam(player.getTeam()); player.teleport(locations.get(ThreadLocalRandom.current().nextInt(locations.size()))); } TeamGameMap(String name, GamePlayerStorage<TeamPlayer> teamPlayerRepository, Map<Team, List<Location>> configuredTeamLocations); }
TeamGameMap extends AbstractGameMap { @Override public void teleportPlayer(UUID playerId) { TeamPlayer player = teamPlayerRepository.getPlayer(playerId); List<Location> locations = computeLocationsForTeam(player.getTeam()); player.teleport(locations.get(ThreadLocalRandom.current().nextInt(locations.size()))); } TeamGameMap(String name, GamePlayerStorage<TeamPlayer> teamPlayerRepository, Map<Team, List<Location>> configuredTeamLocations); @Override void teleportPlayers(); @Override void teleportPlayer(UUID playerId); }
TeamGameMap extends AbstractGameMap { @Override public void teleportPlayer(UUID playerId) { TeamPlayer player = teamPlayerRepository.getPlayer(playerId); List<Location> locations = computeLocationsForTeam(player.getTeam()); player.teleport(locations.get(ThreadLocalRandom.current().nextInt(locations.size()))); } TeamGameMap(String name, GamePlayerStorage<TeamPlayer> teamPlayerRepository, Map<Team, List<Location>> configuredTeamLocations); @Override void teleportPlayers(); @Override void teleportPlayer(UUID playerId);  }