Пример #1
0
 public function lives($playerID)
 {
     //we'll have a payload will have the hash key.
     Validate::player($playerID);
     Validate::payload($_POST['payload']);
     //so we passed the inital validation
     if ($_POST['payload'] == 'true') {
         $_POST['payload'] = Util::hashPost($_POST);
     }
     if (!$_POST) {
         throw new NInjaException("Error in request");
     }
     if (!$_POST['payload']) {
         throw new NinjaException("No data was received");
     }
     $data = str_replace(' ', '+', $_POST['payload']);
     $playerModel = new PlayerModel();
     if ($ack = $playerModel->collectGifts($playerID, $data)) {
         $response['status'] = 'ok';
         $response['value'] = $ack['lives'];
         $response['requests'] = $ack['requestCount'];
         $response['remaining'] = 0;
         //since we cap the # they can request to max lives of 8.
     } else {
         $response['status'] = 'error';
         $response['message'] = "error saving data";
         Log::add('Error updating lives');
     }
     $this->printJson($response);
 }