public static function generatePage(&$tpl, &$session, &$account, &$mj) { $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante if (!isset($_POST['itemId'])) { return fctErrorMSG('Vous devez sélectionner un item.', '?mj=Lieu_Inventaire&id=' . $_GET['id'], null, false); } //Créer l'objet item vers/dans lequel transférer les items. $itemTo = Member_ItemFactory::createFromInvId($_POST['itemId']); foreach ($_POST['invId'] as $itemId) { //Si l'item ne supporte pas la gestion de quantité, simplement considérer sa quantité comme étant de 1. if (!isset($_POST['inv' . $itemId])) { $_POST['inv' . $itemId] = 1; } //Créer l'objet item à transférer $item = Member_ItemFactory::createFromInvId($itemId); //Si l'item est caché, le dé-cacher if ($item->iscache()) { $item->decacherObjet(); } $item->transfererVersItem($itemTo, $_POST['inv' . $itemId]); } //Retourner le template complété/rempli $tpl->set('PAGE', 'Lieu_Inventaire&id=' . $_GET['id']); return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Mj/redirect.htm', __FILE__, __LINE__); }
public static function generatePage(&$tpl, &$session, &$account, &$mj) { $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante if (!isset($_POST['lieuTech'])) { return fctErrorMSG('Vous devez sélectionner un lieu.', '?mj=Perso_Inventaire&id=' . $_GET['id'], null, false); } //Instancier le lieu try { $lieu = Member_LieuFactory::createFromNomTech($_POST['lieuTech']); } catch (Exception $e) { return fctErrorMSG($e->getMessage()); } foreach ($_POST['invId'] as $itemId) { //Si l'item ne supporte pas la gestion de quantité, simplement considérer sa quantité comme étant de 1. if (!isset($_POST['inv' . $itemId])) { $_POST['inv' . $itemId] = 1; } //Créer l'objet item à transférer $item = Member_ItemFactory::createFromInvId($itemId); $item->transfererVersLieu($lieu, $_POST['inv' . $itemId]); } //Retourner le template complété/rempli $tpl->set('PAGE', 'Lieu_Inventaire&id=' . $_GET['id']); return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Mj/redirect.htm', __FILE__, __LINE__); }
public static function generatePage(&$tpl, &$session, &$account, &$mj) { $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante if (!isset($_POST['casierId'])) { return fctErrorMSG('Vous devez sélectionner un casier.', '?mj=Lieu_Inventaire&id=' . $_GET['id'] . '&cid=' . $_POST['casier'], null, false); } $query = 'SELECT *' . ' FROM ' . DB_PREFIX . 'lieu_casier' . ' WHERE id=:casierId' . ' LIMIT 1;'; $prep = $db->prepare($query); $prep->bindValue(':casierId', $_POST['casierId'], PDO::PARAM_INT); $prep->execute($db, __FILE__, __LINE__); $arr = $prep->fetch(); $prep->closeCursor(); $prep = NULL; //Créer l'objet Casier (à qui donner l'item) $casier = new Member_Casier($arr); foreach ($_POST['invId'] as $itemId) { //Si l'item ne supporte pas la gestion de quantité, simplement considérer sa quantité comme étant de 1. if (!isset($_POST['inv' . $itemId])) { $_POST['inv' . $itemId] = 1; } //Créer l'objet item à transférer $item = Member_ItemFactory::createFromInvId($itemId); //Si l'item est caché, le dé-cacher if ($item->iscache()) { $item->decacherObjet(); } $item->transfererVersCasier($casier, $_POST['inv' . $itemId]); } //Retourner le template complété/rempli $tpl->set('PAGE', 'Lieu_Inventaire&id=' . $_GET['id']); return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Mj/redirect.htm', __FILE__, __LINE__); }
/** Charge la liste des items en inventaire. * <br> Selon le perso actuel (de l'objet perso), cette fonction créer/génère le 'tableau des item en inventaire'. * <br> Cette fonction est apellée par getInventaire() et par les codes qui modifient l'inventaire (Inventaire, dépouillement, etc) dans le cas ou le 'tableau des item en inventaire' est innexistant. * */ public function refreshInventaire() { $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante //Vider l'inventaire $this->inventaire = NULL; //Charger le nouvel inventaire $this->inventaire = Member_ItemFactory::createFromItemId($this->getInvId()); $this->refreshPR(); }
public static function generatePage(&$tpl, &$session, &$account, &$perso) { $errorUrl = '?popup=1&m=Action_Item_Media'; $paCost = 0; if (!$perso->isConscient()) { return fctErrorMSG('Vous n\'êtes pas en état d\'effectuer cette action.', $errorUrl); } //Pas assez de PA if ($perso->getPa() <= $paCost) { return fctErrorMSG('Vous n\'avez pas assez de PA pour effectuer cette action.', $errorUrl); } //Vérifications du post if (!isset($_POST['mediaSelected'])) { return fctErrorMSG('Vous n\'avez pas sélectionné d\'objet.', $errorUrl); } if (empty($_POST[$_POST['mediaSelected'] . '_channelSelected'])) { return fctErrorMSG('Vous n\'avez pas choisi de canal.', $errorUrl); } //Récupérer les informations sur l'item media $item = Member_ItemFactory::createFromInvId($_POST['mediaSelected']); if ($item == false) { return fctErrorMsg('Erreur : l\'item selectionné n\'est pas supporté.', $errorUrl); } if ($item->getMediaType() != 'tous') { if ($item->getMediaType() != $_POST[$_POST['mediaSelected'] . '_typeSelected']) { return fctErrorMsg('Le type de média selectionné n\'est pas accessible par cet objet.', $errorUrl); } } $mediaMsg = $item->getMediaContenu($_POST[$_POST['mediaSelected'] . '_typeSelected'], $_POST[$_POST['mediaSelected'] . '_channelSelected']); $mediaReception = $item->isRecepteur(); $mediaEmission = $item->isEmetteur(); //Si on veut regarder les média : retirer les PA if ($item->isRecepteur()) { $perso->changePa('-', $paCost); $perso->setPa(); } $tpl->set('MEDIA_RECEPTION', $mediaReception); $tpl->set('MEDIA_EMISSION', $mediaEmission); $tpl->set('MEDIA_MESSAGE', $mediaMsg); $tpl->set('PERSO', $perso); $tpl->set('CANAL', $_POST[$_POST['mediaSelected'] . '_channelSelected']); $tpl->set('ITEM', $item); if ($_POST[$_POST['mediaSelected'] . '_typeSelected'] = 'tele') { $typeAffichable = 'télé'; } else { $typeAffichable = 'radio'; } $tpl->set('MEDIA', $typeAffichable); $tpl->set('MEDIA_TYPE', $_POST[$_POST['mediaSelected'] . '_typeSelected']); //Retourner le template complété/rempli return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/Action/Item/Media2.htm', __FILE__, __LINE__); }
public static function generatePage(&$tpl, &$session, &$account, &$mj) { $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante if (!isset($_GET['id'])) { return fctErrorMSG('Vous devez sélectionner un personnage.'); } if (!is_numeric($_GET['id'])) { return fctErrorMSG('ID non numérique'); } //Trouver des informations sur le perso $query = 'SELECT *' . ' FROM ' . DB_PREFIX . 'perso' . ' WHERE id=:persoId' . ' LIMIT 1;'; $prep = $db->prepare($query); $prep->bindValue(':persoId', $_GET['id'], PDO::PARAM_INT); $prep->executePlus($db, __FILE__, __LINE__); $arr = $prep->fetch(); $prep->closeCursor(); $prep = NULL; if ($arr === false) { return fctErrorMSG('Ce personnage n\'existe pas.'); } $perso = new Member_Perso($arr); $tpl->set('PERSO', $perso); //Effectuer le rendu tableau de l'inventaire try { $arrItem = Member_ItemFactory::createFromPersoId($perso->getId(), true); $tableHTML = Mj_Item_Inventaire::generateInventaireTable($account, $arrItem, 'Perso_Inventaire', $_GET['id'], '800px'); if (!empty($tableHTML)) { $tpl->set('ITEMS_TABLE', $tableHTML); } } catch (Exception $e) { return fctErrorMSG($e->getMessage()); } //Retourner le template complété/rempli return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Mj/Perso/Inventaire.htm', __FILE__, __LINE__); }
public static function generatePage(&$tpl, &$session, &$account, &$perso) { $errorUrl = '?popup=1&m=Action_Item_Media'; $paCost = 0; if (!$perso->isConscient()) { return fctErrorMSG('Vous n\'êtes pas en état d\'effectuer cette action.', $errorUrl); } //Pas assez de PA if ($perso->getPa() <= $paCost) { return fctErrorMSG('Vous n\'avez pas assez de PA pour effectuer cette action.', $errorUrl); } //Vérifications du post if (!isset($_POST['title'])) { return fctErrorMSG('Vous n\'avez pas sélectionné d\'émission.', $errorUrl); } if (empty($_POST['message'])) { return fctErrorMSG('Vous devez écrire un message.', $errorUrl); } if ($_POST['title'] == 'new' && empty($_POST['new_title'])) { return fctErrorMSG('Vous devez entrer un nom d\'émission.', $errorUrl); } //Récupérer les informations sur l'item media $item = Member_ItemFactory::createFromInvId($_POST['item']); if ($item == false) { return fctErrorMsg('Erreur : l\'item selectionné n\'est pas supporté.', $errorUrl); } if ($item->getMediaType() != 'tous') { if ($item->getMediaType() != $_POST['mediaType']) { return fctErrorMsg('Le type de média selectionné n\'est pas accessible par cet objet.', $errorUrl); } } $item->writeInMedia($_POST['mediaType'], $_POST['channel'], $_POST[$_POST['title'] . '_title'], $_POST['message']); $perso->changePa('-', $paCost); $perso->setPa(); //Rafraichir le HE return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/herefresh.htm', __FILE__, __LINE__); }
/** * Génère un tableau de l'inventaire d'un item à partir d'une requête. * * @param Account &$account Account à utiliser (par défaut: $account) * @param array $arrItem tableau des items à traiter * @param string $returnPage Nom du module actuel (pour les pages de retour, ex: Member_Perso_Inventaire) * @param string $tableWidth Largeur du tableau à créer * @return string Retourne du code HTML ou false si aucun item */ public static function generateInventaireTable(&$account, &$arrItem, $returnPage, $returnId, $tableWidth, $deep = 0) { $deep++; $tpl = new Template($account); if (count($arrItem) == 0) { return array(); } //Trier le tableau en ordre de type usort($arrItem, "compare"); //Construire la liste des tableaux $tableHTML = ''; $currentCat = ''; $i = 0; foreach ($arrItem as $item) { //Gérer les entête du tableau $showHeader = false; if ($currentCat != $item->getTypeTech()) { if (!empty($tableHTML)) { //Ne pas commencer avec une fermeture de tableau $tableHTML .= '</table><br />'; } $currentCat = $item->getTypeTech(); $showHeader = true; } //Générer le tableau $type = $item->getTypeTech(); if ($item instanceof Member_ItemDefense) { $type = 'defense'; } if ($item instanceof Member_ItemDrogue) { $type = 'drogue'; } if ($item instanceof Member_ItemSac && $deep < 2) { $arrItem2 = Member_ItemFactory::createFromItemId($item->getInvId(), true); if (!empty($arrItem2)) { $sacHTML = self::generateInventaireTable($account, $arrItem2, $returnPage, $returnId, '750px', $deep); } else { $sacHTML = "Vide"; } $tpl->set('SAC_INVENTAIRE', $sacHTML); } $tpl->set('SHOW_HEADER', $showHeader); $tpl->set('TABLE_WIDTH', $tableWidth); $tpl->set('RETURN_PAGE', $returnPage); $tpl->set('RETURN_ID', $returnId); $tpl->set('ITEM', $item); $tableHTML .= $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Mj/Item/Inventaire_' . $type . '.htm', __FILE__, __LINE__); } return $tableHTML . '</table>'; }
/** Charge la liste des items en inventaire. * <br> Selon le lieu actuel (de l'objet lieu), cette fonction créer/génère le 'tableau des item en inventaire'. * <br> Cette fonction est apellée par {@link getItems()} * * @param int $casier Si défini, sert à spécifier de quel casier ont souhaite obtenir l'inventaire */ public function refreshItems() { //Vider l'inventaire $this->items = NULL; //Charger le nouvel inventaire $this->items = Member_ItemFactory::createFromCasierId($this->getId()); }
/** * Charge la liste des items en inventaire. * * Selon le perso actuel (de l'objet perso), cette fonction créer/génère le 'tableau des item en inventaire'. * Cette fonction est apellée par getInventaire() et par les codes qui modifient l'inventaire (Inventaire, dépouillement, etc) dans le cas ou le 'tableau des item en inventaire' est innexistant. * * @param bool $listAllDrugs Liste les drogues actuellement consommées. * @see getInventaire() */ public function refreshInventaire($listAllDrugs = false) { $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante //Vider l'inventaire $this->inventaire = NULL; //Charger le nouvel inventaire $this->inventaire = Member_ItemFactory::createFromPersoId($this->getId(), $listAllDrugs); //Calcul des PR $this->pr = 0; foreach ($this->inventaire as $item) { if (!$item->isEquip()) { $this->pr += $item->getPr() * $item->getQte(); } } }
/** * Charge la liste des items en inventaire dans la boutique. * * Selon le lieu actuel (de l'objet lieu), cette fonction créer/génère * le 'tableau des item en inventaire'. * Cette fonction est apellée par {@link getBoutiqueInventaire()} * * @see getBoutiqueInventaire() */ private function refreshBoutiqueItems() { $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante //Vider l'inventaire $this->boutiqueInventaire = NULL; //Charger le nouvel inventaire $this->boutiqueInventaire = Member_ItemFactory::createFromNomTechBoutique($this->getNomTech()); }
public static function generatePage(&$tpl, &$session, &$account, &$mj) { $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante if (isset($_POST['save'])) { //Fetcher toutes les informations concernant le perso $query = 'SELECT *' . ' FROM ' . DB_PREFIX . 'perso' . ' WHERE id=:persoId' . ' LIMIT 1;'; $prepP = $db->prepare($query); $prepP->bindValue(':persoId', $_GET['id'], PDO::PARAM_INT); $prepP->executePlus($db, __FILE__, __LINE__); $arr = $prepP->fetch(); $perso = new Member_Perso($arr); //Vérifier tout ce qui a changé $msg = array(); if ($perso->getUserId() != $_POST['userId']) { $msg[] = 'UserId: ' . $_POST['userId']; } if ($perso->getNom() != $_POST['nom']) { $msg[] = 'Nom: ' . $_POST['nom']; } if ($perso->getSexe() != $_POST['sexe']) { $msg[] = 'Sexe: ' . $_POST['sexe']; } if ($perso->getAge() != $_POST['age']) { $msg[] = 'Age: ' . $_POST['age']; } if ($perso->getTaille() != $_POST['taille']) { $msg[] = 'Taille: ' . $_POST['taille']; } if ($perso->getEthnie() != $_POST['ethnie']) { $msg[] = 'Ethnie: ' . $_POST['ethnie']; } if ($perso->getYeux() != $_POST['yeux']) { $msg[] = 'Yeux: ' . $_POST['yeux']; } if ($perso->getCheveux() != $_POST['cheveux']) { $msg[] = 'Cheveux: ' . $_POST['cheveux']; } if ($perso->getType() != $_POST['playertype']) { $msg[] = 'Type: ' . $_POST['playertype']; } if ($perso->getPrMax() != $_POST['prmax']) { $msg[] = 'Pr Max: ' . $_POST['prmax']; } if ($perso->getPa() != $_POST['pa']) { $msg[] = 'Pa: ' . $_POST['pa']; } if ($perso->getPaMax() != $_POST['pamax']) { $msg[] = 'Pa Max: ' . $_POST['pamax']; } if ($perso->getPv() != $_POST['pv']) { $msg[] = 'Pv: ' . $_POST['pv']; } if ($perso->getPvMax() != $_POST['pvmax']) { $msg[] = 'Pv Max: ' . $_POST['pvmax']; } if ($perso->getPn() != $_POST['pn']) { $msg[] = 'Pn: ' . $_POST['pn']; } if ($perso->getCash() != $_POST['cash']) { $msg[] = 'Argent: ' . $_POST['cash']; } try { if ($perso->getLieu()->getNomTech() != $_POST['lieu']) { $msg[] = 'Lieu: ' . $_POST['lieu']; } } catch (Exception $e) { if (!isset($_POST['lieu'])) { $msg[] = 'Lieu: non-sélectionné'; } else { $msg[] = 'Lieu: ' . $_POST['lieu']; } } if ($perso->getCurrentAction() != $_POST['current_action']) { $msg[] = "Action Courrante: \n" . $_POST['current_action']; } if ($perso->getDescription() != $_POST['description']) { $msg[] = "Description: \n" . $_POST['description']; } if ($perso->getBackground() != $_POST['background']) { $msg[] = "Background: \n" . $_POST['background']; } if ($perso->getNoteMj() != $_POST['note_mj']) { $msg[] = "Note MJ: \n" . $_POST['note_mj']; } if ($perso->isBloque() != $_POST['actif']) { $msg[] = 'Actif: ' . $_POST['actif']; } if ($perso->getVisaPerm() != $_POST['visavert']) { $msg[] = 'VisaVert: ' . $_POST['visavert']; } if ($perso->getPv() > 0 && $_POST['pv'] < 0) { $perso->logMort($mj->getNom(), 'Modifier Perso'); } $menotte = $_POST['menotte'] == false ? NULL : $_POST['menotteId']; if ($perso->getMenotte() != $menotte) { $msg[] = 'Menotté : ' . ($menotte ? 'oui (' . $menotte . ').' : 'non.'); //Gestion des menottes //Si menotté : //Vérifier si l'item a bien la capacité menottage //Vérifier si l'item n'est pas déjà utilisé //Equiper l'item //Si passage de monotté à menotté avec autre item => déséquiper ancien item //Si passage de menotté à non menotté => déséquiper l'item if ($menotte) { try { $newMenotte = Member_ItemFactory::createFromInvId($menotte); } catch (Exception $e) { return fctErrorMSG($e->getMessage()); } $query = 'SELECT *' . ' FROM ' . DB_PREFIX . 'item_menu' . ' WHERE item_dbid = :dbid' . ' AND url="Menotter" LIMIT 1;'; $prep = $db->prepare($query); $prep->bindValue(':dbid', $newMenotte->getDbId(), PDO::PARAM_INT); $prep->executePlus($db, __FILE__, __LINE__); $arrAll = $prep->fetchAll(); $prep->closeCursor(); $prep = NULL; if (count($arrAll) == 0) { return fctErrorMSG('L\'item choisi pour menotter n\'a pas la capacité menotter.'); } if ($newMenotte->isEquip()) { return fctErrorMSG('L\'item choisi pour menotter est déjà utilisé.'); } //Équiper l'item $query = 'UPDATE ' . DB_PREFIX . 'item_inv' . ' SET inv_equip="1"' . ' WHERE inv_id=:itemId' . ' LIMIT 1;'; $prep = $db->prepare($query); $prep->bindValue(':itemId', $newMenotte->getInvId(), PDO::PARAM_INT); $prep->executePlus($db, __FILE__, __LINE__); $prep->closeCursor(); $prep = NULL; if ($perso->getMenotte()) { $query = 'UPDATE ' . DB_PREFIX . 'item_inv' . ' SET inv_equip="0"' . ' WHERE inv_id=:itemId' . ' LIMIT 1;'; $prep = $db->prepare($query); $prep->bindValue(':itemId', $perso->getMenotte(), PDO::PARAM_INT); $prep->executePlus($db, __FILE__, __LINE__); $prep->closeCursor(); $prep = NULL; } } else { $query = 'UPDATE ' . DB_PREFIX . 'item_inv' . ' SET inv_equip="0"' . ' WHERE inv_id=:itemId' . ' LIMIT 1;'; $prep = $db->prepare($query); $prep->bindValue(':itemId', $perso->getMenotte(), PDO::PARAM_INT); $prep->executePlus($db, __FILE__, __LINE__); $prep->closeCursor(); $prep = NULL; } } //modification $query = 'UPDATE ' . DB_PREFIX . 'perso' . ' SET' . ' userId=:userId,' . ' nom=:nom,' . ' sexe=:sexe,' . ' age=:age,' . ' taille=:taille,' . ' ethnie=:ethnie,' . ' yeux=:yeux,' . ' cheveux=:cheveux,' . ' playertype=:playerType,' . ' prmax=:prMax,' . ' pa=:pa,' . ' pamax=:paMax,' . ' pv=:pv,' . ' pvmax=:pvMax,' . ' pn=:pn,' . ' cash=:cash,' . ' lieu=:lieu,' . ' current_action=:currentAction,' . ' description=:description,' . ' background=:background,' . ' note_mj=:noteMj,' . ' bloque=:bloque,' . ' visa_perm=:visaPerm,' . ' menotte = :menotte' . ' WHERE id=:persoId;'; $prep = $db->prepare($query); $prep->bindValue(':persoId', $_GET['id'], PDO::PARAM_INT); $prep->bindValue(':userId', $_POST['userId'], PDO::PARAM_INT); $prep->bindValue(':nom', $_POST['nom'], PDO::PARAM_STR); $prep->bindValue(':sexe', $_POST['sexe'], PDO::PARAM_STR); $prep->bindValue(':age', $_POST['age'], PDO::PARAM_INT); $prep->bindValue(':taille', $_POST['taille'], PDO::PARAM_STR); $prep->bindValue(':ethnie', $_POST['ethnie'], PDO::PARAM_STR); $prep->bindValue(':yeux', $_POST['yeux'], PDO::PARAM_STR); $prep->bindValue(':cheveux', $_POST['cheveux'], PDO::PARAM_STR); $prep->bindValue(':playerType', $_POST['playertype'], PDO::PARAM_STR); $prep->bindValue(':prMax', $_POST['prmax'], PDO::PARAM_INT); $prep->bindValue(':pa', $_POST['pa'], PDO::PARAM_INT); $prep->bindValue(':paMax', $_POST['pamax'], PDO::PARAM_INT); $prep->bindValue(':pv', $_POST['pv'], PDO::PARAM_INT); $prep->bindValue(':pvMax', $_POST['pvmax'], PDO::PARAM_INT); $prep->bindValue(':pn', $_POST['pn'], PDO::PARAM_INT); $prep->bindValue(':cash', $_POST['cash'], PDO::PARAM_INT); $prep->bindValue(':lieu', isset($_POST['lieu']) ? $_POST['lieu'] : LIEU_DEPART, PDO::PARAM_STR); $prep->bindValue(':currentAction', $_POST['current_action'], PDO::PARAM_STR); $prep->bindValue(':description', $_POST['description'], PDO::PARAM_STR); $prep->bindValue(':background', $_POST['background'], PDO::PARAM_STR); $prep->bindValue(':noteMj', $_POST['note_mj'], PDO::PARAM_STR); $prep->bindValue(':bloque', $_POST['actif'], PDO::PARAM_STR); $prep->bindValue(':visaPerm', $_POST['visavert'], PDO::PARAM_STR); $prep->bindValue(':persoId', $_GET['id'], PDO::PARAM_INT); $prep->bindValue(':menotte', $menotte, PDO::PARAM_STR); $prep->executePlus($db, __FILE__, __LINE__); $prep->closeCursor(); $prep = NULL; //Fetcher toutes les informations concernant le perso $prepP->bindValue(':persoId', $_GET['id'], PDO::PARAM_INT); $prepP->executePlus($db, __FILE__, __LINE__); $arr = $prepP->fetch(); $perso = new Member_Perso($arr); //Sauvegarder les stats $query = 'INSERT INTO ' . DB_PREFIX . 'perso_stat' . ' (persoid, statid, xp)' . ' VALUES' . ' (:persoId, :statId, :xp);'; $prepIns = $db->prepare($query); $query = 'UPDATE ' . DB_PREFIX . 'perso_stat' . ' SET xp=:xp' . ' WHERE persoid=:persoId' . ' AND statid=:statId' . ' LIMIT 1;'; $prepUpd = $db->prepare($query); foreach ($perso->getStat() as $id) { $statCode = $perso->getStatCode($id); $fieldName = 'stat_' . $statCode; if (isset($_POST[$fieldName]) && is_numeric($_POST[$fieldName]) && $perso->getStatRawXp($id) != $_POST[$fieldName]) { //Construire le message d'information $statDiff = (int) $_POST[$fieldName] - $perso->getStatRawXp($id); if ($statDiff > 0) { $statDiff = '+' . $statDiff; } $msg[] = 'Stat ' . strtoupper($statCode) . ': ' . $statDiff; if ($perso->getStatRawXp($id) === NULL) { $prepIns->bindValue(':persoId', $perso->getId(), PDO::PARAM_INT); $prepIns->bindValue(':statId', $id, PDO::PARAM_INT); $prepIns->bindValue(':xp', $_POST[$fieldName], PDO::PARAM_INT); $prepIns->executePlus($db, __FILE__, __LINE__); } else { $prepUpd->bindValue(':persoId', $perso->getId(), PDO::PARAM_INT); $prepUpd->bindValue(':statId', $id, PDO::PARAM_INT); $prepUpd->bindValue(':xp', $_POST[$fieldName], PDO::PARAM_INT); $prepUpd->executePlus($db, __FILE__, __LINE__); } } } $prepIns->closeCursor(); $prepIns = NULL; $prepUpd->closeCursor(); $prepUpd = NULL; //Sauvegarder les comps $query = 'INSERT INTO ' . DB_PREFIX . 'perso_competence' . ' (`persoid`, `compid`, `xp`)' . 'VALUES' . '(:persoId, :compId, :xp);'; $prepIns = $db->prepare($query); $query = 'UPDATE ' . DB_PREFIX . 'perso_competence' . ' SET xp=:xp' . ' WHERE persoid=:persoId' . ' AND compid=:compId' . ' LIMIT 1;'; $prepUpd = $db->prepare($query); $query = 'DELETE FROM ' . DB_PREFIX . 'perso_competence' . ' WHERE persoid=:persoId' . ' AND compid=:compId' . ' LIMIT 1;'; $prepDel = $db->prepare($query); foreach ($perso->getComp() as $id) { $compCode = $perso->getCompCode($id); $fieldName = 'comp_' . $compCode; //La comp doit être définie if (isset($_POST[$fieldName]) && !empty($_POST[$fieldName]) && is_numeric($_POST[$fieldName]) && $perso->getCompXp($id) != $_POST[$fieldName]) { //Construire le message d'information $compDiff = (int) $_POST[$fieldName] - $perso->getCompXp($id); if ($compDiff > 0) { $compDiff = '+' . $compDiff; } $msg[] = 'Comp ' . strtoupper($compCode) . ': ' . $compDiff; //Créer la comp if ($perso->getCompXp($id) === NULL) { $prepIns->bindValue(':persoId', $perso->getId(), PDO::PARAM_INT); $prepIns->bindValue(':compId', $id, PDO::PARAM_INT); $prepIns->bindValue(':xp', $_POST[$fieldName], PDO::PARAM_INT); $prepIns->executePlus($db, __FILE__, __LINE__); } else { $prepUpd->bindValue(':persoId', $perso->getId(), PDO::PARAM_INT); $prepUpd->bindValue(':compId', $id, PDO::PARAM_INT); $prepUpd->bindValue(':xp', $_POST[$fieldName], PDO::PARAM_INT); $prepUpd->executePlus($db, __FILE__, __LINE__); } } //La compétence doit être effacée if (isset($_POST[$fieldName]) && empty($_POST[$fieldName]) && $perso->getCompXp($id) !== NULL) { $prepDel->bindValue(':persoId', $perso->getId(), PDO::PARAM_INT); $prepDel->bindValue(':compId', $id, PDO::PARAM_INT); $prepDel->executePlus($db, __FILE__, __LINE__); //Construire le message d'information $msg[] = 'Comp ' . strtoupper($compCode) . ': 0'; } } $prepIns->closeCursor(); $prepIns = NULL; $prepUpd->closeCursor(); $prepUpd = NULL; $prepDel->closeCursor(); $prepDel = NULL; //Modifier / Supprimer une caract $query = 'SELECT p.*, c.nom' . ' FROM ' . DB_PREFIX . 'perso_caract as p' . ' LEFT JOIN ' . DB_PREFIX . 'caract as c' . ' ON (c.id = p.caractid)' . ' WHERE p.`persoid`=:persoId;'; $prep = $db->prepare($query); $prep->bindValue(':persoId', $_GET['id']); $prep->executePlus($db, __FILE__, __LINE__); $arrAll = $prep->fetchAll(); $prep->closeCursor(); $prep = NULL; $query = 'UPDATE ' . DB_PREFIX . 'perso_caract' . ' SET `desc`=:description' . ' WHERE `id`=:id;'; $prepUpd = $db->prepare($query); $query = 'DELETE FROM ' . DB_PREFIX . 'perso_caract' . ' WHERE `id`=:id' . ' LIMIT 1;'; $prepDel = $db->prepare($query); foreach ($arrAll as &$row) { //Supprimer ? if (isset($_POST['del_caract_' . $row['id']])) { $prepDel->bindValue(':id', $row['id'], PDO::PARAM_INT); $prepDel->executePlus($db, __FILE__, __LINE__); $msg[] = 'Suppression de la caract ' . stripslashes($row['nom']); } else { $newDesc = fctScriptProtect($_POST['caract_' . $row['id']]); if (stripslashes($row['desc']) != $newDesc) { //Modifier $prepUpd->bindValue(':description', $newDesc, PDO::PARAM_STR); $prepUpd->bindValue(':id', $row['id'], PDO::PARAM_INT); $prepUpd->executePlus($db, __FILE__, __LINE__); $msg[] = 'Modification de la caract ' . stripslashes($row['nom']) . ":\n" . $newDesc; } } } $prepUpd->closeCursor(); $prepUpd = NULL; $prepDel->closeCursor(); $prepDel = NULL; //Ajouter une caract if ($_POST['add_caract'] != 0) { $query = 'INSERT INTO ' . DB_PREFIX . 'perso_caract' . ' (`caractid`,`persoid`)' . ' VALUES' . ' (:caractId, :persoId);'; $prep = $db->prepare($query); $prep->bindValue(':caractId', $_POST['add_caract'], PDO::PARAM_INT); $prep->bindValue(':persoId', $_GET['id'], PDO::PARAM_INT); $prep->executePlus($db, __FILE__, __LINE__); $prep->closeCursor(); $prep = NULL; $msg[] = 'Ajout de la caract #' . $_POST['add_caract'] . ":\n"; } //Recharger la liste des perso du compte actuel (compte du MJ) $query = 'SELECT id, nom FROM ' . DB_PREFIX . 'perso WHERE userId=:userId;'; $prep = $db->prepare($query); $prep->bindValue(':userId', $session->getVar('userId'), PDO::PARAM_INT); $prep->executePlus($db, __FILE__, __LINE__); $arrAll = $prep->fetchAll(); $prep->closeCursor(); $prep = NULL; $session->setVar('persoList', $arrAll); //Afficher les messages et logger dans le HE MJ if (count($msg) > 0) { $msg = implode(",\n", $msg); $tpl->set('MODIFICATIONS', nl2br($msg)); $mj->addHe("Modification du personnage: \n" . $msg, $perso->getNom(), 'perso'); } $prepP->closeCursor(); $prepP = NULL; } // End save //Fetcher toutes les informations concernant le perso $query = 'SELECT p.*, a.user as user' . ' FROM ' . DB_PREFIX . 'perso as p' . ' LEFT JOIN ' . DB_PREFIX . 'account as a' . ' ON (a.id=p.userId)' . ' WHERE p.id=:persoId' . ' LIMIT 1;'; $prep = $db->prepare($query); $prep->bindValue(':persoId', $_GET['id'], PDO::PARAM_INT); $prep->executePlus($db, __FILE__, __LINE__); $arr = $prep->fetch(); $prep->closeCursor(); $prep = NULL; if ($arr === false) { return fctErrorMSG('Ce personnage n\'existe pas.'); } try { $perso = new Member_Perso($arr); } catch (Exception $e) { return fctErrorMSG($e->getMessage()); } try { $tpl->set('PERSO_LIEU', $perso->getLieu()->getNomTech()); } catch (Exception $e) { $tpl->set('PERSO_LIEU', 'LIEU CORROMPU'); } $tpl->set('PERSO', $perso); $tpl->set('ACCOUNT_USER', $arr['user']); $tpl->set('BACKGROUND', stripslashes($arr['background'])); $tpl->set('NOTE_MJ', stripslashes($arr['note_mj'])); //Trouver les drogues consommées $query = 'SELECT inv_id' . ' FROM ' . DB_PREFIX . 'item_inv' . ' WHERE inv_equip="1"' . ' AND inv_dbid="2"' . ' AND inv_persoid=:persoId' . ' ;'; $prep = $db->prepare($query); $prep->bindValue(':persoId', $perso->getId(), PDO::PARAM_INT); $prep->executePlus($db, __FILE__, __LINE__); $arrAll = $prep->fetchAll(); $prep->closeCursor(); $prep = NULL; $drogues = array(); foreach ($arrAll as &$arr) { $drogues[] = '<a href="?mj=Item_Inv_Mod&id=' . (int) $arr['inv_id'] . '&rpage=Perso_Mod&rid=' . (int) $perso->getId() . '">' . (int) $arr['inv_id'] . '</a>'; } if (count($drogues) > 0) { $tpl->set('DROGUES', implode(', ', $drogues)); } //Trouver les caractéristiques du perso $query = 'SELECT p.*, c.nom, t.nom as cat' . ' FROM ' . DB_PREFIX . 'perso_caract as p' . ' LEFT JOIN ' . DB_PREFIX . 'caract as c ON (c.id = p.caractid)' . ' LEFT JOIN ' . DB_PREFIX . 'caract as t ON (t.id = c.catid)' . ' WHERE p.persoid=:persoId;'; $prep = $db->prepare($query); $prep->bindValue(':persoId', $perso->getId(), PDO::PARAM_INT); $prep->executePlus($db, __FILE__, __LINE__); $arrAll = $prep->fetchAll(); $prep->closeCursor(); $prep = NULL; foreach ($arrAll as &$arr) { $arr['cat'] = stripslashes($arr['cat']); $arr['nom'] = stripslashes($arr['nom']); $arr['desc'] = stripslashes($arr['desc']); } $tpl->set('CARACT', $arrAll); //Trouver toutes les caractéristiques $query = 'SELECT c.*, t.nom as cat' . ' FROM ' . DB_PREFIX . 'caract as c' . ' LEFT JOIN ' . DB_PREFIX . 'caract as t ON (t.id = c.catid)' . ' WHERE c.catid!=0' . ' ORDER BY t.nom, c.nom;'; $prep = $db->prepare($query); $prep->bindValue(':persoId', $perso->getId(), PDO::PARAM_INT); $prep->executePlus($db, __FILE__, __LINE__); $arrAll = $prep->fetchAll(); $prep->closeCursor(); $prep = NULL; foreach ($arrAll as &$arr) { $arr['cat'] = stripslashes($arr['cat']); $arr['nom'] = stripslashes($arr['nom']); } $tpl->set('ALLCARACT', $arrAll); //trouver les modificateurs des compétences: $query = 'SELECT c.*, p.xp, s.statid, s.stat_multi' . ' FROM ' . DB_PREFIX . 'competence as c' . ' LEFT JOIN ' . DB_PREFIX . 'perso_competence as p ON (p.compid = c.id AND p.persoid=:persoId)' . ' LEFT JOIN ' . DB_PREFIX . 'competence_stat as s ON (s.compid = c.id)' . ' ORDER BY c.id;'; $prep = $db->prepare($query); $prep->bindValue(':persoId', $perso->getId(), PDO::PARAM_INT); $prep->executePlus($db, __FILE__, __LINE__); $arrAll = $prep->fetchAll(); $prep->closeCursor(); $prep = NULL; $arrComp = array(); foreach ($arrAll as &$arr) { if ($arr['statid'] === NULL) { $arrComp[$arr['id']] = NULL; } else { $arrComp[$arr['id']][$arr['statid']] = $arr['stat_multi']; } } foreach ($arrComp as &$arr) { if ($arr === NULL) { $arr['txt'] = ''; } else { $txtBuilder = array(); foreach ($arr as $statId => $multi) { $txtBuilder[] = strtoupper($perso->getStatCode($statId)) . 'x' . $multi; } $arr['txt'] = implode(' + ', $txtBuilder); } } $tpl->set('COMP_MOD_TXT', $arrComp); return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Mj/Perso/Mod.htm'); }