function deactivateProfile($profilesToDeactivate, $userId) { if ($profilesToDeactivate) { $profileDAO = new UserProfileDAO(); foreach ($profilesToDeactivate as $profile) { if ($profile) { $profile->setProfileStatus("off"); $profile->setUserID($userId); $profileDAO->updateUserProfile($profile); } } } }
/** * * @param <String> $type * @return <GameProfile> */ public function addSkill($type) { $userProfileDao = new UserProfileDAO(); $gameProfile = $_SESSION['game_profile']; if ($type == ServerConstants::SPY) { $columnName = "spylvl"; } else { if ($type == ServerConstants::SCOUT) { $columnName = "scoutlvl"; } else { if ($type == ServerConstants::BUY) { $columnName = "buylvl"; } else { if ($type == ServerConstants::SHARE) { $columnName = "sharelvl"; } } } } if ($userProfileDao->addSkill($columnName, $gameProfile)) { if ($type == ServerConstants::SPY) { $gameProfile->spyLvl = $gameProfile->spyLvl + 1; } else { if ($type == ServerConstants::SCOUT) { $gameProfile->scoutLvl = $gameProfile->scoutLvl + 1; } else { if ($type == ServerConstants::BUY) { $gameProfile->buyLvl = $gameProfile->buyLvl + 1; } else { if ($type == ServerConstants::SHARE) { $gameProfile->shareLvl = $gameProfile->shareLvl + 1; } } } } $_SESSION['game_profile'] = $gameProfile; return $gameProfile; } else { return null; } }
/** * Carrega nos campos da classe os valores que estão armazenados no Banco de Dados * @param string $token Token do usuário, gerado pelo Login * @returns integer $sucess 1 em caso de sucesso, 0 em caso de erro */ function loadUser($token) { $ws = new ChamaWebService(); $param = '<todosDados>'; $param .= '<tokenUsuario>' . $token . '</tokenUsuario>'; $param .= '</todosDados>'; $this->clearFields(); $xml = $ws->retornoChamada('todosDados', $param); preg_match_all("/\\<entry\\>(.*?)\\<\\/entry\\>/s", $xml, $entry); preg_match_all("/\\<status\\>(.*?)\\<\\/status\\>/s", $xml, $status); $this->setToken($token); if ($status[1][0] != "OK") { return 0; } for ($i = 0; $i < count($entry[1]); $i++) { preg_match_all("/\\<string>(.*?)\\<\\/string\\>/s", trim($entry[1][$i]), $string); /* terminar de fazer isso com TODOS os campos . . . hehehehe */ if ($string[1][0] == "IDENTIFICADOR") { $this->setID($string[1][1]); } if ($string[1][0] == "FIRST_NAME") { $this->setFirstName($string[1][1]); } if ($string[1][0] == "LAST_NAME") { $this->setLastName($string[1][1]); } if ($string[1][0] == "GENDER") { $this->setGender($string[1][1]); } if ($string[1][0] == "EMAIL_ADDRESS") { $this->setEMail($string[1][1]); } if ($string[1][0] == "AFILIACAO") { $this->setAfiliacao($string[1][1]); } if ($string[1][0] == "GRAU_DE_FORMACAO") { $this->setGrauDeFormacao($string[1][1]); } } //carregando os dados do profile do usuário $userProfileDAO = new UserProfileDAO(); $this->setProfiles($userProfileDAO->getUserProfilesStatusOn($this->getID())); return 1; }
/** * * @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; }
/** * * @param <GameProfile> $userProfile * @param <int> $expPoints * @return <GameProfile> */ public function giveExperience($userProfile, $expPoints) { $userProfileDAO = new UserProfileDAO(); $updatedProfile = $userProfileDAO->giveExperience($currentSearchParty, $expPoints); return $updatedProfile; }
/** * Carrega nos campos da classe os valores que estão armazenados no Banco de Dados * @param integer $id Identificador do usuário * @returns integer $sucess 1 em caso de sucesso, 0 em caso de erro */ function loadUser($id) { $this->clearFields(); //carregando os dados do usuário $strsql = "SELECT * FROM users WHERE users.user_id = '" . $id . "'"; //$ret = $this->_db->databaseExecInsert($strsql); $arr = $this->_db->databaseQuery($strsql); if (count($arr) > 0) { $this->setID($arr[0]['user_id']); $this->setFirstName($arr[0]['user_firstname']); $this->setLastName($arr[0]['user_lastname']); $this->setGender($arr[0]['user_gender']); $this->setLogin($arr[0]['user_login']); $this->setEMail($arr[0]['user_email']); //carregando os dados do profile do usuário $userProfileDAO = new UserProfileDAO(); $this->setProfiles($userProfileDAO->getUserProfilesStatusOn($id)); return 1; } else { return 0; } }