当前位置: 首页>>代码示例>>PHP>>正文


PHP Card::get方法代码示例

本文整理汇总了PHP中Card::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Card::get方法的具体用法?PHP Card::get怎么用?PHP Card::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Card的用法示例。


在下文中一共展示了Card::get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 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;
                     }
                 }
             }
         }
     }
 }
开发者ID:OlivierLamiraux,项目名称:mtgas,代码行数:60,代码来源:deck.php

示例2: get_content

 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();
 }
开发者ID:OlivierLamiraux,项目名称:mtgas,代码行数:9,代码来源:ws_booster.php

示例3: get_cards

 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));
         }
     }
 }
开发者ID:OlivierLamiraux,项目名称:mtgas,代码行数:19,代码来源:extension.php

示例4: recieve

 protected function recieve($user, $data)
 {
     switch ($data->type) {
         case 'recieve':
             $user->game->recieveAction($data->id);
             break;
         case 'mojosto':
             switch ($user->player_id) {
                 case $user->game->creator_id:
                     $zone = 'game.creator.battlefield';
                     break;
                 case $user->game->joiner_id:
                     $zone = 'game.joiner.battlefield';
                     break;
                 default:
                     die('Player not creator nor joiner');
             }
             $param = json_decode($data->param);
             $target = isset($param->target) ? $param->target : null;
             $cards = mojosto($param->avatar, $param->cc);
             if (count($cards) == 0) {
                 $user->sendString('{"type": "msg", "sender": "", "param": {"text": "' . $param->avatar . ' can\'t cast anything with cc=' . $param->cc . '"}}');
             } else {
                 foreach ($cards as $card) {
                     $card->zone = $zone;
                     if ($param->avatar == 'stonehewer' && $target != null) {
                         $card->target = $target;
                     }
                     $action = $user->game->addAction($user->player_id, 'mojosto', json_encode($card));
                     $this->broadcast(json_encode($action), $user->game);
                 }
             }
             break;
         case 'focus':
         case 'blur':
             $user->focused = $data->type == 'focus';
             $data->sender = $user->player_id;
             $this->broadcast(json_encode($data), $user->game, $user);
             break;
         case 'land':
             $param = json_decode($data->param);
             $land = Card::get($param->name);
             if ($user->game->isCreator($user->player_id)) {
                 $zone = 'game.creator.library';
             } else {
                 if ($user->game->isJoiner($user->player_id)) {
                     $zone = 'game.joiner.library';
                 } else {
                     $this->observer->say('Land : nor creator nor joiner');
                     return false;
                 }
             }
             $land->zone = $zone;
             $action = $user->game->addAction($user->player_id, 'card', json_encode($land));
             $this->broadcast(json_encode($action), $user->game);
             break;
         default:
             $action = $user->game->addAction($user->player_id, $data->type, $data->param, $data->local_index);
             if ($action == null) {
                 $user->sendString('{"type": "msg", "sender": "", "param": {"text": "You can\'t send ' . $data->type . '"}}');
             } else {
                 // Send back to sender if containing a callback ID
                 if (isset($data->callback)) {
                     $action->callback = $data->callback;
                 }
                 $this->broadcast(json_encode($action), $user->game, isset($action->callback) ? null : $user);
             }
     }
 }
开发者ID:OlivierLamiraux,项目名称:mtgas,代码行数:69,代码来源:ws_game_handler.php

示例5: add

 public function add($name, $nb)
 {
     for ($i = 0; $i < $nb; $i++) {
         $card = Card::get($name);
         if ($card != null) {
             $this->deck_obj->main[] = $card;
         }
     }
     $this->summarize();
 }
开发者ID:OlivierLamiraux,项目名称:mtgas,代码行数:10,代码来源:ws_registration.php


注:本文中的Card::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。