HashSet<Actor> allActors = new HashSet<Actor>(getActors(client.getClientType()));
for(ActorMove move : message.getMoves()) {
Actor actor = move.getActor();
if(actor.getCurrentPosition() != null)
throw new ProtocolException("Position was already assigned to actor: " + actor.getId(), client);
if(placedActors.contains(actor))
throw new ProtocolException("Position was specified multiple times to actor: " + actor.getId(), client);
if(!allActors.contains(actor))
throw new ProtocolException("Client placed other player's actor: " + actor.getId(), client);
placedActors.add(actor);
if(move.getTargetNode() == null)
throw new ProtocolException("The target node was not specified for actor: " + actor.getId(), client);
if(move.getTargetNode().isOccupied(client.getClientType()))
throw new ProtocolException(String.format("Actor %s cannot be placed to node %s, the node is already occupied",
actor.getId(), move.getTargetNode().getId()),
client);
if(move.getTransportType() != null)
throw new ProtocolException("Transport type was specified in the placement message for actor: " + actor.getId(), client);
if(usedNodes.contains(move.getTargetNode()))
throw new ProtocolException(String.format("Actor %s cannot be placed to node %s, the node is already occupied",
actor.getId(), move.getTargetNode().getId()),
client);
usedNodes.add(move.getTargetNode());
}
for(Actor actor : allActors) {
if(!placedActors.contains(actor))
throw new ProtocolException("Actor was not placed: " + actor.getId(), client);
}
}