當前位置: 首頁>>代碼示例>>PHP>>正文


PHP State::isEndGame方法代碼示例

本文整理匯總了PHP中State::isEndGame方法的典型用法代碼示例。如果您正苦於以下問題:PHP State::isEndGame方法的具體用法?PHP State::isEndGame怎麽用?PHP State::isEndGame使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在State的用法示例。


在下文中一共展示了State::isEndGame方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: reconcile

 public function reconcile($game)
 {
     $state = $game->getState();
     debug("Wallet::reconcile state [{$state}] money [" . $this->money . "]");
     $prize = 0;
     $wager = $this->wager;
     if ($state != State::RECONCILED && State::isEndGame($state)) {
         // handle double down
         if ($game->isDoubleDown()) {
             $wager *= 2;
         }
         switch ($state) {
             case State::USER_BLACKJACK:
                 $prize = $wager * 1.5;
                 break;
             case State::DEALER_BUST:
             case State::USER_WIN:
                 $prize = $wager;
                 break;
             case State::DEALER_BLACKJACK:
             case State::USER_BUST:
             case State::DEALER_WIN:
                 $prize += -$wager;
                 break;
         }
         // handle insurance
         if ($game->userInsured()) {
             if ($state == State::DEALER_BLACKJACK) {
                 // user original wager insurance
                 $prize += $this->wager;
             } else {
                 // user original wager insurance
                 $prize -= $this->wager / 2;
             }
         }
         $this->money += $prize;
         debug("Wallet::reconcile final prize [{$prize}] money [" . $this->money . "]");
     }
     $game->reconcile();
 }
開發者ID:perenchiod,項目名稱:php-blackjack,代碼行數:40,代碼來源:blackjack.php

示例2: testIsEndGame

 public function testIsEndGame()
 {
     $this->assertTrue(State::isEndGame(State::USER_BUST));
     $this->assertTrue(State::isEndGame(State::DEALER_BUST));
     $this->assertTrue(State::isEndGame(State::PUSH));
     $this->assertTrue(State::isEndGame(State::USER_WIN));
     $this->assertTrue(State::isEndGame(State::DEALER_WIN));
     $this->assertTrue(State::isEndGame(State::USER_BLACKJACK));
     $this->assertTrue(State::isEndGame(State::DEALER_BLACKJACK));
     $this->assertFalse(State::isEndGame(State::INVALID));
     $this->assertFalse(State::isEndGame(State::START));
     $this->assertFalse(State::isEndGame(State::PLAYING));
     $this->assertFalse(State::isEndGame(State::PLAYING_ACTIVE));
     $this->assertFalse(State::isEndGame(State::OFFER_INSURANCE));
 }
開發者ID:perenchiod,項目名稱:php-blackjack,代碼行數:15,代碼來源:testblackjack.php


注:本文中的State::isEndGame方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。