/** * The index handler. * * @access public * @return string The HTML code. */ public function index() { $Contact = new Contact(); $Dealer = new Dealer(); $this->getView()->set('Contacts', $Contact->findList(array(), 'Position asc')); $this->getView()->set('Dealers', $Dealer->findList(array(), 'Position asc')); return $this->getView()->render(); }
/** * @param Dealer $dealer * @return SolutionHand|null */ public function getWinningHand(Dealer $dealer) { $winningHand = null; $allCards = array_merge($this->getCards(), $dealer->getCards()); $allCardCombos = $this->getCombinations($allCards, 5); foreach ($allCardCombos as $cardCombo) { $solutionHand = new SolutionHand($cardCombo); if (!$winningHand || $solutionHand->diff($winningHand) > 0) { $winningHand = $solutionHand; } } return $winningHand; }
public function editDealer() { $dealer = Dealer::find(Input::get('id')); $previous_status = $dealer->paid; $clicks = Input::get('clicks', '0'); if (is_numeric($clicks)) { $dealer->monthly_clicks = $clicks; } else { $dealer->monthly_clicks = 0; } $paid = Input::get('paid', 'free'); if ($paid === 'paid') { $dealer->paid = 1; $dealer->active = 1; } else { $dealer->paid = 0; $dealer->active = 0; } if ($previous_status != $dealer->paid) { if ($dealer->paid == 1) { $dealer->paid_clicks = 0; } DB::table('vehicle')->where('dealer', $dealer->id)->update(array('modified' => 1, 'paid' => $dealer->active)); } $dealer->save(); return Redirect::route('get.admin.dealers'); }
public static function getOrganName() { $organName = Yii::app()->user->getState('organName'); if ($organName) { return $organName; } //先获取角色身份(生产商/经销商/修理厂) $organName = ""; // $userid = Yii::app()->user->id; $userid = Commonmodel::getOrganID(); $model = self::getIdentity($userid); if ($model['identity'] == 1) { $organ = MakeOrgan::model()->find('userID=:userid', array(':userid' => $userid)); $organName = $organ['name']; } else { if ($model['identity'] == 2) { $organ = Dealer::model()->find('userID=:userid', array(':userid' => $userid)); $organName = $organ['organName']; } else { if ($model['identity'] == 3) { $organ = Service::model()->find('userId=:userid', array(':userid' => $userid)); $organName = $organ['serviceName']; } } } Yii::app()->user->setState('organName', $organName); return $organName; }
public function getName($source) { $value = ''; if (array_key_exists('dealer', $source)) { $values = Dealer::where('id', '=', $source['dealer']); if ($values->count()) { $value = $values->first()->dealer; } } return $value; }
/** * 登记入库 */ public function Add($modelName, $return) { $user_id = Commonmodel::getOrganID(); if ($_POST[$modelName]) { $post = $_POST[$modelName]; if ($modelName == 'MakeEmpowerDealer') { $make = MakeEmpowerDealer::model()->findByPk($post['id']); if (empty($make)) { $telephone = $_POST['telephone']; $dealer = Dealer::model()->find("Phone='{$telephone}'"); if (empty($dealer)) { Yii::app()->db->createCommand()->insert('tbl_user', array('username' => $telephone, 'password' => md5($telephone), 'email' => $telephone . '@jiaparts.com', 'status' => '1', 'create_at' => date('Y-m-d H-i-s', time()), 'identity' => '2')); $newuserID = Yii::app()->db->getLastInsertID(); Yii::app()->db->createCommand()->insert('tbl_profiles', array('user_id' => $newuserID)); Yii::app()->db->createCommand()->insert('tbl_dealer', array('userID' => $newuserID, 'organName' => $post['organName'], 'jiapartsId' => $telephone, 'loginPassword' => md5($telephone), 'Phone' => $telephone)); $post['dealer_id'] = Yii::app()->db->getLastInsertID(); } else { $post['dealer_id'] = $dealer->id; } $make = new MakeEmpowerDealer(); } $post['up_userID'] = $user_id; } elseif ($modelName == 'MakeContacts') { $make = MakeContacts::model()->findByPk($post['id']); if (empty($make)) { $make = new MakeContacts(); } $post['up_userID'] = $user_id; } elseif ($modelName == 'MakeDistributionBusiness') { $make = MakeDistributionBusiness::model()->findByPk($post['id']); if (empty($make)) { $make = new MakeDistributionBusiness(); } $post['up_userID'] = $user_id; } elseif ($modelName == 'MakeStorageService') { $make = MakeStorageService::model()->findByPk($post['id']); if (empty($make)) { $make = new MakeStorageService(); } $post['up_userID'] = $user_id; } elseif ($modelName == 'MakeTechniqueService') { $make = MakeTechniqueService::model()->findByPk($post['id']); if (empty($make)) { $make = new MakeTechniqueService(); } $post['up_userID'] = $user_id; $post['serviceTime'] = $_POST['beginWeek'] . '至' . $_POST['endWeek'] . ' ' . $_POST['beginHour'] . '-' . $_POST['endHour']; } $make->attributes = $post; $make->save(); $this->redirect(array($return)); } }
public function authenticate() { $username = strtolower($this->username); $user = Dealer::model()->find('LOWER(username)=?', array($username)); if ($user === null) { $this->errorCode = self::ERROR_USERNAME_INVALID; } else { if (!$user->validatePassword($this->password)) { $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { $this->_id = $user->id; $this->username = $user->username; $this->errorCode = self::ERROR_NONE; } } return $this->errorCode == self::ERROR_NONE; }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new User(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); $dealer = Dealer::model()->find('id=:id', array(':id' => Yii::app()->user->id)); // var_dump($dealer->id); // return; $currentUsers = User::model()->count('dealer_id=:dealer', array('dealer' => Yii::app()->user->id)); if ($currentUsers >= $dealer->user_limit) { throw new CHttpException(401); } if (isset($_POST['User'])) { $model->attributes = $_POST['User']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function index() { $vin = Input::get('vin', ''); $vehicle = Vehicle::where('vin', '=', $vin)->first(); $dealer = Dealer::where('id', '=', $vehicle->dealer)->first(); $click = new Click(); $click->vin = $vehicle->vin; $click->dealer = $dealer->dealer; $click->state = $vehicle->state; $click->datetime = date("Y-m-d H:i:s"); $click->ip = $_SERVER['REMOTE_ADDR']; $click->paid = $vehicle->paid; $click->save(); $dealer->current_clicks = $dealer->current_clicks + 1; if ($vehicle->paid > 0) { $dealer->paid_clicks = $dealer->paid_clicks + 1; } if ($dealer->active == 1 && $dealer->monthly_clicks <= $dealer->paid_clicks) { $dealer->active = 0; DB::table('vehicle')->where('dealer', $dealer->id)->update(array('paid' => 0, 'modified' => 1)); } $dealer->save(); return Redirect::to($vehicle->url); }
<?php //include the files include_once 'models/Card.php'; include_once 'models/Dealer.php'; include_once 'models/Deck.php'; include_once 'models/Hand.php'; include_once 'models/Player.php'; //get the player names from the form $player_names = $_POST['players']; //Create a new Dealer $dealer = new Dealer(); //iterate through the player names foreach ($player_names as $num => $player_name) { $dealer->registerPlayer(new Player($player_name)); } //tell the dealer to deal the cards to the players $dealer->dealCards(); //ask the dealer the rankings of the players $player_ranking = $dealer->determineWinnerRanking(); //variable for getting remaining cards $cardcount = 52; ?> <!DOCTYPE html> <html> <head> <title>Poker Demo</title> <link rel="stylesheet" href="css/reset.css" type="text/css" /> <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" /> <script src="js/jquery.min.js"></script>
private static function getOrganName($ogranID) { $organName = Dealer::model()->find("userID = {$ogranID}"); $organInfo = array(); $organInfo['QQ'] = $organName['QQ']; $organInfo['organName'] = $organName['organName']; $organInfo['Phone'] = $organName['Phone']; $organInfo['ContactPhone'] = $organName['ContactPhone']; return $organInfo; }
/** * 修改机构信息 */ private function updateOrgan($mobphone, $qq, $email) { $userID = Yii::app()->user->id; $usertype = User::model()->find('id=' . $userID); // 获取会员的类型 if ($usertype['identity'] == 1) { // 生产商 $bool = MakeOrgan::model()->updateByPk($userID, array('mobile_phone' => $mobphone, 'qq' => $qq)); } elseif ($usertype['identity'] == 2) { // 经销商 $bool = Dealer::model()->updateAll(array('Phone' => $mobphone, 'QQ' => $qq), 'userID=:userID', array(':userID' => $userID)); } elseif ($usertype['identity'] == 3) { // 修理厂 $bool = Service::model()->updateByPk($userID, array('serviceCellPhone' => $mobphone, 'serviceQQ' => $qq)); } else { //用户不存在 $bool = false; } return $bool; }
public function actionDealerinfo() { if ($_GET['userID']) { $arr = Dealer::model()->find('userID=' . $_GET['userID']); echo json_encode($arr->attributes); } }
<?php require 'Card.php'; require 'Deck.php'; require 'Dealer.php'; require 'Person.php'; $dealer = new Dealer(3); $dealer->addPlayer('Bob')->addPlayer('Cindy')->addPlayer('Maxx'); $dealer->deal(); $dealer->render();
/** * 检查授权经销商登记使用的手机号是否存在 */ public function actionCheckorgan() { $telephone = $_GET['telephone']; $organName = $_GET['organName']; $user_id = Commonmodel::getOrganID(); $model = Dealer::model()->findAll("Phone='{$telephone}' and organName!='{$organName}'"); if (!empty($model)) { $result = 1; } else { $model2 = Dealer::model()->findAll("Phone!='{$telephone}' and organName='{$organName}'"); if (!empty($model2)) { $result = 2; } else { $model1 = MakeEmpowerDealer::model()->findAll("organName='{$organName}' and up_userID = {$user_id}"); if (!empty($model1)) { $result = 3; } else { $dealer = Dealer::model()->find("Phone='{$telephone}' and organName='{$organName}'"); $model3 = MakeEmpowerDealer::model()->findAll("dealer_id='{$dealer->id}' and up_userID = {$user_id}"); if (!empty($model3)) { $result = 4; } else { $result = 100; } } } } echo json_encode($result); }
public function actionSharecontact() { $organID = Commonmodel::getOrganID(); $dealer = Dealer::model()->find('userID=:userid', array(':userid' => $organID)); $share = BusinessShare::model()->findAll('InitiatorID=:intorID and Status=2', array(':intorID' => $organID)); foreach ($share as $key => $value) { $shareID .= ',' . $value['ShareID']; } $shareID = ltrim($shareID, ","); //查出shareID $sql = "select a.id,a.contact_user_id,a.customertype,\n\t\t a.cooperationtype,a.name,a.sex,\n\t\t a.companyname,a.phone,a.province,a.city,a.area,a.email,\n\t\t a.weixin,a.QQ,a.create_time,a.Status,a.jiapart_ID,a.update_time,\n\t\t (select b.category from tbl_customer_category b where a.customercategory=b.id and a.user_id={$organID}) as customercategory\n\t\t from tbl_business_contacts a where \n\t\t user_id='{$organID}' and Status=0 and a.contact_user_id in({$shareID})"; if ($_POST) { $search['name'] = $_POST['name']; $search['phone'] = $_POST['phone']; $search['keyword'] = $_POST['keyword']; if ($search) { if ($search['name']) { $sql .= " and name like'%{$search['name']}%'"; } if ($search['phone']) { $sql .= " and phone like '%{$search['phone']}%'"; } if ($search['keyword']) { $sql .= " and (companyname like '%{$search['keyword']}%') "; } } } $sql .= "order by create_time desc"; $criteria = new CDbCriteria(); $models = Yii::app()->db->createCommand($sql)->queryAll(); $count = count($models); $pages = new CPagination($count); $pages->pageSize = intval($_GET['rows']); $pages->applylimit($criteria); $models = Yii::app()->db->createCommand($sql . " LIMIT :offset,:limit"); $models->bindValue(':offset', $pages->currentPage * $pages->pageSize); $models->bindValue(':limit', $pages->pageSize); $models = $models->queryAll(); foreach ($models as $key => $value) { $data[$key]['id'] = $value['id']; $data[$key]['Initiator'] = F::msubstr($dealer['organName']); $data[$key]['companyID'] = $value['contact_user_id']; //$data[$key]['customertype'] = $value['customertype']; $data[$key]['cooperationtype'] = $value['cooperationtype']; $data[$key]['customercategory'] = $value['customercategory']; $data[$key]['name'] = $value['name']; $data[$key]['sex'] = $value['sex']; $data[$key]['companyname2'] = F::msubstr($value['companyname']); $data[$key]['companyname'] = $value['companyname']; $data[$key]['phone'] = $value['phone']; $data[$key]['province'] = $value['province']; $data[$key]['city'] = $value['city']; $data[$key]['area'] = $value['area']; $data[$key]['address'] = F::msubstr(Area::getCity($value['province']) . Area::getCity($value['city']) . Area::getCity($value['area'])); $data[$key]['email'] = $value['email']; $data[$key]['weixin'] = $value['weixin']; $data[$key]['QQ'] = $value['QQ']; $data[$key]['create_time'] = $value['create_time']; $data[$key]['Status'] = $value['Status']; $data[$key]['jiapart_ID'] = $value['jiapart_ID']; $data[$key]['update_time'] = $value['update_time']; //$data[$key]['checked']=true; } $rs = array('total' => $count, 'rows' => !empty($data) ? $data : array()); echo json_encode($rs); }
<?php use React\EventLoop\Factory; use React\EventLoop\LoopInterface; use Rx\Scheduler\EventLoopScheduler; use Rxnet\Event\Event; use Rxnet\Zmq\RxZmq; use Rxnet\Zmq\SocketWrapper; require __DIR__ . "/../../vendor/autoload.php"; $loop = Factory::create(); $zmq = new RxZmq($loop); $scheduler = new EventLoopScheduler($loop); $id = isset($argv[1]) ? (int) $argv[1] : '0'; $dealer = new Dealer($loop, $zmq, $scheduler); $dealer->handle($id); $loop->run(); class Dealer { protected $ip = "tcp://127.0.0.1:23001"; protected $id = 0; /** @var LoopInterface */ protected $loop; /** @var SocketWrapper */ protected $dealer; /** @var EventLoopScheduler */ protected $scheduler; public function __construct(LoopInterface $loop, RxZmq $zmq, EventLoopScheduler $scheduler) { $this->loop = $loop; $this->dealer = $zmq->dealer(); $this->scheduler = $scheduler;
/** * 公司信息保存 */ public function actionSavedealerorgan() { $OrganID = Yii::app()->user->getOrganID(); $Organ = Yii::app()->request->getParam("Organ"); $arr = Yii::app()->request->getParam("telPhone"); $TelPhone = ""; foreach ($arr as $key => $val) { if (empty($val)) { continue; } $TelPhone .= $val . ","; } $model = Organ::model()->findByPK($OrganID); if (empty($model)) { $model = new Organ(); } //保存organ数据 $model->attributes = $Organ; $model->TelPhone = trim($TelPhone, ','); //判断基本信息是否为空,为空则不提交 if ($Organ) { //接收删除图片的地址 $photoId = Yii::app()->request->getParam("photoId"); //判断是否删除图片 if (!empty($photoId)) { $imageids = explode(',', $photoId); foreach ($imageids as $imageid) { $picture = OrganPhoto::model()->find('Path=:img AND OrganID=:OrganID', array(':img' => $imageid, ':OrganID' => $OrganID)); //判断该图片路径是否存在数据库中 if (empty($picture)) { $ftp = new Ftp(); $res = $ftp->delete_file($imageid); $ftp->close(); } else { OrganPhoto::model()->deleteAll('Path=:img AND OrganID=:OrganID', array(':img' => $imageid, ':OrganID' => $OrganID)); $ftp = new Ftp(); $res = $ftp->delete_file($picture->Path); $ftp->close(); } } } //接收上传图片地址 $goodsImages = Yii::app()->request->getParam("goodsImages"); //判断是否有上传图片 if (!empty($goodsImages)) { $imglegth = count($goodsImages); for ($i = 0; $i < $imglegth; $i++) { $goodsImg = new OrganPhoto(); $goodsImg->OrganID = $OrganID; $goodsImg->Path = $goodsImages[$i]; $goodsImg->save(); } } //判断是否上传营业执照 $BLPoto = Yii::app()->request->getParam("BLPoto"); if ($model->BLPoto != $BLPoto) { if (!empty($model->BLPoto)) { $ftp = new Ftp(); $res = $ftp->delete_file($model->BLPoto); $ftp->close(); } $model->BLPoto = $BLPoto; } //接收dealer数据 $dealer = Yii::app()->request->getParam("Dealer"); //保存dealer数据 $dealermodel = Dealer::model()->find("OrganID=:organid", array(":organid" => $OrganID)); if (empty($dealermodel)) { //判断是否第一次添加 $dealermodel = new Dealer(); $dealermodel->OrganID = $OrganID; } $dealermodel->SaleMoney = $dealer['SaleMoney']; $dealermodel->SaleDomain = $dealer['SaleDomain']; $dealermodel->ShopArea = $dealer['ShopArea']; if ($dealermodel->save() && $model->save()) { //保存成功 $this->redirect(array('index')); } else { var_dump($dealermodel->errors); var_dump($model->errors); die; } } }
public function savedealerdata() { $OrganID = Yii::app()->user->getOrganID(); //接收dealer数据 $dealer = Yii::app()->request->getParam("Dealer"); //保存dealer数据 $dealermodel = Dealer::model()->find("OrganID=:organid", array(":organid" => $OrganID)); if (empty($dealermodel)) { //判断是否第一次添加 $dealermodel = new Dealer(); $dealermodel->OrganID = $OrganID; } $dealermodel->SaleMoney = $dealer['SaleMoney']; $dealermodel->SaleDomain = $dealer['SaleDomain']; $dealermodel->ShopArea = $dealer['ShopArea']; if (!$dealermodel->save()) { //var_dump($dealermodel->errors);die; throw new CHttpException(400, '保存机构信息失败!'); } }
public function fillHands(Dealer $dealer) { $dealer->deal(...$this->hands); }
/** * Exports the object as an array. * * You can specify the key type of the array by passing one of the class * type constants. * * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. * Defaults to TableMap::TYPE_PHPNAME. * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. * * @return array an associative array containing the field names (as keys) and field values */ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) { if (isset($alreadyDumpedObjects['DealerTeam'][$this->getPrimaryKey()])) { return '*RECURSION*'; } $alreadyDumpedObjects['DealerTeam'][$this->getPrimaryKey()] = true; $keys = DealerTeamTableMap::getFieldNames($keyType); $result = array($keys[0] => $this->getId(), $keys[1] => $this->getDealerId(), $keys[2] => $this->getTeamId(), $keys[3] => $this->getCreatedAt(), $keys[4] => $this->getUpdatedAt(), $keys[5] => $this->getVersion(), $keys[6] => $this->getVersionCreatedAt(), $keys[7] => $this->getVersionCreatedBy()); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } if ($includeForeignObjects) { if (null !== $this->aDealer) { $result['Dealer'] = $this->aDealer->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } if (null !== $this->aTeam) { $result['Team'] = $this->aTeam->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } if (null !== $this->collDealerTeamVersions) { $result['DealerTeamVersions'] = $this->collDealerTeamVersions->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } } return $result; }
$deck = new Deck(); } catch (Exception $e) { echo 'An error occurred: ' . $e->getMessage(); } // Instantiate all players $jared = new Player("Jared"); $samir = new Player("Samir"); $alex = new Player("Alex"); $traci = new Player("Traci"); $brian = new Player("Brian"); $simon = new Player("Simon"); $jerry = new Player("Jerry"); // Put all players into an array $allPlayers = array($jared, $samir, $alex, $traci, $brian, $simon, $jerry); // Instantiate the dealer with the array of players, the number of cards to deal them, and the deck of cards $dealer = new Dealer($allPlayers, 3, $deck); // Make sure no additional decks are needed echo $dealer->setupGame(); // Format game echo "<div class='table'>"; // Show the deck face down echo "<div class='headline'><b>The Deck</b></div>"; echo $dealer->showDeck(); echo "<div class='divider'></div>"; // Deal the cards to all players $dealer->deals(); // Show the players' hands echo "<div class='headline'>Player's Hands</div>"; foreach ($allPlayers as $player) { echo $player->showHand(); }
/** * 验证机构名称 手机号码 邮箱是否重复 */ public function actionCheckorgan() { $model = Yii::app()->db->createCommand()->select("OrganID as organID")->from("tbl_user")->where("id=:userid", array(":userid" => Yii::app()->user->id))->queryRow(); if (empty($model['organID'])) { $organID = 0; } else { $organID = $model['organID']; } $name = $_GET['name']; if (!empty($name)) { $model = Dealer::model()->findAll("userID!=:organID and organName=:name", array(":organID" => $organID, ":name" => $name)); if (!empty($model)) { $message = "机构名称已存在,不可重复"; } else { $phone = $_GET['phone']; if (!empty($phone)) { $model = Dealer::model()->findAll("userID!=:organID and Phone=:phone", array(":organID" => $organID, ":phone" => $phone)); if (!empty($model)) { $message = "手机号码已被使用"; } else { $email = $_GET['email']; if (!empty($email)) { $model = Dealer::model()->findAll("userID!=:organID and Email=:email", array(":organID" => $organID, ":email" => $email)); if (!empty($model)) { $message = "邮箱已被使用"; } } } } } } if (empty($message)) { $result = TRUE; } else { $result = FALSE; } $resu['result'] = $result; $resu['message'] = $message; echo json_encode($resu); }
public function actionMainbusupdate() { $this->pageTitle = Yii::app()->name . '-' . "主营登记"; $userID = Commonmodel::getOrganID(); $model = Dealer::model()->findByAttributes(array('userID' => $userID)); // 显示车系 $showvehicle = DealerVehicle::model()->findAll('userid=:userid', array(':userid' => $userID)); // 显示主营品类 $showcpname = DealerCpname::model()->findAll('OrganID=:userID', array(':userID' => $userID)); //$sqlveh = "select * from jpd_dealer_vehicle where userid = $userID"; //$showvehicle = DBUtil::queryAll($sqlveh); //ajax校验 $this->render('mainbusiness_update', array('model' => $model, 'showvehicles' => $showvehicle, 'showcpnames' => $showcpname)); }
public function actionDetail() { $model = Dealer::model()->find("userID=:userID", array(":userID" => $_GET['dealer'])); // 机构照片 $organphotoSql = "select id, photoName from tbl_dealer_organphoto where dealerID = " . $_GET['dealer']; $organphotos = DBUtil::queryAll($organphotoSql); $brands = DealerBrand::model()->findAll("OrganID = {$_GET['dealer']}"); $data = array(); foreach ($brands as $key => $brand) { $data[$key]['brandname'] = $brand['BrandName']; } //主营车系 $dealerv = DealerVehicle::model()->findAll("userID=:userID", array(":userID" => $_GET['dealer'])); //主营品类 $cpnames = DealerCpname::model()->findAll("OrganID=:userID", array(":userID" => $_GET['dealer'])); $this->render("detail", array('model' => $model, 'organphotos' => $organphotos, 'dealerv' => $dealerv, 'cpnames' => $cpnames, 'data' => $data)); }
public function hit(Dealer $f_objPlayer, $f_bForced = false) { if (21 <= $f_objPlayer->score()) { return false; } $objNextCard = $this->deck->next(); if (!$objNextCard) { // out of cards, bad value for blackjack::cut_card $this->gameover = true; $this->player->stands = true; $this->dealer->stands = true; $this->winner = $this->player; $this->player->payout = 2 * $this->player->bet; $this->player->balance += $this->player->payout; return false; } $f_objPlayer->receive($objNextCard); if (21 <= $f_objPlayer->score() && !$f_bForced) { if ($this->player === $f_objPlayer) { $this->dealerPlays(); } } return true; }
* Карты на руках * @var array */ public $cards = []; /** * Позиция за столом * @var int 1-9 */ public $position; /** * ссылка на текущего дилера * @var Dealer */ public $dealer; function __construct($id, $dealer) { $this->id = $id; $this->dealer = $dealer; echo 'Игрок с id' . $id . ' создан.<br>'; } function decision() { } } $Dealer = new Dealer(); echo '<br>'; $Dealer->addPlayer(); $Dealer->addPlayer(); $Dealer->addPlayer(); $Dealer->startGame(); echo '<br>Количество игроков: ' . count($Dealer->players) . '<br><br>';
public static function getRecommendByPhone($recommend) { $model = Dealer::model()->find("Phone=:phone", array(":phone" => $recommend))->attributes['userID']; if (empty($model)) { unset($model); $model = Service::model()->find("serviceCellPhone=:cellphone", array(":cellphone" => $recommend))->attributes['userId']; } return $model; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Dealer::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }