コード例 #1
0
    public function show_Interact()
    {
        if ($this->_myGame == null) {
            $this->welcome();
            return;
        }
        $cards = "";
        $values = array();
        $totalValue = 0;
        foreach ($this->_myCards as $c) {
            $totalValue += $c['card'] == "a" ? 1 : $c['value'];
            $values[] = $c['card'] == "a" ? "1/11" : $c['value'];
            $cards .= PlayingCards::displayCard($c['card'], $c['color']);
        }
        if ($totalValue > 21) {
            $this->output('load', 'game/finish');
            return;
        }
        $d_cards = array();
        foreach ($this->_dealerCards as $c) {
            array_push($d_cards, PlayingCards::displayCard($c['card'], $c['color']));
        }
        // last card is hidden
        array_pop($d_cards);
        array_push($d_cards, PlayingCards::displayCardBack());
        $s_cards = implode("", $d_cards);
        $this->output('maintext', 'Deine Karten (' . implode(" + ", $values) . ' Punkte): <br />' . $cards . ' <br /> <br />
		Die Karten des Dealers: <br />' . $s_cards);
        $this->output('options', array('game/card' => 'Noch eine Karte', 'game/finish' => 'Keine Karte mehr, aufhören'));
    }