Ejemplo n.º 1
0
  /**
   * Parse a single line order.
   *
   * <p>Null arguments are not permitted, except for phaseType. If phaseType is
   * Phase.PhaseType.RETREAT, "Move" format orders will be made into Retreat orders, and convoyed
   * moves will be disallowed.
   */
  public NJudgeOrder parse(
      final dip.world.Map map,
      final OrderFactory orderFactory,
      final Phase.PhaseType phaseType,
      final String line)
      throws OrderException {
    // create order parsing context
    final ParseContext pc = new ParseContext(map, orderFactory, phaseType, line);

    // parse results. This also removes the trailing '.' from the order
    final ArrayList resultList = new ArrayList(5);
    final String newOrderLine = removeTrailingDot(parseResults(pc, resultList));

    if (Phase.PhaseType.ADJUSTMENT.equals(phaseType)) {
      return parseAdjustmentOrder(pc, newOrderLine);
    } else {
      // tokenize order
      final String[] tokens = tokenize(newOrderLine);

      // parse order prefix
      OrderPrefix prefix = new OrderPrefix(pc, tokens);

      // parse predicate
      Orderable order = parsePredicate(pc, prefix, tokens);

      // parse text results into real results
      List results = createResults(pc, order, resultList);

      // create NJudgeOrder
      return new NJudgeOrder(order, results, pc.isAdjustmentPhase());
    }
  } // parse()
Ejemplo n.º 2
0
 public boolean isAdjustmentPhase() {
   return (Phase.PhaseType.ADJUSTMENT.equals(phaseType));
 } // isAdjustmentPhase()