private function setEndVariationValue(Move $move) { if ($this->endingVariation) { $this->endingVariation = false; $move->endVariation(); } }
public function makeMove(Move $move) { if ($this->gameState !== self::GAME_STATE_PLAYING) { throw new InvalidArgumentException('game is already over'); } $row = $move->getRow(); $column = $move->getColumn(); // wait until the user makes a first move to initialize the bomb locations // in order to ensure that the first move doesn't ever land on a mine if (!$this->bombsInitialized) { $points = RandomPointGenerator::generate($this->getLength(), $this->getWidth(), $row, $column, $this->getBombCount()); $this->initBombs($points); } $cell = $this->getCell($row, $column); if (!$cell->isHidden()) { throw new InvalidArgumentException($row . ',' . $column . ' is already showing'); } if ($move->isFlag()) { $cell->toggleFlagged(); return; } if ($cell->isBomb()) { $this->gameState = self::GAME_STATE_LOST; } else { $cell->setHidden(false); $this->hiddenCount--; if ($cell->getSurroundingBombCount() === 0) { $this->revealSurroundingCells($row, $column); } if ($this->isGameWon()) { $this->gameState = self::GAME_STATE_WON; } } }
public function setUp() { parent::setUp(); LudoDBRegistry::set('FILE_UPLOAD_PATH', '/tmp/'); $mv = new MetadataValue(); $mv->drop()->yesImSure(); $m = new Move(); $m->drop()->yesImSure(); $g = new Game(); $g->drop()->yesImSure(); $g->createTable(); $m->createTable(); $mv->createTable(); $db = new Database(1); if (!$db->getId()) { $db->setTitle('My database'); $db->commit(); } }
private function getUsersNextMove($handle) { $length = $this->board->getLength(); $width = $this->board->getWidth(); $exampleRow = floor($length / 2); $exampleColumn = floor($width / 2); $examplePoint = $exampleRow . ',' . $exampleColumn; $prompt = 'Enter move in the format "[row],[column]" e.g. "' . $examplePoint . '". To toggle a flag on a cell, prefix with an "f" e.g. "f' . $examplePoint . '"'; $move = null; do { echo $prompt . ': '; $input = rtrim(fgets($handle)); try { $move = Move::parse($input, $length - 1, $width - 1); } catch (InvalidArgumentException $e) { echo "\nInvalid move. Please try again.\n"; } } while ($move === null); return $move; }
/** * @test */ public function testCommandGeneration() { $cmd = new Move('from', 'to'); $this->assertEquals("mv from to", $cmd->getCommand()); }
/** * Move Folder * * @param folderId - required - * The id of the folder. * @param parentId - required - * The id of the parent where the file should be moved. * @return The Move object which contains the status of the operation. */ public function moveFolder($folderId, $parentId) { $parameters = array('folderId' => $folderId, 'parentId' => $parentId); $urld = 'dpi/v1/folder/' . $folderId . '/move'; $this->response = $this->restTransportInstance->sendRequest($urld, $parameters, self::HTTP_PUT, $this->authToken); $responseBody = simplexml_load_string($this->response); $returnObject = new Move(); if ($responseBody === false) { $errorCode = 'N/A'; $errorMessage = 'The server has encountered an error, please try again.'; $errorObject = new ErrorStatus($errorCode, $errorMessage); $returnObject->setErrorStatus($errorObject); } else { $errorStatus = $responseBody->errorStatus; if (empty($errorStatus)) { $returnObject->setStatus((string) $responseBody->status); } else { $errorCode = (string) $responseBody->errorStatus->code; $errorMessage = (string) $responseBody->errorStatus->message; $errorObject = new ErrorStatus($errorCode, $errorMessage); $returnObject->setErrorStatus($errorObject); } } return $returnObject; }
<?php /** * 转移采购信息到采购商社区 */ $move = new Move(); $move->run(); class Move { public $provinceArr = array(1 => array("title" => "北京", "fid" => 85, "num" => 50), 2 => array("title" => "上海", "fid" => 95, "num" => 0), 3 => array("title" => "天津市", "fid" => 86, "num" => 0), 4 => array("title" => "重庆市", "fid" => 75, "num" => 0), 7 => array("title" => "安徽省", "fid" => 98, "num" => 0), 8 => array("title" => "福建省", "fid" => 104, "num" => 0), 10 => array("title" => "广东省", "fid" => 100, "num" => 0), 11 => array("title" => "贵州省", "fid" => 77, "num" => 0), 12 => array("title" => "河北省", "fid" => 87, "num" => 0), 13 => array("title" => "黑龙江省", "fid" => 94, "num" => 0), 14 => array("title" => "河南省", "fid" => 88, "num" => 0), 15 => array("title" => "湖北省", "fid" => 103, "num" => 0), 16 => array("title" => "湖南省", "fid" => 102, "num" => 0), 17 => array("title" => "吉林省", "fid" => 93, "num" => 0), 18 => array("title" => "江西省", "fid" => 99, "num" => 0), 19 => array("title" => "江苏省", "fid" => 96, "num" => 0), 20 => array("title" => "辽宁省", "fid" => 92, "num" => 0), 21 => array("title" => "山东省", "fid" => 89, "num" => 0), 22 => array("title" => "陕西省", "fid" => 81, "num" => 0), 23 => array("title" => "山西省", "fid" => 90, "num" => 0), 24 => array("title" => "四川省", "fid" => 76, "num" => 0), 25 => array("title" => "云南省", "fid" => 78, "num" => 0), 26 => array("title" => "浙江省", "fid" => 97, "num" => 0), 27 => array("title" => "青海省", "fid" => 83, "num" => 0), 28 => array("title" => "广西壮族自治区", "fid" => 101, "num" => 0), 29 => array("title" => "内蒙古自治区", "fid" => 91, "num" => 0), 30 => array("title" => "宁夏回族自治区", "fid" => 82, "num" => 0), 31 => array("title" => "西藏自治区", "fid" => 79, "num" => 0), 32 => array("title" => "新疆维吾尔自治区", "fid" => 84, "num" => 0), 34 => array("title" => "海南省", "fid" => 105, "num" => 0)); public $op = "gongyepin"; public function __construct() { } public function run() { $op = $this->op . "Action"; $this->{$op}(); } public function gongyepinAction() { $this->num = 1000; $this->online = new Table("online"); $maxInfo = $this->online->findOne("select max(eid) as eid from productoffer.pd_sendenq"); $maxId = $maxInfo['eid']; $maxId = 1923834; $eid = $maxId; while (1) { $buyInfo = $this->online->findAll("select eid,cid, proname, buycount, unit, contact, tel, pubtime,cate1, buytitle, is_public, status, endtime from productoffer.pd_sendenq where eid <= '" . $eid . "' order by eid desc limit 100"); if (empty($buyInfo)) { break;
/** * Append new move to the game * @param $move * @return Array */ public function appendMove($move) { if (!$this->getId()) { $this->commit(); } $move = $this->gameParser()->getParsed($move); $move['game_id'] = $this->getId(); $move['fen_id'] = Fen::getIdByFen($move['fen']); $m = new Move(); $m->setValues($move); $m->commit(); return $move; }