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 <CurrentSearchParty> $currentSearchParty
  * @param <GameProfile> $gameProfile
  * @return <Array>
  */
 public function obtainArtifact($currentSearchParty, $gameProfile)
 {
     //add to inventory
     //give experience i.e update game profile
     //chk for lvl up
     //make item inactive
     /*
      * Adding to inventory
      */
     $inventoryUtil = new InventoryUtil();
     $inventory = new Inventory();
     $inventory->artifact = $currentSearchParty->artifact;
     $inventory->artifactLvl = $currentSearchParty->artifactLvl;
     $inventory->user = $currentSearchParty->user;
     $inventory = $inventoryUtil->addToInventory($inventory);
     /*
      * Calulate exp
      */
     $exp = $currentSearchParty->artifactLvl * 100;
     $exp = $gameProfile->exp + $exp;
     /*
      * Update game profile and checking for levelup and updateing level
      */
     $userProfileDAO = new UserProfileDAO();
     $updatedProfile = $userProfileDAO->giveExperience($gameProfile, $exp);
     //exp is the updated exp
     /*
      * Making the artifact inactive
      */
     $artifactUtil = new ArtifactUtil();
     $artifactUtil->makeArtifactInactive($currentSearchParty->artifact);
     $returnArray = array();
     array_push($returnArray, $inventory);
     //on position 0 inventory will b thr
     array_push($returnArray, $updatedProfile);
     //on 1st position updated profile
     return $returnArray;
 }