}
@Override
public Input handle(Action action, String actorID)
{
final ApplyToGroup app = (ApplyToGroup)action;
if (app.getGroup().equals(AbstractAgent.leaveGroup))
{
String old_group = dmodel.getAgentById(actorID).getGroupId();
if (old_group != null)
{
sim.getPlayer(old_group).enqueueInput(new LeaveNotification(
sim.getTime(), LeaveNotification.Reasons.Other, actorID));
}
logger.log(Level.FINE, "Agent {0} has rejoined the free agents group.",
nameOf(actorID));
}
else
{
sim.getPlayer(app.getGroup()).enqueueInput(new JoinRequest(sim.getTime(),
actorID));
logger.log(Level.FINE, "Agent {0} has attempted to join group {1}",
new Object[]
{
nameOf(actorID),
nameOf(app.getGroup())
});
}
return null;
}