Beispiel #1
0
 public static function getQuestsForGame($pack)
 {
     $pack->auth->permission = "read_write";
     if (!users::authenticateUser($pack->auth)) {
         return new return_package(6, NULL, "Failed Authentication");
     }
     $sql_quests = dbconnection::queryArray("SELECT * FROM quests WHERE game_id = '{$pack->game_id}' ORDER BY sort_index");
     $quests = array();
     for ($i = 0; $i < count($sql_quests); $i++) {
         if ($ob = quests::questObjectFromSQL($sql_quests[$i])) {
             $quests[] = $ob;
         }
     }
     return new return_package(0, $quests);
 }
Beispiel #2
0
 public static function getQuestsForPlayer($pack)
 {
     $pack->auth->permission = "read_write";
     if (!users::authenticateUser($pack->auth)) {
         return new return_package(6, NULL, "Failed Authentication");
     }
     $gameQuests = quests::getQuestsForGame($pack)->data;
     $playerQuests = new stdClass();
     $playerQuests->active = array();
     $playerQuests->complete = array();
     for ($i = 0; $i < count($gameQuests); $i++) {
         $gameQuests[$i]->user_id = $pack->auth->user_id;
         $gameQuests[$i]->requirement_root_package_id = $gameQuests[$i]->active_requirement_root_package_id;
         if (!requirements::evaluateRequirementPackage($gameQuests[$i])) {
             continue;
         }
         //ensure quest is active/visible
         $gameQuests[$i]->requirement_root_package_id = $gameQuests[$i]->complete_requirement_root_package_id;
         if (requirements::evaluateRequirementPackage($gameQuests[$i])) {
             $playerQuests->complete[] = $gameQuests[$i];
         } else {
             $playerQuests->active[] = $gameQuests[$i];
         }
         unset($gameQuests[$i]->requirement_root_package_id);
         //get rid of redundant attrib
     }
     return new return_package(0, $playerQuests);
 }