Package com.svanloon.game.wizard.client.player

Examples of com.svanloon.game.wizard.client.player.Bid


    }
    return false;
  }

  private Bid bid(Card trump, int lead, int cardsDealt, Round round) {
    Bid bid = new Bid();
    int minBid = 0;
    int playerCount = 0;
    for (Player player: new PlayerIterator(_playerCollection, lead)) {
      int notAllowedToBid = -1;

      if(playerCount == this._playerCollection.size() - 1) {
        boolean isPlayerWinning = isPlayerWinning(player.getId());
        boolean isEven = isPlayerWinning && go.getBidType().equals(BidType.EVEN);
        boolean isCanadian = isPlayerWinning &&  go.getBidType().equals(BidType.CANADIAN);
        boolean isHardCore = cardsDealt > 3 && go.getBidType().equals(BidType.HARDCORE);
   
        if(isEven || isCanadian || isHardCore) {
          int bidSoFar = bid.bidSoFar();
          if(cardsDealt - bidSoFar >= 0) {
            notAllowedToBid = cardsDealt - bidSoFar;
            // in canadian rules, zero is always allowed.
            if(isCanadian && notAllowedToBid == 0 ) {
              notAllowedToBid = -1;
            }
          }
          //else they can bid anything

        }
      }

      int bidInt = player.bid(trump, minBid, cardsDealt, notAllowedToBid);
      if(bidInt == notAllowedToBid) {
        System.err.print("illegal bid");
        throw new RuntimeException("illegal bid");
      }
      bid.addIndividualBid(new IndividualBid(player, bidInt));
      if(go.getBidType().equals(BidType.STANDARD) ||
        go.getBidType().equals(BidType.EVEN) ||
        go.getBidType().equals(BidType.CANADIAN) ||
        go.getBidType().equals(BidType.HARDCORE)
      ) {
View Full Code Here


        trump = new Card(null, trumpPicker.pickTrump(), -1);
        gameEventNotifier.notify(new NewTrumpEvent(trump));
        round.setTrump(trump);
      }
      int cardsDealt = roundId;
      Bid bid = bid(trump, lead, cardsDealt, round);
      if(go.getBidType().equals(BidType.HIDDEN)) {
        for(IndividualBid individualBid :bid.getBids()) {
          gameEventNotifier.notify(new PlayerBidEvent(individualBid.getPlayer().getId(), individualBid.getBid()));
          round.setBid(individualBid.getPlayer().getId(), individualBid.getBid());
        }
      }
      RoundSummary roundSummary = new RoundSummary();
      for (int i = 0; i < roundId; i++) {
        TrickTracker trickTracker = playTrick(trump, lead, round);
        roundSummary.addTrickTracker(trickTracker);
        int playerIdWhoWon = trickTracker.winningPlay().getPlayerId();
        lead = findPlayerIndex(playerIdWhoWon);
      }
      if(go.getBidType().equals(BidType.SECRET)) {
        for(IndividualBid individualBid :bid.getBids()) {
          gameEventNotifier.notify(new PlayerBidEvent(individualBid.getPlayer().getId(), individualBid.getBid()));
          round.setBid(individualBid.getPlayer().getId(), individualBid.getBid());
        }
      }
      scoreRound(roundSummary, bid, _game);
View Full Code Here

TOP

Related Classes of com.svanloon.game.wizard.client.player.Bid

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.