public function checkTemposCard(Card $card) { $tcard = $this->getTemposCard(); if (!is_null($tcard)) { return $tcard->getId() == $card->getId(); } }
public function testCard() { $Card = new Card(0, '♦'); $cardstring = $Card->getCardEvalString(); $this->assertEquals('Ad', $cardstring); $value = $Card->getValue(); $isRoyal = $Card->isRoyal(); $label = $Card->getCardPrintLabel(); $this->assertEquals(14, $value); $this->assertTrue(!$isRoyal); $this->assertEquals('A♦', $label); $Card = new Card(10, '♣'); $label = $Card->getCardPrintLabel(); $isRoyal = $Card->isRoyal(); $cardstring = $Card->getCardEvalString(); $this->assertEquals('Jc', $cardstring); $this->assertTrue($isRoyal); $this->assertEquals('J♣', $label); $Card = new Card(9, '♥'); $label = $Card->getCardPrintLabel(); $isRoyal = $Card->isRoyal(); $cardstring = $Card->getCardEvalString(); $this->assertEquals('Th', $cardstring); $this->assertTrue(!$isRoyal); $this->assertEquals('10♥', $label); $Card = new Card(8, '♠'); $label = $Card->getCardPrintLabel(); $isRoyal = $Card->isRoyal(); $cardstring = $Card->getCardEvalString(); $this->assertEquals('9s', $cardstring); $this->assertTrue(!$isRoyal); $this->assertEquals('9♠', $label); }
public function delete_card($card_id = 0) { $card = new Card($card_id); $deck_id = $card->deck_id; $card->delete(); /* $ref = $_SERVER['HTTP_REFERER']; redirect($ref); */ redirect('/admin/cards/list_cards/' . $deck_id); }
/** * Add a card to the deck * If the card already exists, increase the count * * @param Card $card * * @return self */ public function addCard(Card $card) { $hash = $card->getHash(); if (array_key_exists($hash, $this->cards)) { $this->cards[$hash]['count']++; } else { $this->cards[$hash] = ['count' => 1, 'details' => $card]; } $this->sortCards(); return $this; }
public function addCard() { try { $db = new DB(); $card = new Card($_POST["name"], $_POST["description"], $_GET["list"]); $sql = "INSERT INTO card(name,description,list_id) VALUES (:name,:description,:list_id)"; $q = $db->getConnection()->prepare($sql); $q->execute(array(':name' => $card->getName(), ':description' => $card->getDescription(), ':list_id' => $card->getListId())); } catch (PDOException $e) { echo $e->getMessage(); } }
private function carte_et_scoreOracle() { include './sys/load_iso.php'; require_once './controllers/update_score_coeff.php'; if (!isset($_SESSION["timeOutOracle"])) { // récupération d'enregistrementID pour récupérer l'id de l'Oracle et l'id de la carte //connexion à la BD $db = db::getInstance(); //Récupération de enregistrementID $sql = 'SELECT enregistrementID FROM parties WHERE idDevin="' . $this->diviner . '" ORDER BY tpsDevin DESC LIMIT 1 '; $res1 = $db->query($sql); $this->res2 = mysqli_fetch_assoc($res1); // récupération de l'id de l'oracle et de la carte grâce à enregistrementID $sql = 'SELECT idOracle,carteID,OracleLang FROM enregistrement WHERE enregistrementID=' . $this->res2['enregistrementID'] . ''; $res1 = $db->query($sql); $res3 = mysqli_fetch_assoc($res1); $this->oracle = $res3['idOracle']; // récupération du contenu de la carte avec carteID $carte = new Card($res3['carteID']); $this->res = $carte->dirtify(); // Requête de modification des scores de l'Oracle qui a fait une description non trouvée par le devin updateScoreOracleDevinEchec($this->oracle, $iso[$res3["OracleLang"]], $this->res2['enregistrementID']); //~ //récupération du score précédent; //~ $sql = 'SELECT `scoreGlobal`,`scoreOracle` FROM `score` WHERE `userid`="'.$this->oracle.'" AND langue="'.$iso[$res3["OracleLang"]].'"'; //~ $result=$db->query($sql); //~ $res5= mysqli_fetch_assoc($result); //~ $this->previousSGO= $res5['scoreGlobal']; //~ $this->previousSO= $res5['scoreOracle']; //~ //~ //maj des variables de scores: le score ne doit jamais être négatif. //~ $points = $this->points*0.5; //~ $_SESSION["pointsCoef"] = $points; //~ //~ if($this->previousSO >= $points) //~ { //~ $this->previousSGO = $this->previousSGO - $points; //~ $this->previousSO = $this->previousSO - $points; //~ } //~ //maj du score dans la BD //~ $sql = 'UPDATE score //~ SET scoreGlobal='.$db->escape((string) $this->previousSGO) . ', ' . //~ 'scoreOracle='.$db->escape((string) $this->previousSO) . ' //~ WHERE userid='.$this->oracle.' AND langue="'.$iso[$res3["OracleLang"]].'"'; //~ //~ $db->query($sql); $_SESSION["timeOutOracle"] = true; return false; } else { header('Location: index.php?page.home.html'); return false; } }
public function generate() { $serial = new Serial(); $serial->serial = $this->serial; $serial->duration = $this->duration; $serial->save(); for ($number = 1; $number <= $this->quantity; $number++) { $card = new Card(); $card->serial_id = $serial->id; $card->number = $number; $card->save(); } }
public function updateCard(Card $card) { $inputs = ['color' => Input::get('color'), 'content' => Input::get('content'), 'comment' => Input::get('comment'), 'worker_id' => Input::get('worker_id')]; $valid = Validator::make($inputs, Card::$rules); if ($valid->passes()) { $card->color = $inputs['color']; $card->content = $inputs['content']; $card->comment = $inputs['comment']; $card->worker_id = $inputs['worker_id']; $card->save(); return Redirect::route('card.list')->with('success', Lang::choice('messages.Cards', 1) . ' ' . trans('is updated')); } else { return Redirect::back()->withErrors($valid)->withInput(); } }
public function run() { DB::table('sides')->delete(); DB::table('cards')->delete(); $cid = Card::create(array())['id']; echo $cid; Side::create(array('card_id' => $cid, 'descriptor' => 'front', 'text' => 'front')); Side::create(array('card_id' => $cid, 'descriptor' => 'back', 'text' => 'back')); /* Card::create(array('front' => 'hello', 'back' => 'back of card', 'count' => 10)); Card::create(array('front' => 'hello', 'back' => 'konnichiha', 'count' => 10)); */ /* for ($i=0; $i<1000; $i++) { Card::create(array('front' => 'hello', 'back' => 'konnichiha', 'count' => 10)); } */ /* */ }
public function __tostring() { if (null === self::$__tostring || !is_callable(self::$__tostring)) { self::$__tostring = create_function('$c', 'return \'<img src="/images/\'.$c->suit.\'_\'.$c->short.\'.gif" />\';'); } return call_user_func(self::$__tostring, $this); }
public function __construct($deck = null) { if (is_string($deck)) { $reg_comment = '/^\\s*\\/\\/(.*)/'; $reg_empty = "/^\\s*\n\$/"; $reg_side = '/^SB:(.*)$/'; $reg_card_mwd = '/(\\d+)\\s*\\[(.*)\\]\\s*(.+)$/'; $reg_card_apr = '/(\\d+)\\s*(.+)$/'; $lines = explode("\n", $deck); // Cut file content in lines $notfound = 0; foreach ($lines as $value) { // Parse lines one by one // Not a card line if (preg_match($reg_comment, $value, $matches)) { // Comment line continue; } if (preg_match($reg_empty, $value, $matches)) { // Empty line continue; } // Sideboard if ($side = preg_match($reg_side, $value, $matches)) { $value = $matches[1]; } // Search $card = null; if (preg_match($reg_card_mwd, $value, $matches)) { // MWS list($line, $nb, $ext, $name) = $matches; $card = Card::get(trim($name), $ext); } else { if (preg_match($reg_card_apr, $value, $matches)) { // Aprentice list($line, $nb, $name) = $matches; $card = Card::get(trim($name)); } } // (not) Found if ($card == null) { if (++$notfound > 3) { echo "Too many cards not found, deck parsing canceled\n"; return false; } } else { if ($notfound > 0) { $notfound--; } for ($i = 0; $i < $nb; $i++) { if ($side) { $this->side[] = $card; } else { $this->main[] = $card; } } } } } }
public function __construct() { foreach (Card::getSuits() as $suit) { foreach (Card::getValues() as $value) { $this->cards[] = new Card($suit, $value); } } }
public function community_cards($game = NULL) { if (is_a($game, 'Game')) { return $game->render_community_cards(); } else { return Card::render_card_space() . Card::render_card_space() . Card::render_card_space() . Card::render_card_space() . Card::render_card_space(); } }
public function setCardsAttribute($cards) { if (count($cards) > 0) { foreach ($cards as $card) { Card::create((array) $card); } } }
public function get_content($content) { global $db_cards; $this->fullcontent = array(); foreach ($content as $card) { $this->fullcontent[] = Card::get($card->name, $card->ext, property_exists($card, 'nb') ? $card->nb : 0); } $this->summarize(); }
public function render () { global $config; echo $this->card . '...'; $card = $this->card; $settings = $this->getSettings(); $costColors = Card::getCostColors($card->cost); $white = '255,255,255'; $canvas = imagecreatetruecolor(1050, 736); // Art image. $this->drawArt($canvas, $card->artFileName, $settings['art.top'], $settings['art.left'], $settings['art.bottom'], $settings['art.right'], !$config['art.keep.aspect.ratio']); echo '.'; // Background image. $bgImage = @imagecreatefrompng('images/plane/plane.png'); imagecopy($canvas, $bgImage, 0, 0, 0, 0, 1050, 736); echo '.'; // Set and rarity. $rarityLeft = $this->drawRarity($canvas, $card->rarity, $card->set, $settings['rarity.right'], $settings['rarity.center.y'], $settings['rarity.height'], $settings['rarity.width'], false); // Card title. $this->drawText($canvas, $settings['title.x'], $settings['title.y'], null, $card->getDisplayTitle(), $this->font('title')); echo '.'; // Type. $this->drawText($canvas, $settings['type.x'], $settings['type.y'], null, $card->type, $this->font('type')); //Chaos Symbol $this->drawSymbol($canvas, 632, 115, 50, 'C', null); // Legal text. if (!preg_match('/(.*\n)(.*?)$/s', $card->legal, $matches)) error('Missing chaos ability from legal text: ' . $card->title); $this->drawLegalAndFlavorText($canvas, $settings['text.top'], $settings['text.left'], $settings['text.bottom'], $settings['text.right'], $matches[1], null, $this->font('text'), 0); $this->drawLegalAndFlavorText($canvas, $settings['chaos.top'], $settings['chaos.left'], $settings['chaos.bottom'], $settings['chaos.right'], $matches[2], null, $this->font('text'), 0); // Artist and copyright. // The artist color is white if the frame behind it is black. $footerColor = '255,255,255'; if ($card->artist) { if ($settings['card.artist.gears']) { $artistSymbol = '{gear}'; } else { $artistSymbol = '{brush}'; } $this->drawText($canvas, $settings['artist.x'], $settings['artist.y'], null, $artistSymbol . $card->artist, $this->font('artist', 'color:' . $footerColor)); } if ($card->copyright) $this->drawText($canvas, $settings['copyright.x'], $settings['copyright.y'], null, $card->copyright, $this->font('copyright', 'color:' . $footerColor)); echo "\n"; return $canvas; }
function __construct() { parent::__construct(); foreach (Card::get_ranks() as $rank) { foreach (Card::get_suits() as $suit) { $this->add(new Card($rank, $suit)); } } }
private function GetEntries() { require_once "Records/card.php"; require_once "Records/entry.php"; $s = Card::GetAllCardsQuery() ->join(array("e" => Entry::$TABLE), "e.card = ca.id", array()) ->where("e.cube = ?", $this->id); $r = DB::zdb()->fetchAll($s); $this->cards = array(); foreach ( $r as $rr ) $this->cards[] = new Card($rr); }
public function __construct($card) { parent::__construct($card); $this->keys = array_keys($this->data); foreach( $this->keys as $key ) { if ( array_key_exists( $key, $_GET ) ) { $this->Mutate( $key, $_GET[$key] ); $this->data[$key] = $_GET[$key]; } } }
public function render_cards($game_id, $face_down = false) { if ($face_down) { $count = $this->cards[$game_id]->count(); if ($count == 2) { return Card::render_card_back() . Card::render_card_back(); } elseif ($count == 1) { return Card::render_card_back() . Card::render_card_space(); } else { return Card::render_card_space() . Card::render_card_space(); } } else { return $this->cards[$game_id]->render(2); } }
public function actionCreate() { $model = new ConsumerLog(); $model->unsetAttributes(); if ($_POST['ConsumerLog']) { $model->attributes = $_POST['ConsumerLog']; if ($model->validate()) { $model->setAttribute('fee', $model->price / $model->total); if ($model->save() && Card::model()->updateByPk($model->card_id, ['used_num' => $model->used + 1])) { Yii::app()->user->setFlash('ConsumerLog', '提交成功'); } } } $stores = Store::model()->getName(); $this->render('create', ['model' => $model, 'stores' => $stores]); }
public function cardInfo($params = array()) { extract($params); if (isset($type_id)) { $num = isset($num) && $num > 0 ? $num : 1; $result = Card::model()->getCards($type_id, $num); if ($result) { $ret = $this->notice('OK', 0, '成功', $result); } else { $ret = $this->notice('OK', 0, '成功', []); } } else { $ret = $this->notice('ERR', 301, '缺少参数', []); } return $ret; }
public function newcardAction() { $em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'); $card = new Card(); $card->setDateadd(); $card->setDateup(); $card->setActive(); $card->setGameId(); $card->setUserId(1); $em->persist($card); $em->flush(); $this->layout('layout/empty'); echo "OK"; }
/** * Convert to an array suitable for use as Twitter Card structured properties * * @since 1.0.0 * * @return array { * @type string Twitter card property * @type mixed property value * } */ public function toArray() { $card = parent::toArray(); $image_properties = $this->imageCardProperties(); if (!empty($image_properties)) { $card['image'] = $image_properties; } unset($image_properties); if (isset($this->creator) && $this->creator) { $creator = $this->creator->asCardProperties(); if ($creator) { $card['creator'] = $creator; } unset($creator); } return $card; }
public function __construct($card) { if ( !is_array($card) ) { $s = Card::GetAllCardsQuery() ->where("ca.id = ?", $card); $card = DB::zdb()->fetchRow($s); } $this->data = $card; $this->id = $card["id"]; $this->name = $card["name"]; $this->cardFrame = $card["frame_url"]; $this->text = $card["text"]; unset($this->data["id"]); }
public static function get_all($sort_query = ' ORDER BY serial, number') { $db = new DB(); $query = 'SELECT c.card_id, s.name serial, c.number, c.release_date, c.end_date, c.status, ( SELECT COUNT( bill_number ) FROM bills WHERE card_id = c.card_id ) AS purchases FROM cards c NATURAL JOIN cards_series s WHERE s.serial_id <> ' . ADMCARDSERIAL . ' ' . $sort_query; $data = $db->query_all($query, 'Card') or die($sort_query); foreach ($data as $obj) { if ((string) $obj->end_date < ($current_date = (string) date('Y-m-d H:i:s'))) { $obj->status = 2; Card::deactivate($obj->card_id, 2); } } return $data; }
private function get_cards() { // Import card list from DB and dispatch by rarity/transformability if (count($this->cards) > 0) { return false; } if ($this->get_data('all', false)) { $this->cards = Card::$cache; $this->cards_rarity['C'] = $this->cards; //$cards = $db_cards->select("SELECT `card`.`name` FROM `card` ORDER BY `card`.`id` ASC") ; } else { echo 'Cache not fill'; global $db_cards; $cards = $db_cards->select("SELECT `card`.`name`\n\t\t\tFROM `card_ext`, `card`\n\t\t\tWHERE\n\t\t\t\t`card_ext`.`card` = `card`.`id` AND\n\t\t\t\t`card_ext`.`ext` = {$this->id}\n\t\t\tORDER BY `card`.`id` ASC"); foreach ($cards as $card) { $this->add_card(Card::get($card->name, $this->se)); } } }
private function loadWonders() { $wonders = json_decode(file_get_contents("cards/wonders.json"), true); foreach ($wonders as &$wonder) { foreach ($wonder as $side => &$value) { if ($side == 'name') { continue; } if (isset($value['resource'])) { $value['resource'] = Card::csvResources($value['resource'], true)[0]; } foreach ($value['stages'] as &$stage) { if (isset($stage['resource'])) { $stage['resource'] = Card::csvResources($stage['resource'], false)[0]; } $stage['requirements'] = Card::csvResources($stage['requirements'], false); } } } return $wonders; }
public function render($count = 0) { if ($count) { $return = ''; for ($i = 0; $i < $count; $i++) { if (array_key_exists($i, $this->cards)) { if (is_a($this->cards[$i], 'Card')) { $return .= $this->cards[$i]->render(); } else { $return .= Card::render_card_space(); } } else { $return .= Card::render_card_space(); } } } else { foreach ($this->cards as $card) { $return .= $card->render(); } } return $return; }
public function checkCard($attribute, $params) { if ($this->flag < 2) { if ($this->flag_content) { $obj = Card::model()->find(array('condition' => 'card_num=:num and is_sale =:sale', 'params' => array(':num' => $this->flag_content, ':sale' => '1'))); if ($obj) { if (strtotime($obj->start_time) > time()) { $this->addError($attribute, '使用时间未开始'); return false; } if (strtotime($obj->end_time) < time()) { $this->addError($attribute, '有效时间已过'); return false; } if ($obj->total_num > $obj->used_num) { //ok $this->total = $obj->total_num; $this->used = $obj->used_num; $this->price = $obj->price; $this->card_id = $obj->card_id; return true; } else { $this->addError($attribute, '次数已用完'); } } else { $this->addError($attribute, '卡号不存在'); } } else { $this->addError($attribute, '卡号不能为空'); } } else { if ($this->flag == 2) { return true; } else { $this->addError($attribute, '卡号不存在'); } } }