{
int i = 0;
ArrayList<EcAction> actions = s.getActions();
for (int c = 0; c < actions.size(); ++c)
{
EcAction a = actions.get(c);
i++;
if (a.isInvalid(s))
{
s.invalidActions++;
continue;
}
EcAction.CanExecuteResult canExecute;
while (!(canExecute= a.canExecute(s, log)).can)
{
if (s.seconds > s.targetSeconds || destination.waypointMissed(s))
{
if (s.settings.overDrone && s.getDrones() < s.getOverDrones(s))
log.printFailure( GameLog.FailReason.OverDrone, mergedDestination, s );
else
log.printFailure( GameLog.FailReason.Waypoint, mergedDestination, s );
return s;
}
int waypointIndex = destination.getCurrWaypointIndex(s);
if (waypointIndex != -1 && destination.getWaypointActions(waypointIndex) > 0)
log.printWaypoint( waypointIndex, s );
if(canExecute.somethingChanged){
if (destination.getMergedWaypoints().isSatisfied(s))
{
log.printSatisfied(i - s.invalidActions, s, mergedDestination);
return s;
}}
}
if (!(a instanceof EcActionWait))
log.printAction(s, a);
a.execute(s, log);
}
log.printFailure(GameLog.FailReason.OutOfActions, s, null);
return s;
}