public function awardPoints() { if (Game::findGame()->round > 0) { if (!isset($_SESSION["single"]) || $_SESSION["single"] != true) { $this->fillMissingAnswers(); } usort($this->allAnswers, array("Answer", "sortMiles")); $totalPoints = count($this->allAnswers); foreach ($this->allAnswers as $key => $answer) { $answer->updateAnswer($totalPoints--); } Game::updateRound(-1 * $_SESSION["questionNumber"]); } }
public static function createGame($replay, $game_idSet = null) { global $conn; $game_id = rand(10000, 99999); if ($game_idSet != null) { $game_id = 1111; } if ($replay == "yes") { $lastGame_ID = $_SESSION["game_id"]; } date_default_timezone_set('America/New_York'); //die (date("z")); $_SESSION["game_id"] = $game_id . str_pad(date("z"), 3, "0", STR_PAD_LEFT); //if ($single==true) if ($game_idSet != null) { $_SESSION["game_id"] = $game_id = 1111; } // $_SESSION["game_id"]*=00;//, $single=false //$_SESSION["game_id"] =$_GET['game_id']; //$_SESSION["user_id"] =rand (0,111111111); $sql = "INSERT INTO `games` (`game_id`) VALUES ('{$_SESSION['game_id']}')"; //echo $sql; $result = $conn->query($sql); $_SESSION["questionNumber"] = 0; Game::updateRound(-1); if ($replay == "yes") { //SOCKET SENDING MESSAGE $entryData = array('category' => "Game" . $lastGame_ID . "NextGame", 'title' => substr($_SESSION["game_id"], 0, 5)); $context = new ZMQContext(); $socket = $context->getSocket(ZMQ::SOCKET_PUSH, 'my pusher'); $socket->connect("tcp://127.0.0.1:5555"); $socket->send(json_encode($entryData)); $entryData = array('category' => "Game" . $lastGame_ID . "Status", 'title' => substr($_SESSION["game_id"], 0, 5), 'type' => "NextGame"); $socket->send(json_encode($entryData)); } }
function __construct($type) { if ($type != null) { $_SESSION["questionNumber"]++; $this->type = $type; if ($type == "geo") { $this->getLocation($type); } else { if ($type == "weather") { $this->getWeather(); } else { if ($type == "entertainment") { $this->getEntertainment(); } else { if ($type == "pt") { $this->getPPT("pt"); } else { if ($type == "places") { $this->getPPT("places"); } else { if ($type == "sports") { $this->getQuestion($type); } else { if ($type == "science") { $this->getQuestion($type); } else { if ($type == "time") { $this->getTime(); } else { if ($type == "facts") { $this->getFacts(); } else { //if ($type=="rand") $this->getQuestion($type); } } } } } } } } } //if ($type=="user") // $this->getUserQuestion(); $this->addAnswer(); //echo "in here again"; Game::updateRound($_SESSION["questionNumber"], $this->type); if ($this->type == "time") { if ($this->answer < -200) { $region = 0; } else { if ($this->answer < 600) { $region = 1; } else { if ($this->answer < 1200) { $region = 2; } else { if ($this->answer < 1600) { $region = 3; } else { $region = 4; } } } } $this->alertUsers($_SESSION["questionNumber"], "WorldTime" . $region); } else { if ($this->type == "facts" && $this->max == -100) { $this->alertUsers($_SESSION["questionNumber"], "factsPercent"); } else { if ($this->type == "facts" && $this->max == 100) { $this->alertUsers($_SESSION["questionNumber"], "facts"); } else { if ($this->type == "facts" && $this->max < 100) { $this->alertUsers($_SESSION["questionNumber"], "factsMax"); } else { if ($this->type == "facts" && $this->max > 0) { $this->alertUsers($_SESSION["questionNumber"], "factsRand"); } else { $this->alertUsers($_SESSION["questionNumber"], $this->type); } } } } } } }