Package org.gnubridge.core.bidding.rules

Source Code of org.gnubridge.core.bidding.rules.Rebid

package org.gnubridge.core.bidding.rules;

import org.gnubridge.core.Hand;
import org.gnubridge.core.bidding.Auctioneer;
import org.gnubridge.core.bidding.Bid;
import org.gnubridge.core.bidding.Call;

public abstract class Rebid extends BiddingRule {
  protected Bid response;
  protected Bid opening;

  public Rebid(Auctioneer a, Hand h) {
    super(a, h);
  }

  @Override
  protected boolean applies() {
    if (validOpeningAndResponse()) {
      response = auction.getPartnersLastCall().getBid();
      opening = auction.getPartnersCall(auction.getPartnersLastCall()).getBid();
    }
    return validOpeningAndResponse();
  }

  private boolean validOpeningAndResponse() {
    Call responderCall = auction.getPartnersLastCall();
    if (responderCall != null && responderCall.getBid().hasTrump()) {
      Call myOpeningBid = auction.getPartnersCall(responderCall);
      if (myOpeningBid != null && myOpeningBid.getBid().hasTrump() && auction.isOpening(myOpeningBid)) {
        return true;
      }
    }
    return false;
  }

  @Override
  abstract protected Bid prepareBid();

}
TOP

Related Classes of org.gnubridge.core.bidding.rules.Rebid

TOP
Copyright © 2018 www.massapi.com. 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.