echo '[' . $players[$key] . ']  '; sort($val); $cardObj->watch_card($val); } echo '<hr>'; // 遊戲開始 $flow = new Flow(); $tab = new Table(); $flow::$members = count($players); // 第一手 $card = $flow->fire($groups); $tab->add($card); echo $players[$flow->now_player()] . ' : ' . $suit[$card] . '<br>'; for ($i = 0; $i < 55; $i++) { $flow->move_next(); $card = $flow->run($tab->get_on_table()); if (!$card) { echo '[' . $i . '] ' . $players[$flow->now_player()] . ' : PASS ! <br>'; continue; // 沒牌了 } if ($card > 0) { $tab->add($card); $show_card = $suit[$card]; } else { $tab->discard($flow->now_player(), -intval($card)); $show_card = "<font color='blue'>蓋牌 " . $suit[-intval($card)] . "</font>"; } echo '[' . $i . '] ' . $players[$flow->now_player()] . ' : ' . $show_card . '<br>'; // test foreach ($flow->hands() as $key => $val) {
<?php /** * Copyright 2013 princehaku * * FileName : index.php * Created on : 13-3-19 , 下午7:01 * Author : zhongwei.bzw */ define("DEV_MODE", true); define("APP_PATH", dirname(__FILE__)); define("FLOW_PATH", dirname(dirname(dirname(__FILE__))) . "/flowphp/"); include FLOW_PATH . "flow.php"; $flow = new Flow(); $flow->run();
<?php /** * Copyright 2013 princehaku * * FileName : index.php * Created on : 13-3-19 , 下午7:01 * Author : zhongwei.bzw */ define("DEV_MODE", true); define("APP_PATH", dirname(__FILE__)); define("FLOW_PATH", dirname(dirname(dirname(__FILE__))) . "/flowphp/"); include FLOW_PATH . "flow.php"; $flow = new Flow(); $flow->run('cli');
fwrite(STDOUT, $players[$flow->now_player()] . '出牌: ' . $suit[$card]); for ($i = 0; $i < 55; $i++) { $flow->move_next(); fwrite(STDOUT, " || " . $players[$flow->now_player()] . "請出牌:"); $str = trim(fgets(STDIN)); if (empty($str)) { fwrite(STDOUT, "Empty input str, try again."); $flow->move_back(); $i--; continue; } $tmp = explode(",", $str); // (Call=1|Fold=2),SUIT(0|1|2|3),NUMBER $action = $tmp[0]; $input = $tmp[1] * 13 + $tmp[2]; $card = $flow->run($tab->get_on_table(), $action, $input); if (isset($card['error'])) { fwrite(STDOUT, $card['error'] . ": " . $tmp[2] . " try again."); $flow->move_back(); $i--; continue; } if (!$card) { fwrite(STDOUT, " || " . $players[$flow->now_player()] . ":PASS! "); continue; // 沒牌了 } if ($card > 0) { $tab->add($card); $show_card = $suit[$card]; fwrite(STDOUT, " || " . $players[$flow->now_player()] . "出牌:" . $show_card);