Example #1
0
 /**
  * Deals cards to players based on hand size,
  * will deal entire deck if handSize is 0. Has scope for
  * dealing different sized hands as required
  *
  * @param int $handSize
  */
 protected function deal($handSize = 0)
 {
     Talk::say('Dealing...');
     if ($handSize == 0) {
         // If handSize is 0 then we'll deal all the cards to all players
         $counter = floor($this->deck->undealtCount() / count($this->players));
     } else {
         if ($this->deck->undealtCount() >= count($this->players) * $handSize) {
             // Else if theres enough cards we'll deal the appropriate handSize
             $counter = $handSize;
         } else {
             // But if theres not enough cards we'll exit
             $counter = 0;
         }
     }
     // If we've got players
     if (!empty($this->players)) {
         // And the counter allows it
         while ($counter > 0) {
             // Deal a card to each player
             foreach ($this->players as $player) {
                 $player->takeCard($this->deck->deal());
             }
             // Decrement the counter
             $counter--;
         }
     }
 }
Example #2
0
 public function deal()
 {
     foreach ($this->players as $player) {
         $cards = $this->deck->getSpecifiedNumberOfCards($this->numCardsPerPlayer);
         foreach ($cards as $card) {
             $player->giveCard($card);
         }
     }
 }
Example #3
0
 function toHTML()
 {
     $deck_id = $_GET['deck_id'];
     $deck = new Deck();
     $deck->createFromID($deck_id);
     $slides = $deck->getSlidesFull();
     $slides_to_string = array();
     $image_local_path = array();
     $image_name = array();
     $image_paths = array();
     $slides_to_string = $this->createSlideString($deck_id);
     foreach ($slides as $slide) {
         $img_pattern = '/\\.\\/upload\\/media\\/images\\/\\d+\\/\\d+\\..../';
         preg_match_all($img_pattern, $slide->content, $matches);
         if (count($matches[0])) {
             foreach ($matches[0] as $img_path) {
                 $image_paths[] = $img_path;
             }
         }
     }
     $html = " \n\t\t<!DOCTYPE html>\n\t\t<!--[if lt IE 7]> <html class=\"no-js ie6\" lang=\"en\"> <![endif]-->\n\t\t<!--[if IE 7]>    <html class=\"no-js ie7\" lang=\"en\"> <![endif]-->\n\t\t<!--[if IE 8]>    <html class=\"no-js ie8\" lang=\"en\"> <![endif]-->\n\t\t<!--[if gt IE 8]><!-->  <html class=\"no-js\" lang=\"en\"> <!--<![endif]-->\n\t\t<head>\n\t\t\t<meta charset=\"utf-8\">\n\t\t\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">\n\n\t\t\t<title>" . $deck->title . "</title>\n\n\t\t\t<meta name=\"author\" content=" . $deck->owner->username . ">\n\t\t\t<meta name=\"deck_id\" content=" . $deck->deck_id . ">\n\t\t\t<meta name=\"deck_revision_id\" content=" . $deck->id . ">\n\t\t\t<meta name=\"viewport\" content=\"width=1024, user-scalable=no\">\n\n\t\t\t<!-- Core and extension CSS files -->\n\t\t\t<link rel=\"stylesheet\" href=\"deck.js/core/deck.core.css\">\n\t\t\t<link rel=\"stylesheet\" href=\"deck.js/extensions/goto/deck.goto.css\">\n\t\t\t<link rel=\"stylesheet\" href=\"deck.js/extensions/menu/deck.menu.css\">\n\t\t\t<link rel=\"stylesheet\" href=\"deck.js/extensions/navigation/deck.navigation.css\">\n\t\t\t<link rel=\"stylesheet\" href=\"deck.js/extensions/status/deck.status.css\">\n\t\t\t<link rel=\"stylesheet\" href=\"deck.js/extensions/hash/deck.hash.css\">\n\n\t\t\t<!-- Theme CSS files (menu swaps these out) -->\n\t\t\t<link rel=\"stylesheet\" id=\"style-theme-link\" href=\"default_theme/default.css\">\n\t\t\t<link rel=\"stylesheet\" id=\"transition-theme-link\" href=\"deck.js/themes/transition/horizontal-slide.css\">\n\n\t\t\t<!-- Custom CSS just for this page -->\n\t\t\t<link rel=\"stylesheet\" href=\"deck.js/introduction/introduction.css\">\n\t\t\t<link rel=\"stylesheet\" href=\"local.css\">\n\n\t\t\t<script src=\"deck.js/modernizr.custom.js\"></script>\n\t\t\t<script src=\"deck.js/jquery.js\"></script>\n\n\t\t\t<!-- client syntax highlightning -->\n\t\t\t<link   href=\"deck.js/syntax/shThemeDefault.css\" rel=\"stylesheet\" type=\"text/css\" />\n\t\t\t<script src=\"deck.js/syntax/shCore.js\" type=\"text/javascript\"></script>\n\t\t\t<script src=\"deck.js/syntax/shAutoloader.js\" type=\"text/javascript\"></script>\n\t\t\t<script src=\"deck.js/syntax/shBrushTurtle.js\" type=\"text/javascript\"></script>\n\t\t\t<script type=\"text/javascript\" src=\"deck.js/MathJax.js\"></script>\n\n<script type=\"text/javascript\">\n\t\t\tfunction htmlDecode(input){\n\t\t\t\t  var e = document.createElement(\"div\");\n\t\t\t\t  e.innerHTML = input;\n\t\t\t\t  return e.childNodes.length === 0 ? \"\" : e.childNodes[0].nodeValue;\n\t\t\t}\n\t\t\tfunction removeBRs(input){\n\t\t\t\tvar r=input.replace(/<br>/gi,\"\"); \n\t\t\t\tr=r.replace(/<br[0-9a-zA-Z]+>/gi,\"\");\n\t\t\t\treturn r;\n\t\t\t}\n\t\t\t\tSyntaxHighlighter.defaults['toolbar'] = false;\n\t\t\t\tSyntaxHighlighter.all();\n\t\t\t\t</script>\n\t\t\t<script type=\"text/x-mathjax-config\">\n\t\t\t\$(function() {\n\t\t\t  MathJax.Hub.Config({\n\t\t\t\t\tskipStartupTypeset: true,\n\t\t\t\t\textensions: [\"tex2jax.js\"],\n\t\t\t\t\tjax: [\"input/TeX\", \"output/HTML-CSS\"],\n\t\t\t\t\ttex2jax: {\n\t\t\t\t\tinlineMath: [ ['\$','\$'], [\"\\(\",\"\\)\"] ],\n\t\t\t\t\tdisplayMath: [ ['\$\$','\$\$'], [\"\\[\",\"\\]\"] ],\n\t\t\t\t\tprocessEscapes: true\n\t\t\t\t\t},\n\t\t\t\t\t\"HTML-CSS\": { availableFonts: [\"TeX\"] }\n\t\t\t  });\n\t\t\t\t\$.deck('.slide');\n\t\t\t\tMathJax.Hub.Queue([\"Typeset\",MathJax.Hub,'slide-area']);\n\t\t\t\t});\n\t\t\t\t</script>\t\t\t\n\t\t</head>\t\t\n\t\t\n\t\t<body class=\"deck-container\">\n\n\t\t\t<div class=\"theme-menu\">\n\t\t\t\t<h2>Themes</h2>\n\n\t\t\t\t<label for=\"style-themes\">Style:</label>\n\t\t\t\t<select id=\"style-themes\">\n\t\t\t\t\t<option selected value=\"default_theme/default.css\">Default</option>\n\t\t\t\t\t<option value=\"deck.js/themes/style/web-2.0.css\">Web 2.0</option>\n\t\t\t\t\t<option value=\"deck.js/themes/style/swiss.css\">Swiss</option>\n\t\t\t\t\t<option value=\"deck.js/themes/style/neon.css\">Neon</option>\n\t\t\t\t\t<option value=\"\">None</option>\n\t\t\t\t</select>\n\n\t\t\t\t<label for=\"transition-themes\">Transition:</label>\n\t\t\t\t<select id=\"transition-themes\">\n\t\t\t\t\t<option selected value=\"deck.js/themes/transition/horizontal-slide.css\">Horizontal Slide</option>\n\t\t\t\t\t<option value=\"deck.js/themes/transition/vertical-slide.css\">Vertical Slide</option>\n\t\t\t\t\t<option value=\"deck.js/themes/transition/fade.css\">Fade</option>\n\t\t\t\t\t<option value=\"\">None</option>\n\t\t\t\t</select>\n\t\t\t</div>" . $slides_to_string . "</div>\n\t\t\t</div>\n\t\t</div>\n\t\t\n\t\t<a href=\"#\" class=\"deck-prev-link\" title=\"Previous\">&#8592;</a>\n\t\t<a href=\"#\" class=\"deck-next-link\" title=\"Next\">&#8594;</a>\n\n\t\t<p class=\"deck-status\">\n\t\t\t<span class=\"deck-status-current\"></span>\n\t\t\t/\n\t\t\t<span class=\"deck-status-total\"></span>\n\t\t</p>\n\n\t\t<form action=\".\" method=\"get\" class=\"goto-form\">\n\t\t\t<label for=\"goto-slide\">Go to slide:</label>\n\t\t\t<input type=\"number\" name=\"slidenum\" id=\"goto-slide\">\n\t\t\t<input type=\"submit\" value=\"Go\">\n\t\t</form>\n\n\t\t<a href=\".\" title=\"Permalink to this slide\" class=\"deck-permalink\">#</a>\n\n\n\t\t<!-- Deck Core and extensions -->\n\t\t<script src=\"deck.js/core/deck.core.js\"></script>\n\t\t<script src=\"deck.js/extensions/menu/deck.menu.js\"></script>\n\t\t<script src=\"deck.js/extensions/goto/deck.goto.js\"></script>\n\t\t<script src=\"deck.js/extensions/status/deck.status.js\"></script>\n\t\t<script src=\"deck.js/extensions/navigation/deck.navigation.js\"></script>\n\t\t<script src=\"deck.js/extensions/hash/deck.hash.js\"></script>\n\t\t<!-- Specific to this page -->\n\t\t<script src=\"deck.js/introduction/introduction.js\"></script>\n\t\t<!-- Code Mirror -->\n\t\t<link rel=\"stylesheet\" href=\"codemirror/lib/codemirror.css\">\n\t\t<script src=\"codemirror/lib/codemirror.js\"></script>\n\t\t<script src=\"codemirror/mode/javascript/javascript.js\"></script>\n\t\t<script src=\"codemirror/mode/xml/xml.js\"></script>\n\t\t<script src=\"codemirror/mode/htmlmixed/htmlmixed.js\"></script>\n\t\t<script src=\"codemirror/mode/css/css.js\"></script>\n\t\t<script src=\"codemirror/mode/php/php.js\"></script>\n\t\t<script src=\"codemirror/mode/ntriples/ntriples.js\"></script>\n\t\t<script src=\"codemirror/mode/sparql/sparql.js\"></script>\n\t\t<script src=\"codemirror/lib/util/formatting.js\"></script>\n\t\t<!-- Code Mirror for deck.js -->\n\t\t<link rel=\"stylesheet\" href=\"deck.js/extensions/codemirror/deck.codemirror.css\">\n\t\t<script src=\"deck.js/extensions/codemirror/deck.codemirror.js\"></script>\n\t\t</body>\n\t\t</html>";
     $zipName = "archive.zip";
     $libraries_folder = 'deck.js' . DS;
     $createZipFile = new createDirZip();
     $createZipFile->get_files_from_folder(ROOT . DS . 'libraries' . DS . 'frontend' . DS . 'deck.js' . DS, $libraries_folder);
     $fileToZip = "index.html";
     $createZipFile->addFile($html, $fileToZip);
     $fileContents = file_get_contents(ROOT . DS . "libraries" . DS . "frontend" . DS . "MathJax" . DS . "MathJax.js");
     $fileToZip = $libraries_folder . "MathJax.js";
     $createZipFile->addFile($fileContents, $fileToZip);
     $fileContents = file_get_contents(ROOT . DS . "libraries" . DS . "frontend" . DS . "jquery.js");
     $fileToZip = $libraries_folder . "jquery.js";
     $createZipFile->addFile($fileContents, $fileToZip);
     $fileContents = file_get_contents(ROOT . DS . "libraries" . DS . "frontend" . DS . "jquery.min.js");
     $fileToZip = $libraries_folder . "jquery.min.js";
     $createZipFile->addFile($fileContents, $fileToZip);
     $createZipFile->get_files_from_folder(ROOT . DS . 'libraries' . DS . 'frontend' . DS . 'codemirror' . DS, 'codemirror' . DS);
     // adding images
     foreach ($image_paths as $im) {
         $fileContents = file_get_contents($im);
         $fileToZip = split('\\/', $im);
         $fileToZip = $fileToZip[count($fileToZip) - 1];
         $createZipFile->addFile($fileContents, $fileToZip);
     }
     //add default theme
     $style = new Style();
     $tmp = $style->getStyle($deck->default_theme);
     $createZipFile->addFile($tmp['css'], 'default_theme/default.css');
     $date = date('Y-m-d');
     $zipName = $this->sluggify($deck->title) . '_' . $date . "_" . $zipName;
     $fd = fopen($zipName, "wb");
     $out = fwrite($fd, $createZipFile->getZippedfile());
     fclose($fd);
     $createZipFile->forceDownload($zipName);
     @unlink($zipName);
 }
Example #4
0
 function create($deck_id, $format)
 {
     $deck = new Deck();
     $deck->createFromID($deck_id);
     $this->deck_id = $deck_id;
     $this->deck = $deck;
     $this->title = $deck->title;
     $this->root_deck_name = $this->sluggify($this->title);
     $this->deck_name = $this->sluggify($this->title);
     mkdir(ROOT . DS . 'tmp' . DS . $this->root_deck_name);
     $this->format = $format;
     $this->resources = $this->createResources($this->resources, $deck);
     $this->createManifest();
     //$this->createCourseMetadata();
 }
 public function edit_deck($deck_id = 0, $repeating = 0)
 {
     if ($repeating == 1) {
         $this->data['error'] = "New Deck Added.";
     }
     $deck = new Deck($deck_id);
     if ($_POST) {
         $repeat = FALSE;
         /*
         			if($deck_id == 0){
         				$repeat = TRUE;
         			}*/
         foreach ($this->input->post() as $key => $val) {
             $deck->{$key} = nl2br($val);
         }
         if ($this->input->post('enabled')) {
             $deck->enabled = 1;
         } else {
             $deck->enabled = 0;
         }
         $deck->save();
         if ($repeat) {
             redirect('/admin/cards/edit_deck/');
         }
     }
     $this->data['deck'] = $deck;
     $this->data['current_function_view'] = $this->load->view('admin/cards/edit_deck', $this->data, true);
     $this->load->view('admin/master', $this->data);
 }
Example #6
0
 /**
  * Adds a card to this hand
  *
  * @param Poker\Table\Contracts\Card $card
  */
 public function addCard(Contracts\Card $card)
 {
     if ($this->cardLimit == $this->cardCount()) {
         throw new InvalidHandException("An attempt was made to add a card to a hand which had already hit it\\'s legal limit of cards");
     }
     parent::addCard($card);
 }
Example #7
0
 /**
  * Going to display everyone's hand
  * @throws Exception
  * @return string
  */
 public function play()
 {
     $html = '';
     if (empty($this->players)) {
         throw new Exception('No players!');
     }
     $deck = new Deck();
     foreach ($this->players as $playerName) {
         $player = new Player($playerName);
         for ($i = 0; $i < $this->numCards; $i++) {
             $player->giveCard($deck->getCard());
         }
         $html .= $player->showHand();
         $html .= '<hr/>';
     }
     return $html;
 }
Example #8
0
 function __construct()
 {
     $this->initConnection();
     $tasks = $this->dbquery('SELECT * FROM translation_cronjobs');
     //print_r($tasks);
     foreach ($tasks as $task) {
         $id = $task['revision_id'];
         $language = $task['to_language'];
         $old_deck = new Deck();
         $old_deck->createFromID($id);
         $new_deck = new Deck();
         $new_deck->createFromID($task['future_deck']);
         $new_deck->translation_status = 'translated';
         $new_deck->content = $old_deck->content;
         if ($new_deck->translate_parent($language)) {
             $old_deck->removeFromQueue($id, $language);
         }
     }
 }
 function builder4impress()
 {
     $this->_template->disableHeader();
     $this->_template->disableFooter();
     $deck_id = isset($_GET['deck']) ? $_GET['deck'] : 0;
     $deck = new Deck();
     $slides = array();
     if ($deck_id) {
         $deck->createFromID($deck_id);
         $slides = $deck->getSlides();
         $_SESSION['deck'] = $deck_id;
     }
     $user_id = $this->_user['id'];
     if ($user_id) {
         $_SESSION['user'] = $user_id;
     }
     $this->set('deckObject', $deck);
     $this->set('slides', $slides);
 }
Example #10
0
 public function delete($id)
 {
     $id = (int) $id;
     $this->load->model('Deck');
     $result = Deck::delete($id);
     if ($result === true) {
         redirect('/Deck/view_all');
     } elseif ($result instanceof Standard_error) {
         $this->layout->add_basic_assets()->menu()->view('others/form_failure', array('message' => $result->message));
     }
 }
Example #11
0
 /**
  * Return true once all players have
  * been dealt cards
  * Return $this for possible chaining
  *
  * @return Dealer
  */
 public function dealCards()
 {
     foreach ($this->_players as $player) {
         if ($player->getHasBeenDealt() == false) {
             while ($player->getTotalCards() < 5) {
                 $player->receiveCard($this->_deck->dealCard());
             }
             $player->setHasBeenDealt(true);
         }
     }
     return $this;
 }
Example #12
0
 function create()
 {
     if ($this->_user['id'] == 2 || $this->_user['id'] == 1) {
         $this->set('alert', '1');
     } else {
         $this->set('alert', '0');
     }
     if (isset($_POST['submit'])) {
         $brand = $_POST['brand'];
         $br = new Brand();
         $br->description = $brand['text'];
         $br->image = $brand['image'];
         $br->url = $brand['url'];
         $br->deck_id = $brand['deck'];
         $br->create();
         $deck = new Deck();
         $deck->id = $brand['deck'];
         $deck->title = $deck->getTitle();
         $deck->slug_title = $deck->sluggify($deck->title);
         header('Location: deck/' . $brand['deck'] . '_' . $deck->slug_title);
     } else {
     }
 }
Example #13
0
 function __construct()
 {
     $this->initConnection();
     $decks = $this->dbquery('SELECT * FROM deck WHERE language IS NULL OR language="" OR language="-"');
     echo 'decks:' . count($decks);
     foreach ($decks as $task) {
         $deck = new Deck();
         $deck->deck_id = $task['id'];
         $deck->createFromID($deck->getLastRevisionID());
         $language = $deck->detectLanguage();
         $deck->setLanguageFull($language);
     }
     $slides = $this->dbquery('SELECT * FROM slide WHERE language IS NULL OR language="" OR language="-"');
     echo 'slides:' . count($slides);
     $decks = array();
     foreach ($slides as $task) {
         $slide = new Slide();
         $slide->slide_id = $task['id'];
         $id = $slide->getLastRevisionID();
         $decks_array = $this->dbGetOne('SELECT deck_revision_id FROM deck_content WHERE item_id =:id AND item_type="slide" LIMIT 1', array('id' => $id));
         if ($decks_array) {
             if (!in_array($decks_array, $decks)) {
                 $decks[] = $decks_array;
             }
         }
     }
     echo 'decks:' . count($decks) . '<br>';
     foreach ($decks as $task) {
         echo $task;
         $deck = new Deck();
         $deck->createFromID($task);
         $language = $deck->detectLanguage();
         $deck->setLanguageFull($language);
         echo ' done ';
     }
 }
Example #14
0
 function deck()
 {
     $deck_id = $_GET['id'];
     $deck = new Deck();
     $deck->createFromIDLite($deck_id);
     $deck->last_revision_id = $deck->getLastRevisionID();
     $usage = $deck->getUsage();
     $deck->comments = $deck->getComments();
     $translations = $deck->getTranslatedTo();
     $this->set('deck', $deck);
     $this->set('translations', $translations);
     $this->set('usage', $usage);
     $this->set('page_title', $deck->title . ' - SlideWiki');
     $this->set('page_keywords', join(',', $deck->getTags($deck->id)));
 }
Example #15
0
 public function create()
 {
     $this->load->model('Campaign');
     $this->load->model('Deck');
     $this->form_validation->set_rules('name', 'Name', 'required');
     $this->form_validation->set_rules('id_deck', 'Deck', 'required');
     $this->layout->add_basic_assets()->menu();
     $decks = Deck::find();
     if ($this->form_validation->run() === false) {
         $data = array('action' => $this->router->method, 'name' => '', 'decks' => $decks);
         $create_edit = $this->layout->views('controllers/Campaign/actions/create_edit', $data, array(), true);
         $this->layout->action_view(array('create_edit' => $create_edit));
     } else {
         $result = Campaign::insert($this->input->post('name'), $this->input->post('id_deck'));
         if ($result === true) {
             $this->layout->view('others/form_success');
         } elseif ($result instanceof Standard_error) {
             $this->layout->views('others/form_failure', array('message' => $result->message));
             $data = array('action' => $this->router->method, 'name' => $this->input->post('name'), 'decks' => $decks);
             $create_edit = $this->layout->views('controllers/Campaign/actions/create_edit', $data, array(), true);
             $this->layout->action_view(array('create_edit' => $create_edit));
         }
     }
 }
Example #16
0
 public function testDeck()
 {
     $Deck = new Deck();
     $cards = $Deck->getCards();
     $this->assertEquals(52, count($cards), 'There must be 52 cards in the Deck');
     $spades = [];
     $hearts = [];
     $clubs = [];
     $diamonds = [];
     foreach ($cards as $Card) {
         switch ($Card->getSuit()) {
             case '♣':
                 $clubs[] = $Card;
                 break;
             case '♦':
                 $diamonds[] = $Card;
                 break;
             case '♥':
                 $hearts[] = $Card;
                 break;
             case '♠':
                 $spades[] = $Card;
                 break;
             default:
                 throw new Exception('Invalid Suit Found.');
         }
     }
     $this->assertEquals(13, count($spades), 'There must be 13 spade cards');
     $this->assertEquals(13, count($hearts), 'There must be 13 heart cards');
     $this->assertEquals(13, count($clubs), 'There must be 13 club cards');
     $this->assertEquals(13, count($diamonds), 'There must be 13 diamond cards');
     $Card = $Deck->dealCard();
     $this->assertTrue($Card instanceof Card);
     $cards = $Deck->dealCards(5);
     $this->assertEquals(5, count($cards));
     $cards = $Deck->dealCards(2);
     $this->assertEquals(2, count($cards));
     $stack = $Deck->getStack();
     //We dealt 8 cards, so should only have 44 in the stack
     $this->assertEquals(44, count($stack));
 }
Example #17
0
 public function getLastOuterParent($deck_id)
 {
     $d = new Deck();
     $d->id = $deck_id;
     $usage = $d->getUsage();
     if (is_array($usage) && count($usage) == 1) {
         return $this->getLastOuterParent($usage[0]->id);
     } else {
         return $deck_id;
     }
 }
Example #18
0
 function html($widget, $params, $sidebar)
 {
     global $post, $wpdb;
     $show_mini = false;
     $page_project_id = 0;
     $custom = false;
     // Condition to store the product_id, if the page currently being visited is the project page or some other
     if (isset($post)) {
         if ($post->post_type == 'ignition_product') {
             $post_id = $post->ID;
             $page_project_id = get_post_meta($post_id, 'ign_project_id', true);
             //$page_project_id = projectPageof($post->ID, $params['product_id']);
         }
         // We have three conditions now
         // 1.	Show Mini widget only, on all pages
         // 2.	Show Full widget on all pages
         // 3.	Show Mini widget on all pages except the project page
         if (isset($params['widget_options'])) {
             if ($params['widget_options'] == "miniwidget") {
                 $show_mini = true;
             } else {
                 if ($params['widget_options'] == "fullwidget") {
                     $show_mini = false;
                 } else {
                     if ($params['widget_options'] == "miniallpages" && $page_project_id > 0) {
                         //2nd condition means it is a project page, containing some non-zero project_id
                         $show_mini = false;
                     } else {
                         $show_mini = true;
                     }
                 }
             }
         } else {
             $show_mini = true;
         }
         if (isset($params['deck_id']) && $params['deck_id'] > 0) {
             $deck_id = $params['deck_id'];
             $settings = Deck::get_deck_attrs($deck_id);
             if (!empty($settings)) {
                 $attrs = unserialize($settings->attributes);
                 $custom = true;
             }
         }
     }
     // If it's a project page, use the post_id to get the product, else use the product_id in $params
     if ($page_project_id > 0) {
         $project_id = $page_project_id;
     } else {
         $project_id = $params['product_id'];
     }
     $deck = new Deck($project_id);
     if ($show_mini == true) {
         $mini_deck = $deck->mini_deck();
         $post_id = $mini_deck->post_id;
     } else {
         $the_deck = $deck->the_deck();
         $post_id = $deck->post_id;
     }
     $custom = apply_filters('idcf_custom_deck', $custom, $post_id);
     $attrs = apply_filters('idcf_deck_attrs', isset($attrs) ? $attrs : null, $post_id);
     $widget_before = '';
     $widget_after = '';
     $mini_widget_before = '';
     $mini_widget_after = '';
     // Calling the HTML code
     ob_start();
     require ID_PATH . 'languages/text_variables.php';
     include ID_PATH . 'templates/_igWidget.php';
     $widget = ob_get_contents();
     ob_end_clean();
     if ($show_mini) {
         echo apply_filters('id_mini_widget', $widget);
     } else {
         echo apply_filters('id_widget', $widget);
     }
 }
Example #19
0
 function reportDeckChanges()
 {
     //$this->_template->disableHeader();
     //$this->_template->disableFooter();
     $this->_noRender = true;
     $id = $_GET['deck'];
     $deck = new Deck();
     $deck->createFromIDLite($id);
     // revision id
     $deck2 = new Deck();
     $deck2->id = $deck->getPreviousRevisionID();
     if ($deck2->id != NULL) {
         $deck2->createFromIDLite($deck2->id);
         $deck->content = $deck->fetchDeckContentLite();
         $deck2->content = $deck2->fetchDeckContentLite();
         $deck_count = count($deck->content);
         $deck2_count = count($deck2->content);
         //var_dump($deck->content);
         //var_dump($deck2->content);
         if ($deck_count > $deck2_count) {
             echo $deck_count - $deck2_count . " slide(s) added to the deck.";
         } elseif ($deck_count < $deck2_count) {
             echo $deck2_count - $deck_count . " slide(s) removed from the deck.";
         } else {
             $flag = 0;
             $changes = array();
             foreach ($deck->content as $index => $val) {
                 if ($val->id != $deck2->content[$index]->id) {
                     $flag++;
                     array_push($changes, array($index, $deck2->content[$index]->id, $val->id));
                 }
             }
             if ($flag) {
                 echo "Content of the following " . $flag . " slide(s) has been modified:<br>";
                 echo "<ol>";
                 foreach ($changes as $v) {
                     echo "<li>";
                     echo "<a href='slide/" . $v[1] . "' target='_blank'>Slide</a> at position <b>" . ($v[0] + 1) . "</b> <a href='slide/" . $v[2] . "' target='_blank'>changed</a> (<small><a style='color:#888855;' target='_blank' href='?url=compare/reportSlideChanges&slide=" . $v[2] . "&compareTo=" . $v[1] . "'>details</a></small>).";
                     echo "</li>";
                 }
                 echo "</ol>";
             } else {
                 echo "Just a copy of the previous revision!";
             }
         }
     }
 }
Example #20
0
<?php

if (isset($_POST['choice'])) {
    //do stuff pour envoi post
    header("Location: index.php");
    exit;
}
//stuff pour tout le monde
require 'card.php';
//SCENARIO 1
if (empty($_SESSION['game_state'])) {
    $_SESSION['game_state'] = new GameState();
    $deck = new Deck();
    $deck->shuffle();
    $bank = new Bank();
    $player = new Player($hand[]);
} else {
    $deck = $_SESSION['game_state']->{$deck};
    $bank = $_SESSION['game_state']->{$bank};
    $player = $_SESSION['game_state']->{$player};
}
$bank->take($deck->deal(2));
$player->take($deck->deal(2));
//tire 2 cartes du deck, la banque les prends
while ($player->getHandValue() < 21) {
    // || jusqu'à ce que le joueur arrête de tirer
    $player->take($deck->deal(1));
}
if ($player->getHandValue() > 21) {
    echo "Le joueur perd " . $player->getHandValue();
    echo "La banque gagne";
Example #21
0
 public function getModules($limit, $mode)
 {
     $questions_old = array();
     if (count($this->questions)) {
         $questions_old = $this->questions;
     }
     static $id_array = array();
     static $modules_id = array();
     //add question_id to a list to check duplicates
     if (count($questions_old)) {
         foreach ($questions_old as $question) {
             $id_array[] = $question->id;
         }
     }
     //get subdecks
     $children = array();
     $deck = new Deck();
     $deck->id = $this->item_id;
     $children = $deck->getChildrenForTest();
     if (count($children)) {
         foreach ($children as $deck) {
             $new_item_id = $deck->id;
             if (!in_array($deck->deck_id, $modules_id)) {
                 $questions = array();
                 $modules_id[] = $deck->deck_id;
                 $test = new Test();
                 $test->item_id = $new_item_id;
                 $checkQuestions = $test->getDirectQuestions();
                 //do not add duplicates
                 if (count($checkQuestions)) {
                     foreach ($checkQuestions as $question) {
                         if (!in_array($question->id, $id_array)) {
                             $test->questions[] = $question;
                         }
                     }
                 }
                 //if there are questions create a module and add it to the test
                 $test->title = $test->getTitle();
                 $test->type = 'auto';
                 $test->quest_count = count($test->questions);
                 if ($test->quest_count) {
                     $questions = $test->testMode($mode, $limit, $test->questions);
                 }
                 $test->questions = $questions;
                 $test->quest_count = count($test->questions);
                 $test->getModules($limit, $mode);
                 $this->modules[] = $test;
             }
         }
     }
 }
Example #22
0
} else {
    $version = $_GET['version'];
}
$db->autocommit(FALSE);
if ($version < 2) {
    echo "Updating to version 2... <br />";
    # Version 2 Changes:
    #  - Add 'mtgo_confirmed', 'mtgo_challenge' field to players, and initialize them
    do_query("ALTER TABLE players ADD COLUMN (mtgo_confirmed tinyint(1), mtgo_challenge varchar(5))");
    do_query("UPDATE players SET mtgo_confirmed = 0");
    do_query("UPDATE players SET mtgo_challenge = NULL");
    #  - Add 'deck_hash', 'sideboard_hash' and 'whole_hash' to decks, and initialize them
    do_query("ALTER TABLE decks ADD COLUMN (deck_hash varchar(40), sideboard_hash varchar(40), whole_hash varchar(40))");
    $deckquery = do_query("SELECT id FROM decks");
    while ($deckid = $deckquery->fetch_array()) {
        $deck = new Deck($deckid[0]);
        $deck->calculateHashes();
        echo "-> Calculating deck hash for {$deck->id}... <br />";
        flush();
    }
    #  - Add 'notes' to entries and copy the current notes in the decks
    do_query("ALTER TABLE entries ADD COLUMN (notes text)");
    do_query("UPDATE entries e, decks d SET e.notes = d.notes WHERE e.deck = d.id");
    #  - and of course, set the version number to 2.
    do_query("UPDATE db_version SET version = 2");
    $db->commit();
    echo ".. DB now at version 2! <br />";
}
if ($version < 3) {
    echo "Updating to version 3... <br />";
    # Version 3 Changes:
Example #23
0
<?php

global $post;
$id = $post->ID;
$content = the_project_content($id);
$project_id = get_post_meta($id, 'ign_project_id', true);
if (class_exists('Deck')) {
    $deck = new Deck($project_id);
    $the_deck = $deck->the_deck();
    $levels = $the_deck->level_data;
    //$levels = the_levels($id);
    $type = get_post_meta($id, 'ign_project_type', true);
    $end_type = get_post_meta($id, 'ign_end_type', true);
    $project = new ID_Project($project_id);
    $days_left = $project->days_left();
}
?>
<aside id="sidebar">
  <?php 
get_template_part('project', 'author');
?>
  <!-- check for closed projects -->
   <h3 class="widget-title levels"><?php 
_e('REWARDS', 'fivehundred');
?>
</h3>
  <div class="project-sidebar-wrapper">
  <div id="ign-product-levels" data-projectid="<?php 
echo $project_id;
?>
">
function id_projectGrid($attrs)
{
    ob_start();
    if (isset($attrs['columns'])) {
        $wide = $attrs['columns'];
    } else {
        $wide = 3;
    }
    $width = 90 / $wide;
    $margin = 10 / ($wide - 1);
    if (isset($attrs['max'])) {
        $max = $attrs['max'];
    } else {
        $max = null;
    }
    // project category
    if (isset($attrs['category'])) {
        $category = $attrs['category'];
        $args = array('post_type' => 'ignition_product', 'tax_query' => array(array('taxonomy' => 'project_category', 'field' => 'id', 'terms' => $category)));
    } else {
        // in case category isn't defined, query args must contain post type
        $args['post_type'] = 'ignition_product';
    }
    if (isset($max)) {
        $args['posts_per_page'] = $max;
    }
    // --> Custom args - START
    // orderby possible values - days_left, percent_raised, funds_raised, rand, title, date (default)
    if (isset($attrs['orderby'])) {
        if ($attrs['orderby'] == 'days_left') {
            $args['orderby'] = 'meta_value_num';
            $args['meta_key'] = 'ign_days_left';
        } else {
            if ($attrs['orderby'] == 'percent_raised') {
                $args['orderby'] = 'meta_value_num';
                $args['meta_key'] = 'ign_percent_raised';
            } else {
                if ($attrs['orderby'] == 'funds_raised') {
                    $args['orderby'] = 'meta_value_num';
                    $args['meta_key'] = 'ign_fund_raised';
                } else {
                    // reserved for later use
                    $args['orderby'] = $attrs['orderby'];
                }
            }
        }
    }
    // order possible values = ASC, DESC (default)
    if (isset($attrs['order'])) {
        $args['order'] = $attrs['order'];
    }
    // author (single name)
    if (isset($attrs['author'])) {
        $args['author_name'] = $attrs['author'];
    }
    // --> Custom args - END
    // moved this block before the query call
    require 'languages/text_variables.php';
    $custom = false;
    if (isset($attrs['deck'])) {
        $deck_id = $attrs['deck'];
        $settings = Deck::get_deck_attrs($deck_id);
        if (!empty($settings)) {
            $attrs = unserialize($settings->attributes);
            $custom = true;
        }
    }
    // start the actual query, which will also output decks
    $posts = get_posts($args);
    $project_ids = array();
    echo '<div class="ignitiondeck"><div class="grid_wrap" data-wide="' . $wide . '">';
    $i = 1;
    foreach ($posts as $post) {
        $post_id = $post->ID;
        $project_id = get_post_meta($post_id, 'ign_project_id', true);
        // no more "pass" checks are required, because the query gets all proper projects in proper order and settings
        $deck = new Deck($project_id);
        $mini_deck = $deck->mini_deck();
        $post_id = $deck->get_project_postid();
        $status = get_post_status($post_id);
        $custom = apply_filters('idcf_custom_deck', $custom, $post_id);
        $attrs = apply_filters('idcf_deck_attrs', isset($attrs) ? $attrs : null, $post_id);
        if (strtoupper($status) == 'PUBLISH') {
            $settings = getSettings();
            echo '<div class="grid_item" style="float: left; margin: 0 ' . $margin . '% ' . $margin . '% 0; width: ' . $width . '%;">';
            include 'templates/_miniWidget.php';
            echo '</div>';
            $i++;
        }
    }
    // end with query and continue with original code
    echo '</div></div>';
    echo '<br style="clear: both"/>';
    $grid = ob_get_contents();
    ob_end_clean();
    return $grid;
}
Example #25
0
function deck_builder()
{
    require 'languages/text_variables.php';
    if (isset($_POST['deck_submit'])) {
        $attrs = array();
        foreach ($_POST as $k => $v) {
            if ($k !== 'deck_submit' && $k !== 'deck_select') {
                if ($k == 'deck_title') {
                    $attrs[$k] = esc_attr($v);
                } else {
                    $attrs[$k] = absint($v);
                }
            }
        }
        if ($_POST['deck_select'] > 0) {
            // update saved deck
            $deck_id = absint($_POST['deck_select']);
            Deck::update_deck($attrs, $deck_id);
        } else {
            // new deck, insert
            $new = Deck::create_deck($attrs);
        }
    } else {
        if (isset($_POST['deck_delete'])) {
            $deck_id = absint($_POST['deck_select']);
            Deck::delete_deck($deck_id);
        }
    }
    echo '<div class="wrap">';
    echo admin_menu_html();
    include 'templates/admin/_deckBuilder.php';
    echo '</div>';
}
            print "<li>The {$exp_key} of the card object is <font color='red'>incorrect</font> as {$exp_val} ";
            print_r($exp_val);
            print ".</li>";
            $badtests++;
        }
    }
}
print "</ul>";
//print_r($newcard);
//echo '<br /><br />';
$uidtotest = 4321;
$testcard_id = '01-17-7';
$testcard = new Card($testcard_id);
print "<h3>Testing the Deck Class with user id {$uidtotest}.</h3>";
require_once 'deck.php';
$newdeck = new Deck($uidtotest);
$expectedvals = array("userid" => 4321, "acard" => $testcard);
print "<ul>";
if ($newdeck->getUserID() == $expectedvals["userid"]) {
    print "<li>The user id of the deck object is <font color='green'>correct</font> as ";
    print_r($newdeck->getUserID());
    print "</li>";
    $goodtests++;
} else {
    print "<li>The user id of the deck object is <font color='red'>incorrect</font> as ";
    print_r($newdeck->getUserID());
    print "</li>";
    $badtests++;
}
if ($newdeck->hasCard($testcard->getStat("id"))) {
    print "<li>The deck <font color='green'>has</font> the expected card in it: ";
Example #27
0
        }
    }
    public function getHandValue()
    {
        $panier = 0;
        foreach ($this->hand as $card) {
            $panier += $card->getValue();
        }
        return $panier;
    }
}
class Bank extends Player
{
    public function __construct()
    {
        parent::__construct("Banque");
    }
}
//SCENARIO 1
$deck = new Deck();
$deck->shuffle();
$bank = new Bank();
$bank->take($deck->deal(2));
while ($bank->getHandValue() < 16) {
    $bank->take($deck->deal(1));
}
if ($bank->getHandValue() > 21) {
    echo "La banque perd " . $bank->getHandValue();
} else {
    echo "La banque a " . $bank->getHandValue();
}
Example #28
0
 public function getSubscribedDecks($page)
 {
     $extent = $this->feed_page_size;
     $offset = $page * $extent;
     $res = array();
     foreach ($this->dbQuery('SELECT * FROM subscription WHERE item_type="deck" AND user_id=' . $this->id . ' LIMIT ' . $offset . ',' . $extent) as $row) {
         $deck = new Deck();
         $deck->deck_id = $row['item_id'];
         $last = $deck->getLastRevisionID();
         $deck->createFromID($last);
         $res[] = $deck;
     }
     return $res;
 }
Example #29
0
<title></title>
<link rel="stylesheet" media="screen" type="text/css" href="poker.css" />
</head>

<body>
<?php 
/**
*
*@author bibby <*****@*****.**>
$Id$
** //*/
require_once 'Poker.class.php';
$quota = 4;
while ($quota--) {
    //**
    $D = new Deck();
    $Hand = new Hand();
    foreach (range(1, 7) as $i) {
        $Hand->add($D->draw());
    }
    //*/
    /**
    	$Hand = new Hand();
    	$Hand->add( new Card(2,1) );
    	$Hand->add( new Card(3,1) );
    	$Hand->add( new Card(4,1) );
    	$Hand->add( new Card(5,1) );
    	$Hand->add( new Card(6,1) );
    	$Hand->add( new Card(7,2) );
    	$Hand->add( new Card(8,1) );
    	//*/
Example #30
0
 /**
  * Shuffle the deck and give each player a set number of cards
  * @return void
  */
 public function deals()
 {
     // Shuffle the deck
     $this->deck->shuffle();
     // Iterate through the array of players
     foreach ($this->players as $player) {
         //  Give each player the set number of cards
         for ($i = 0; $i < $this->numCards; $i++) {
             $player->receiveCard($this->deck->getCard());
         }
     }
 }