示例#1
0
 private void identifyShellsOrientation(Element[][] previous) {
   Map<Actor, Command> candidates = new HashMap<>();
   for (Actor actor : actors) {
     if (actor instanceof Shell && ((Shell) actor).getOrientation() == null) {
       for (Command each : Command.values()) {
         if (each == Command.ACT) continue; // skip ACT
         Element prev = actor.getPosition().act(each.back(), 2).get(previous);
         if (prev != null && prev.getType() == ElementType.SHELL) {
           if (!candidates.containsKey(actor) || ((Shell) prev).getOrientation() == each) {
             candidates.put(actor, each);
           }
         }
       }
     }
   }
   for (Map.Entry<Actor, Command> each : candidates.entrySet()) {
     ((Shell) each.getKey()).setOrientation(each.getValue());
   }
 }
示例#2
0
 private boolean isPossible(Command command, Actor actor) {
   Position p = actor.getPosition();
   Element el = p.act(command, 1).get(map);
   return el != null && el.getType() == ElementType.FREE;
 }