Beispiel #1
0
 private void assignCards() {
   player.clearCards();
   dealer.clearCards();
   for (int i = 0; i < 3; ++i) {
     player.assignCard(genNewCard());
     dealer.assignCard(genNewCard());
   }
 }
Beispiel #2
0
 private void judge() {
   if (player.numOfSpecialCards() > dealer.numOfSpecialCards()) {
     player.win();
     dealer.lose();
   } else if (player.numOfSpecialCards() < dealer.numOfSpecialCards()) {
     dealer.win();
     player.lose();
   } else {
     int playerScore = 0, dealerScore = 0;
     for (Card card : player.getCards()) {
       if (!card.isSpecial()) playerScore += card.getValue();
       playerScore %= 10;
     }
     for (Card card : dealer.getCards()) {
       if (!card.isSpecial()) dealerScore += card.getValue();
       dealerScore %= 10;
     }
     if (playerScore > dealerScore) {
       player.win();
       dealer.lose();
     } else {
       dealer.win();
       player.lose();
     }
   }
 }
Beispiel #3
0
 /**
  * Update changing components.
  *
  * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
  */
 @Override
 public void paintComponent(Graphics g) {
   money.setText(String.valueOf(player.getMoney()));
   record.setText(String.valueOf(bestScore));
   dealerPanel.removeAll();
   playerPanel.removeAll();
   for (Card dealerCard : dealer.getCards()) dealerPanel.add(dealerCard);
   for (Card playerCard : player.getCards()) playerPanel.add(playerCard);
   revalidate();
 }
Beispiel #4
0
  @Property(name = PROPERTY_DEALER)
  public boolean setDealer(Dealer value) {
    boolean changed = false;

    if (this.dealer != value) {

      Dealer oldValue = this.dealer;
      Player source = this;
      if (this.dealer != null) {
        this.dealer = null;
        oldValue.setPlayer(null);
      }
      this.dealer = value;

      if (value != null) {
        value.setPlayer(this);
      }
      changed = true;
    }
    return changed;
  }
Beispiel #5
0
 public void RegisterSubscribers(IObserver a_observer) {
   m_dealer.Register(a_observer);
 }
Beispiel #6
0
 public int GetDealerScore() {
   return m_dealer.CalcScore();
 }
Beispiel #7
0
 public Iterable<Card> GetDealerHand() {
   return m_dealer.GetHand();
 }
Beispiel #8
0
 public boolean Stand() {
   return m_dealer.Stand(m_player);
 }
Beispiel #9
0
 public boolean Hit() {
   return m_dealer.Hit(m_player);
 }
Beispiel #10
0
 public boolean NewGame() {
   return m_dealer.NewGame(m_player);
 }
Beispiel #11
0
 public boolean IsDealerWinner() {
   return m_dealer.IsDealerWinner(m_player);
 }
Beispiel #12
0
 public boolean IsGameOver() {
   return m_dealer.IsGameOver();
 }
        public void onClick(View v) {
          dealer.setRoom(room_no.getText().toString());
          dealer.joinRoom();

          closePage();
        }
Beispiel #14
0
 public boolean isGameOver(Dealer dealer, PlayerList playerList) {
   if (dealer.isDeckEmpty() && playerList.isAllPlayerHandEmpty()) return true;
   return false;
 }