Package org.gnubridge.core

Examples of org.gnubridge.core.Direction


    }
    return result;
  }

  public Direction getDummy() {
    Direction result = null;
    if (biddingFinished() && getHighCall() != null) {
      for (Call call : calls) {
        if (call.getBid().hasTrump() && call.getTrump().equals(getHighCall().getTrump())
            && call.pairMatches(getHighCall().getDirection())) {
          result = call.getDirection().opposite();
View Full Code Here


   *      ie: if auction's West becomes the dummy (South during play), the offset
   *      is 1 move clockwise, and when given South as parameter, this method
   *      returns West.
   */
  public Direction getDummyOffsetDirection(Direction original) {
    Direction d = getDummy();
    Direction offset = original;
    for (int i = 0; i < 4; i++) {
      if (d.equals(NORTH)) {
        break;
      } else {
        d = d.clockwise();
        offset = offset.clockwise();
      }
    }
    return offset;
  }
View Full Code Here

    }
    return result;
  }

  public Direction getDummy() {
    Direction result = null;
    if (biddingFinished() && getHighCall() != null) {
      for (Call call : calls) {
        if (call.getBid().hasTrump() && call.getTrump().equals(getHighCall().getTrump())
            && call.pairMatches(getHighCall().getDirection())) {
          result = call.getDirection().opposite();
View Full Code Here

   *      ie: if auction's West becomes the dummy (South during play), the offset
   *      is 1 move clockwise, and when given South as parameter, this method
   *      returns West.
   */
  public Direction getDummyOffsetDirection(Direction original) {
    Direction d = getDummy();
    Direction offset = original;
    for (int i = 0; i < 4; i++) {
      if (d.equals(NORTH)) {
        break;
      } else {
        d = d.clockwise();
        offset = offset.clockwise();
      }
    }
    return offset;
  }
View Full Code Here

    preInitializeGameWithSingleColorSuits();
    MainController mainController = makeController();
    Player humanInBidding = mainController.getBiddingController().getHuman();
    mainController.getBiddingController().placeBid(7, "NT");
    mainController.playGame();
    Direction humanInPlay = mainController.getGameController().getHuman();
    assertEquals(humanInBidding.getHand(), mainController.getGameController().getGame().getPlayer(humanInPlay)
        .getHand());

  }
View Full Code Here

  public HumanAlwaysOnBottom(Direction human) {
    humanBase = human;
  }

  public Direction mapRelativeTo(Direction d) {
    Direction rotation = South.i();
    Direction slot = South.i();

    while (!rotation.equals(d)) {
      slot = slot.clockwise();
      rotation = rotation.clockwise();
    }

    Direction humanOffset = humanBase;
    while (!humanOffset.equals(South.i())) {
      slot = slot.clockwise();
      humanOffset = humanOffset.clockwise();
    }
    return slot;
  }
View Full Code Here

  public Direction getHuman() {
    return human;
  }

  public boolean humanHasMove() {
    Direction nextToMove = game.getNextToPlay().getDirection2();
    if (human.equals(nextToMove) || (human.equals(South.i()) && nextToMove.equals(North.i()))) {
      return true;
    } else {
      return false;
    }
  }
View Full Code Here

    g.drawRect((int) dimensions.getX(), (int) dimensions.getY(), (int) dimensions.getWidth(), (int) dimensions
        .getHeight());
  }

  public Point getExpectedSlot(Direction d) {
    Direction slot = new HumanAlwaysOnBottom(human).mapRelativeTo(d);

    if (slot.equals(South.i())) {
      return new Point((int) (dimensions.getX() + dimensions.getWidth() / 2 - CardPanel.IMAGE_WIDTH / 2),
          (int) (dimensions.getY() + dimensions.getHeight() - CardPanel.IMAGE_HEIGHT));
    } else if (slot.equals(West.i())) {
      return new Point((int) dimensions.getX(),
          (int) (dimensions.getY() + dimensions.getHeight() / 2 - CardPanel.IMAGE_HEIGHT / 2));
    } else if (slot.equals(North.i())) {
      return new Point((int) (dimensions.getX() + dimensions.getWidth() / 2 - CardPanel.IMAGE_WIDTH / 2),
          (int) dimensions.getY());
    } else if (slot.equals(East.i())) {
      return new Point((int) (dimensions.getX() + dimensions.getWidth() - CardPanel.IMAGE_WIDTH),
          (int) (dimensions.getY() + dimensions.getHeight() / 2 - CardPanel.IMAGE_HEIGHT / 2));
    }
    return null;
  }
View Full Code Here

    parent.playGame();

  }

  public Direction allowHumanToPlayIfDummy() {
    Direction newHuman = auction.getDummyOffsetDirection(getHuman().getDirection2());
    if (North.i().equals(newHuman)) {
      newHuman = South.i();
    }
    return newHuman;
  }
View Full Code Here

    }

  }

  private Point calculateUpperLeft(Direction human, Direction player) {
    Direction slot = new HumanAlwaysOnBottom(human).mapRelativeTo(player);
    if (North.i().equals(slot)) {
      return new Point(235, 5);
    } else if (West.i().equals(slot)) {
      return new Point(3, owner.getTotalHeight() - 500);
    } else if (East.i().equals(slot)) {
View Full Code Here

TOP

Related Classes of org.gnubridge.core.Direction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.