コード例 #1
0
ファイル: game.php プロジェクト: sherdog/wnd
 public function gamedata($playerID = null, $return = false)
 {
     Validate::player($playerID);
     //we are going to pass all data's
     $array = array();
     //this is what we store the data in.
     $player = new PlayerModel();
     $level = new LevelModel();
     $playerLevel = new PlayerLevelModel($playerID);
     $store = new StoreModel();
     $abModel = new ABModel();
     $rankModel = new RankModel();
     $array['status'] = 'ok';
     $array['player'] = $player->getPlayerData(array($playerID, false));
     $array['featuretests'] = $abModel->getTests($playerID);
     $array['scores'] = $playerLevel->load($playerID);
     $array['stores'] = $store->getStores();
     $array['gifts'] = $player->getGifts($playerID);
     $array['liferequests'] = $player->getRequests($playerID);
     $array['levels'] = $level->getLevelData();
     $array['ranks'] = $rankModel->getRanks();
     $levelData = null;
     $tmpObject = null;
     if ($return) {
         return $array;
     } else {
         $this->printJson($array);
     }
 }
コード例 #2
0
ファイル: purchase.php プロジェクト: sherdog/wnd
 private function processPayment($objectID)
 {
     $playerModel = new PlayerModel();
     $storeModel = new StoreModel();
     $error = false;
     $newOrder = false;
     $graphUrl = sprintf('https://graph.facebook.com/%s?access_token=%s|%s', $objectID, Config::get('facebook.appid'), Config::get('facebook.appsecret'));
     $curl = new Curl();
     $curl->get($graphUrl);
     if ($curl->error) {
         Log::add('Error in requesting object ' . $curl->error_code . ' : ' . $curl->error_message);
         throw new NinjaException("Error Processing Request");
     }
     $res = $curl->response;
     $facebookID = $res->user->id;
     $playerArray = $playerModel->getPlayerIDFromUID($facebookID, null, false);
     $playerID = $playerArray[0];
     $orderDetails = $storeModel->addOrder($playerID, $objectID, $res);
     if ($res->actions[0]->status == 'completed') {
         $status = 'ok';
         Log::add('payment ok charged status is good');
     } else {
         if ($res->actions[0]->status == 'failed') {
             $error = true;
             $status = 'error';
             $message = 'Payment Declined';
             Log::add('Payment failed ' . print_r($res, true));
         } else {
             if ($res->actions[0]->status == 'initiated') {
                 $error = false;
                 Log::add('Payment failed ' . print_r($res, true));
             } else {
                 $error = true;
                 $status = 'error';
                 $message = 'User canceled payment';
             }
         }
     }
     //ANALYTICS
     if (!$error) {
         $array['status'] = 'ok';
         $array['player'] = $playerModel->getPlayerData($playerID);
         $array['order'] = $orderDetails;
         $this->printJson($array);
     } else {
         $array['status'] = 'error';
         $array['message'] = $message;
         $this->printJson($array);
     }
 }