Exemplo n.º 1
0
 private String getTurnType(TurnType t) {
   if (TurnType.TL.equals(t.getValue())) {
     return AbstractPrologCommandPlayer.A_LEFT;
   } else if (TurnType.TSHL.equals(t.getValue())) {
     return AbstractPrologCommandPlayer.A_LEFT_SH;
   } else if (TurnType.TSLL.equals(t.getValue())) {
     return AbstractPrologCommandPlayer.A_LEFT_SL;
   } else if (TurnType.TR.equals(t.getValue())) {
     return AbstractPrologCommandPlayer.A_RIGHT;
   } else if (TurnType.TSHR.equals(t.getValue())) {
     return AbstractPrologCommandPlayer.A_RIGHT_SH;
   } else if (TurnType.TSLR.equals(t.getValue())) {
     return AbstractPrologCommandPlayer.A_RIGHT_SL;
   } else if (TurnType.KL.equals(t.getValue())) {
     return AbstractPrologCommandPlayer.A_LEFT_KEEP;
   } else if (TurnType.KR.equals(t.getValue())) {
     return AbstractPrologCommandPlayer.A_RIGHT_KEEP;
   }
   return null;
 }
Exemplo n.º 2
0
 private void playMakeTurnIn(
     RouteDirectionInfo next, int dist, RouteDirectionInfo pronounceNextNext) {
   CommandBuilder play = getNewCommandPlayerToPlay();
   if (play != null) {
     String tParam = getTurnType(next.getTurnType());
     boolean isPlay = true;
     if (tParam != null) {
       play.turn(tParam, dist);
     } else if (next.getTurnType().isRoundAbout()) {
       play.roundAbout(dist, next.getTurnType().getTurnAngle(), next.getTurnType().getExitOut());
     } else if (next.getTurnType().getValue().equals(TurnType.TU)
         || next.getTurnType().getValue().equals(TurnType.TRU)) {
       play.makeUT(dist);
     } else {
       isPlay = false;
     }
     // small preparation to next after next
     if (pronounceNextNext != null) {
       TurnType t = pronounceNextNext.getTurnType();
       isPlay = true;
       if (next.getTurnType().getValue().equals(TurnType.C) && !TurnType.C.equals(t.getValue())) {
         play.goAhead(dist);
       }
       if (TurnType.TL.equals(t.getValue())
           || TurnType.TSHL.equals(t.getValue())
           || TurnType.TSLL.equals(t.getValue())
           || TurnType.TU.equals(t.getValue())
           || TurnType.KL.equals(t.getValue())) {
         play.then().bearLeft();
       } else if (TurnType.TR.equals(t.getValue())
           || TurnType.TSHR.equals(t.getValue())
           || TurnType.TSLR.equals(t.getValue())
           || TurnType.KR.equals(t.getValue())) {
         play.then().bearRight();
       }
     }
     if (isPlay) {
       play.play();
     }
   }
 }