Example #1
0
 /**
  *
  * @return <CompleteProfileWrapper>
  */
 public function getProfile()
 {
     $user = $_SESSION['loggedin_user'];
     $completeProfileWrapper = new CompleteProfileWrapper();
     $userProfileDAO = new UserProfileDAO();
     $userProfile = $userProfileDAO->getUserProfile($user);
     $completeProfileWrapper->setUserProfile($userProfile);
     $_SESSION['user_profile'] = $userProfile;
     $friendUtil = new FriendsUtil();
     $friends = $friendUtil->getFriends($user);
     $completeProfileWrapper->friendsArray = $friends;
     $gameUtil = new GameUtil();
     $gameProfile = $gameUtil->getGameProfile($user);
     $completeProfileWrapper->setGameProfile($gameProfile);
     $_SESSION['game_profile'] = $gameProfile;
     $currentSearchPartyUtil = new CurrentSearchPartyUtil();
     $currentSearchParties = $currentSearchPartyUtil->getCurrentSearchParty($user);
     $completeProfileWrapper->currentSearchPartiesArray = $currentSearchParties;
     $friendSearchParties = $currentSearchPartyUtil->getFriendSearchParty($user);
     $completeProfileWrapper->friendSearchPartiesArray = $friendSearchParties;
     $inventoryUtil = new InventoryUtil();
     $myInventory = $inventoryUtil->getInventory($user);
     $completeProfileWrapper->myArtifacts = $myInventory;
     return $completeProfileWrapper;
 }
Example #2
0
 /**
  *
  * @param <GameProgress> $gameProgress
  * @return <GameResponse>
  */
 public function grantShareProgress($gameProgress)
 {
     $gameResponse = new GameProgressResponse();
     settype($gameProgress, "object");
     settype($gameProgress, "object");
     settype($gameProgress->friend, "object");
     settype($gameProgress->csp, "object");
     settype($gameProgress->csp->user, "object");
     settype($gameProgress->csp->artifact, "object");
     settype($gameProgress->progressType, "object");
     settype($gameProgress->friend->user, "object");
     $currentUserGameProfile = $_SESSION['game_profile'];
     $gameResponse->currentSearchParty = $gameProgress->csp;
     $artifactUtil = new ArtifactUtil();
     $artifact = $gameProgress->csp->artifact;
     if ($artifactUtil->isArtifactActive($artifact) == 0) {
         //artifact is in active
         $gameResponse->isSomebodyGetArtifact = true;
         return $gameResponse;
     }
     $gameUtil = new GameUtil();
     //checking weather the person have sufficient money to buy or not
     if (!$gameUtil->validShare($currentUserGameProfile, $gameProgress)) {
         return null;
     }
     $gameDao = new GameDAO();
     $progress = $gameDao->getShareProgress($currentUserGameProfile, $gameProgress);
     $progress = (int) $progress;
     $gameProgress->csp->progress += $progress;
     if ($progress == 0) {
         //dont update
     } else {
         //update and it will always happen as progress will b greater than zero
         $currentSearchPartyUtil = new CurrentSearchPartyUtil();
         $updatedSearchParty = $currentSearchPartyUtil->updateCurrentSearchPartyProgress($gameProgress->csp);
         if ($updatedSearchParty == null) {
             //some body already get the artifact
             $gameResponse->isSomebodyGetArtifact = true;
             return $gameResponse;
         } else {
             $gameResponse->isSomebodyGetArtifact = false;
         }
     }
     $gameResponse->percentObjtained = $progress;
     if ($gameProgress->csp->progress >= 100) {
         $gameUtil = new GameUtil();
         $gameUtilRes = $gameUtil->obtainArtifact($gameProgress->csp, $currentUserGameProfile);
         $updatedGameProfile = $gameUtilRes[1];
         $gameResponse->updatedGameProfile = $updatedGameProfile;
         $gameResponse->artifact = $gameUtilRes[0];
         $gameResponse->isActifactObtained = true;
     }
     return $gameResponse;
 }