$degbm = $c_Troll->getVar("DégâtsBMM"); }*/ // Regarde si le troll appartient à un ggc $sql = "SELECT id_groupe FROM ggc_troll WHERE id_troll = '" . $_SESSION['AuthTroll'] . "' AND id_groupe != 0;"; $query = mysql_query($sql, $db_vue_rm); if (mysql_error()) { echo "alert('" . mysql_error() . "');"; } if (mysql_num_rows($query) > 0) { $ggc = mysql_fetch_assoc($query); } for ($i = 0; $i < count($monsterIds); $i++) { $rang = $i * 2 + $begin; $dist = $monstersDists[$i]; $name = ereg_replace('[\\]', "", $monsterNames[$i]); $infos = getInfoFromMonstre($name); $caracs_moyennes = SelectCaracMoyMonstre($infos['id_race'], $infos['id_template'], $infos['id_age']); $caracs_spe = SelectCapSpe($infos['id_race'], $infos['id_template'], $infos['id_age']); $tab_cdm_mh = SelectCdM_mh($monsterIds[$i], $infos['id_race'], $infos['id_age']); $infos["monstre"] = addslashes($infos["monstre"]); $txtmonster = addslashes($monsterNames[$i]); $insulte = 0; // Initialisation des variables js echo "\n\t\t\t\tvar colortd = '';\t\n\t\t\t\tanchorRow = tableMonsters[{$rang}];\n\t\t\t\tanchorCellID = tableMonsters[{$rang}].childNodes[1]; // ANCHOR\n\t\t\t\tanchorCellNiv = tableMonsters[{$rang}].childNodes[2]; // ANCHOR\n\t\t\t\tanchorCellDesc = tableMonsters[{$rang}].childNodes[3]; // ANCHOR\n\t\t\t\tanchorCellPV = tableMonsters[{$rang}].childNodes[4]; // ANCHOR\n\t\t\t\tmonsterStyle = new String ( anchorCellDesc.getElementsByTagName ( 'a' )[0].getAttribute ( 'class' ) );\n\t\t\t \t\$(anchorCellID).html(\"<a class='\"+monsterStyle+\"' href='javascript:EMV({$monsterIds[$i]} ,750,550)'>{$monsterIds[$i]}</a>\");\t\n\t\t\t"; $urlmonster = "URLBestiaire + escape ('" . $infos["monstre"] . "') + '&IDAge=' + escape ('" . $infos["id_age"] . "') + '&MH={$monsterIds[$i]}'"; $mm = $rm = $dla = ""; if ($tab_cdm_mh) { $last_cdm = count($tab_cdm_mh) - 1; $titre = "cdm recoupées du monstre au " . $tab_cdm_mh[$last_cdm]['date_cdm']; $colPV = $tab_cdm_mh[$last_cdm]['nbj_cdm'] > 5 ? 1 : 0; if ($tab_cdm_mh[$last_cdm]['pdvmax_cdm'] != 999) {
function parseZone($id_troll, $cX = '', $cY = '', $cZ = '', $nCasesVue = '', $taille_distance_pa = "", $trolls_disparus) { global $db_vue_rm; global $DEV, $quadrillage, $quadrillage_delai_max; if ($DEV) { echo "DEBUG parseZone({$id_troll},{$cX},{$cY},{$cZ},{$nCasesVue},{$taille_distance_pa},{$trolls_disparus}) entré<br>\n"; } if ($taille_distance_pa == "" || $nCasesVue > $taille_distance_pa) { $taille = $nCasesVue; } else { $taille = $taille_distance_pa; } //Labyrinthe ? $laby = 0; if ($cZ == '') { $sql = "SELECT x_troll, y_troll, z_troll, maj_groupe_spec_troll, est_labyrinthe_troll"; $sql .= " FROM trolls"; $sql .= " WHERE id_troll={$id_troll}"; if ($DEV) { echo "DEBUG parseZone() {$sql} <br>"; } $res = mysql_query($sql, $db_vue_rm); echo mysql_error(); if ($res != '') { list($X, $Y, $Z, $grpspec, $laby) = mysql_fetch_array($res); } if ($DEV) { echo "DEBUG parseZone() Le troll à la position {$X},{$Y},{$Z}<br>\n"; } if ($grpspec == 'oui' && !userIsGroupSpec()) { $X = 0; $Y = 0; $Z = 0; } } else { $X = $cX; $Y = $cY; $Z = $cZ; } $miniX = $X - $taille; $maxiX = $X + $taille; $miniY = $Y - $taille; $maxiY = $Y + $taille; $miniZ = $Z - ceil($taille / 2); $maxiZ = $Z + ceil($taille / 2); $miniXv = $X - $nCasesVue; $maxiXv = $X + $nCasesVue; $miniYv = $Y - $nCasesVue; $maxiYv = $Y + $nCasesVue; $miniZv = $Z - ceil($nCasesVue / 2); $maxiZv = $Z + ceil($nCasesVue / 2); /* Brouillard de guerre */ #$sql = "SELECT id_troll_quad, UNIX_TIMESTAMP(last_seen_quad) last_seen_quad, "; #$sql .= " TO_DAYS(NOW()) - TO_DAYS(last_seen_quad) delais, x_min_quad, x_max_quad, y_min_quad,"; #$sql .= " y_max_quad , z_min_quad , z_max_quad"; #$sql .= " FROM quadrillage"; #$sql .= " WHERE "; #$sql .= " x_min_quad <= $maxiX"; #$sql .= " AND x_max_quad >= $miniX"; #$sql .= " AND y_min_quad <= $maxiY"; #$sql .= " AND y_max_quad >= $miniY"; #$sql .= " AND z_min_quad <= $maxiZ"; #$sql .= " AND z_max_quad >= $miniZ"; #if ($DEV) echo "DEBUG parseZone() QUADRILLAGE $sql <br>"; #$res=mysql_query($sql, $db_vue_rm); #echo mysql_error(); #if ($nCasesVue <= 10) { # while ($objet = mysql_fetch_assoc($res)) { # for ($i=$miniXv; $i<=$maxiXv; $i++) { # for ($j=$miniYv; $j<=$maxiYv; $j++) { # for ($k=$miniZv; $k<=$maxiZv; $k++) { # $flag = false; # # if ( ($objet['x_min_quad'] <= $i) && ($objet['x_max_quad'] >= $i) # &&($objet['y_min_quad'] <= $j) && ($objet['y_max_quad'] >= $j) # &&($objet['z_min_quad'] <= $k) && ($objet['z_max_quad'] >= $k) # ) # { # # if ($quadrillage[$i][$j][$k]['delais'] == "") { # $flag = true; # } elseif ($quadrillage[$i][$j][$k]['last_seen'] <= $objet['last_seen_quad']) { # $flag = true; # } # if ($flag) { # $quadrillage[$i][$j][$k]['delais'] = $objet['delais']; # $quadrillage[$i][$j][$k]['last_seen'] = $objet['last_seen_quad']; # $quadrillage[$i][$j][$k]['id_troll'] = $objet['id_troll_quad']; # } # } # } # } # } # } # } # Labyrinthe // $labyrinthe=""; if ($laby == 1) { $sql = "SELECT x_labyrinthe, y_labyrinthe, z_labyrinthe, type_labyrinthe "; $sql .= " FROM labyrinthe"; $sql .= " WHERE x_labyrinthe >= {$miniX}"; $sql .= " AND x_labyrinthe <= {$maxiX}"; $sql .= " AND y_labyrinthe >= {$miniY}"; $sql .= " AND y_labyrinthe <= {$maxiY}"; $sql .= " AND z_labyrinthe >= {$miniZ}"; $sql .= " AND z_labyrinthe <= {$maxiZ}"; if ($DEV) { echo "DEBUG parseZone() labyrinthe {$sql} <br>"; } $res = mysql_query($sql, $db_vue_rm); echo mysql_error(); while (list($oX, $oY, $oZ, $oType) = mysql_fetch_array($res)) { $distance_pa = calcPA($X, $Y, $Z, $oX, $oY, $oZ); $objet = array(type => $oType, z => $oZ, x => $oX, y => $oY, distance_pa => $distance_pa); $labyrinthe[$oX + 100][$oY + 100][] = $objet; } } # TROLLS $date_less_5days = date("Y-m-d H-i-s", mktime(date("H"), date("i"), date("s"), date("m"), date("d") - 5, date("Y"))); // statut_guilde 'neutre','tk','ennemie','amie','alliée' $sql = "SELECT x_troll, y_troll, z_troll, "; $sql .= " id_troll, nom_troll, race_troll, niveau_troll, guilde_troll,"; $sql .= " malade_troll, nom_guilde, statut_guilde,"; $sql .= " is_tk_troll, is_wanted_troll, is_seen_troll, UNIX_TIMESTAMP(date_troll) as date_troll"; $sql .= " FROM trolls,guildes"; $sql .= " WHERE x_troll >= {$miniX}"; $sql .= " AND x_troll <= {$maxiX}"; $sql .= " AND y_troll >= {$miniY}"; $sql .= " AND y_troll <= {$maxiY}"; $sql .= " AND z_troll >= {$miniZ}"; $sql .= " AND z_troll <= {$maxiZ}"; $sql .= " AND est_labyrinthe_troll = '{$laby}'"; $sql .= " AND guilde_troll = id_guilde"; if ($trolls_disparus == "oui") { $sql .= " AND (is_seen_troll = 'oui'"; $sql .= " OR (is_seen_troll = 'non' AND date_troll >'{$date_less_5days}'))"; } else { $sql .= " AND is_seen_troll = 'oui'"; } /*if (!userIsGroupSpec()){ $sql .= " AND maj_groupe_spec_troll <> 'oui'"; }*/ if ($DEV) { echo "DEBUG parseZone() TROLLS {$sql} <br>"; } $res = mysql_query($sql, $db_vue_rm); echo mysql_error(); while (list($tX, $tY, $tZ, $tId, $nom, $race, $level, $IdGuilde, $malade, $nom_guilde, $diplomatie, $is_tk, $is_wanted, $is_seen, $date_troll) = mysql_fetch_array($res)) { if ($malade == '-') { $malade = ""; } $distance_pa = calcPA($X, $Y, $Z, $tX, $tY, $tZ); $objet = array(id => $tId, nom => $nom, z => $tZ, race => $race, level => $level, guilde => $nom_guilde, x => $tX, y => $tY, tk => $is_tk, wanted => $is_wanted, malade => $malade, diplomatie => $diplomatie, guilde_troll => $IdGuilde, is_seen => $is_seen, date_troll => $date_troll, distance_pa => $distance_pa); $trolls[$tX + 100][$tY + 100][] = $objet; } # STREUMS $sql = "SELECT x_monstre, y_monstre, z_monstre, "; $sql .= " id_monstre, nom_monstre"; $sql .= " FROM monstres"; $sql .= " WHERE x_monstre\t >= {$miniX}"; $sql .= " AND x_monstre <= {$maxiX}"; $sql .= " AND y_monstre >= {$miniY}"; $sql .= " AND y_monstre <= {$maxiY}"; $sql .= " AND z_monstre >= {$miniZ}"; $sql .= " AND z_monstre <= {$maxiZ}"; $sql .= " AND is_seen_monstre = 'oui'"; $sql .= " AND est_labyrinthe_monstre = '{$laby}'"; if ($DEV) { echo "DEBUG parseZone() MONSTRES {$sql} <br>"; } $res = mysql_query($sql, $db_vue_rm); echo mysql_error(); while (list($mX, $mY, $mZ, $mId, $mNom) = mysql_fetch_array($res)) { unset($monstre); $mNom = stripslashes(stripslashes($mNom)); $tab = getInfoFromMonstre($mNom); $monstre[famille] = $tab['famille']; $monstre[race] = $tab['race']; $monstre[niveau] = $tab['niv']; // niveau estimé $infos_monstre = $tab; $caracs_moyennes = SelectCaracMoyMonstre($tab['id_race'], $tab['id_template'], $tab['id_age']); //if($caracs_moyennes['niv']!='?' && $caracs_moyennes['niv']!='') // $monstre[niveau]=$caracs_moyennes['niv']; // niveau calculé //else // $monstre[niveau] = $tab['niv']; // niveau estimé / Juste pour info ici $tab_cdm = ""; $monstre[connu] = 'non'; if ($infos_monstre[id_template] != "" && $infos_monstre[id_age] != "") { $tab_cdm = SelectCdMs($infos_monstre[race], $infos_monstre[id_template], $infos_monstre[id_age], "-1", "-1", true); if (count($tab_cdm) > 0) { $monstre[connu] = 'oui'; } if ($taille <= 15) { $monstre[tab_cdm] = $tab_cdm; $capacites_speciales = SelectCapSpe($tab['id_race'], $tab['id_template'], $tab['id_age']); } } $id_troll_gowap = ""; $nom_troll = ""; // On regarde si le monstre est un gowap de la guilde if (preg_match("/Gowap/", $mNom)) { $sql = " SELECT nom_troll, id_troll_gowap"; $sql .= " FROM gowaps, trolls"; $sql .= " WHERE id_troll_gowap = id_troll"; $sql .= " AND id_gowap = {$mId}"; if ($DEV) { echo "DEBUG MONSTRES {$sql} <br>"; } $result2 = mysql_query($sql, $db_vue_rm); echo mysql_error(); if (mysql_num_rows($result2) > 0) { $res2 = mysql_fetch_assoc($result2); $id_troll_gowap = $res2[id_troll_gowap]; $nom_troll = $res2[nom_troll]; } } // On regarde si le monstre est recherché (composant) $recherche = ""; $sql = " SELECT id_composant, priorite_composant, id_race_composant"; $sql .= " FROM composants"; $sql .= " WHERE id_race_composant = '" . addslashes($monstre[race]) . "'"; if ($DEV) { echo "DEBUG MONSTRES {$sql} <br>"; } $result2 = mysql_query($sql, $db_vue_rm); echo mysql_error(); if (mysql_num_rows($result2) > 0) { $res2 = mysql_fetch_assoc($result2); $recherche = $res2[priorite_composant]; } $distance_pa = calcPA($X, $Y, $Z, $mX, $mY, $mZ); $objet = array(id => $mId, nom => $mNom, z => $mZ, x => $mX, y => $mY, race => $monstre[race], famille => $monstre[famille], niveau => $monstre[niveau], connu => $monstre[connu], recherche => $recherche, id_troll_gowap => $id_troll_gowap, nom_troll => $nom_troll, infos_monstre => $infos_monstre, caracs_moyennes => $caracs_moyennes, capacites_speciales => $capacites_speciales, tab_cdm => $monstre[tab_cdm], distance_pa => $distance_pa); $streums[$mX + 100][$mY + 100][] = $objet; } # Mythiques $sql = "SELECT x_monstre, y_monstre, z_monstre, "; $sql .= " id_monstre, nom_monstre"; $sql .= " FROM monstres, best_races"; $sql .= " WHERE nom_monstre like CONCAT('%',nom_race,'%')"; $sql .= " AND commentaire like 'Mythique'"; $sql .= " AND is_seen_monstre = 'oui'"; if ($DEV) { echo "DEBUG parseZone() MYTHIQUES {$sql} <br>"; } $res = mysql_query($sql, $db_vue_rm); echo mysql_error(); while (list($oX, $oY, $oZ, $oId, $oNom) = mysql_fetch_array($res)) { $distance_pa = calcPA($X, $Y, $Z, $oX, $oY, $oZ); $objet = array(id => $oId, nom => $oNom, z => $oZ, x => $oX, y => $oY, distance_pa => $distance_pa); $mythiques[$oX + 100][$oY + 100][] = $objet; } # CAME $sql = "SELECT x_tresor, y_tresor, z_tresor, "; $sql .= " id_tresor, nom_tresor"; $sql .= " FROM tresors"; $sql .= " WHERE x_tresor >= {$miniX}"; $sql .= " AND x_tresor <= {$maxiX}"; $sql .= " AND y_tresor >= {$miniY}"; $sql .= " AND y_tresor <= {$maxiY}"; $sql .= " AND z_tresor >= {$miniZ}"; $sql .= " AND z_tresor <= {$maxiZ}"; $sql .= " AND est_labyrinthe_tresor = '{$laby}'"; if ($DEV) { echo "DEBUG parseZone() TRESOR {$sql} <br>"; } $res = mysql_query($sql, $db_vue_rm); echo mysql_error(); while (list($oX, $oY, $oZ, $oId, $oNom) = mysql_fetch_array($res)) { $distance_pa = calcPA($X, $Y, $Z, $oX, $oY, $oZ); $objet = array(id => $oId, nom => $oNom, z => $oZ, x => $oX, y => $oY, distance_pa => $distance_pa); $came[$oX + 100][$oY + 100][] = $objet; } # LIEUX $sql = "SELECT x_lieu, y_lieu, z_lieu,"; $sql .= " id_lieu, nom_lieu"; $sql .= " FROM lieux"; $sql .= " WHERE x_lieu >= {$miniX}"; $sql .= " AND x_lieu <= {$maxiX}"; $sql .= " AND y_lieu >= {$miniY}"; $sql .= " AND y_lieu <= {$maxiY}"; $sql .= " AND z_lieu >= {$miniZ}"; $sql .= " AND z_lieu <= {$maxiZ}"; $sql .= " AND est_labyrinthe_lieu = '{$laby}'"; if ($DEV) { echo "DEBUG parseZone() LIEU {$sql} <br>"; } $res = mysql_query($sql, $db_vue_rm); echo mysql_error(); while (list($lX, $lY, $lZ, $lId, $lNom) = mysql_fetch_array($res)) { $id_info = ""; $nom_info = ""; $statut_info = ""; $type_info = ""; // On regarde si la taniere est une tanière de la guilde // if (preg_match("/Tani.re de/",$lNom)) { if (preg_match("/.*\\((\\d+)\\)/", $lNom, $match)) { if (is_numeric($match[1])) { $sql = " SELECT nom_guilde, statut_guilde"; $sql .= " FROM guildes"; $sql .= " WHERE id_guilde = {$match['1']}"; $result2 = mysql_query($sql, $db_vue_rm); echo mysql_error(); if (mysql_num_rows($result2) > 0) { $res2 = mysql_fetch_assoc($result2); $id_info = $match[1]; $nom_info = $res2[nom_guilde]; $statut_info = $res2[statut_guilde]; if ($match[1] == ID_GUILDE) { $statut_info = "guilde"; } else { $statut_info = $res2[statut_guilde]; } $type_info = "guilde"; } } } // Recherche du statut dans les trolls if (preg_match("/Tani.re de .*\\((\\d+)\\)/", $lNom, $match)) { if (is_numeric($match[1])) { $sql = " SELECT nom_troll, id_troll, statut_troll, statut_guilde"; $sql .= " FROM trolls, guildes"; $sql .= " WHERE id_troll = {$match['1']}"; $sql .= " AND guilde_troll = id_guilde"; $result2 = mysql_query($sql, $db_vue_rm); echo mysql_error(); if (mysql_num_rows($result2) > 0) { $res2 = mysql_fetch_assoc($result2); $id_info = $res2[id_troll]; $nom_info = $res2[nom_troll]; if ($res2[statut_troll] != "") { $statut_info = $res2[statut_troll]; } else { $statut_info = $res2[statut_guilde]; } $type_info = "troll"; } } } // Recherche dans les tanières de guildes if (preg_match("/Tani.re de/", $lNom)) { $sql = " SELECT nom_troll, id_troll_taniere"; $sql .= " FROM tanieres, trolls"; $sql .= " WHERE id_troll_taniere = id_troll"; $sql .= " AND id_taniere = {$lId}"; if ($DEV) { echo "DEBUG LIEUX tanieres {$sql} <br>"; } $result2 = mysql_query($sql, $db_vue_rm); echo mysql_error(); if (mysql_num_rows($result2) > 0) { $res2 = mysql_fetch_assoc($result2); $id_info = $res2[id_troll_taniere]; $nom_info = $res2[nom_troll]; $statut_info = "guilde"; $type_info = "troll"; } } $distance_pa = calcPA($X, $Y, $Z, $lX, $lY, $lZ); $objet = array(id => $lId, nom => $lNom, z => $lZ, x => $lX, y => $lY, id_info => $id_info, nom_info => $nom_info, statut_info => $statut_info, is_guilde => $is_guilde, type_info => $type_info, distance_pa => $distance_pa); $lieux[$lX + 100][$lY + 100][] = $objet; } # CHAMPIGNONS $sql = "SELECT x_champi, y_champi, z_champi,"; $sql .= " id_champi, nom_champi"; $sql .= " FROM champignons"; $sql .= " WHERE x_champi >= {$miniX}"; $sql .= " AND x_champi <= {$maxiX}"; $sql .= " AND y_champi >= {$miniY}"; $sql .= " AND y_champi <= {$maxiY}"; $sql .= " AND z_champi >= {$miniZ}"; $sql .= " AND z_champi <= {$maxiZ}"; $sql .= " AND is_seen_champi ='oui'"; $sql .= " AND est_labyrinthe_champi = '{$laby}'"; if ($DEV) { echo "DEBUG parseZone() CHAMPI {$sql} <br>"; } $res = mysql_query($sql, $db_vue_rm); echo mysql_error(); while (list($cX, $cY, $cZ, $cId, $cNom) = mysql_fetch_array($res)) { $objet = array(id => $cId, nom => $cNom, z => $cZ, x => $cX, y => $cY); $champi[$cX + 100][$cY + 100][] = array(id => $cId, nom => $cNom, z => $cZ); } # BARONNIES /* $sql = "SELECT x_deb_baronnie, y_deb_baronnie, z_deb_baronnie,"; $sql .= " x_fin_baronnie, y_fin_baronnie, z_fin_baronnie,"; $sql .= " x_trone_baronnie, y_trone_baronnie, z_trone_baronnie,"; $sql .= " nom_baronnie, id_baron_baronnie, id_baronnie,nom_troll as nom_baron, "; $sql .= " img_drapeau_baronnie, img_mini_blason_baronnie"; $sql .= " FROM baronnies,trolls"; $sql .= " WHERE x_fin_baronnie >= $miniX"; $sql .= " AND x_deb_baronnie <= $maxiX"; $sql .= " AND y_fin_baronnie >= $miniY"; $sql .= " AND y_deb_baronnie <= $maxiY"; $sql .= " AND z_fin_baronnie >= $miniZ"; $sql .= " AND z_deb_baronnie <= $maxiZ"; $sql .= " AND id_troll = id_baron_baronnie"; if ($DEV) echo "DEBUG parseZone() BARONNIE $sql <br>"; $res=mysql_query($sql, $db_vue_rm); echo mysql_error(); while (list( $x_deb_baronnie, $y_deb_baronnie, $z_deb_baronnie, $x_fin_baronnie, $y_fin_baronnie, $z_fin_baronnie, $x_trone_baronnie, $y_trone_baronnie, $z_trone_baronnie, $nom_baronnie, $id_baron_baronnie, $id_baronnie, $nom_baron, $img_drapeau_baronnie, $img_mini_blason_baronnie )=mysql_fetch_array($res)) { $distance_pa = calcPA($X,$Y,$Z,$x_trone_baronnie,$y_trone_baronnie,$z_trone_baronnie); $objet=array( x_deb_baronnie=>$x_deb_baronnie, y_deb_baronnie=>$y_deb_baronnie, z_deb_baronnie=>$z_deb_baronnie, x_fin_baronnie=>$x_fin_baronnie, y_fin_baronnie=>$y_fin_baronnie, z_fin_baronnie=>$z_fin_baronnie, x_trone_baronnie=>$x_trone_baronnie, y_trone_baronnie=>$y_trone_baronnie, z_trone_baronnie=>$z_trone_baronnie, nom_baronnie=>$nom_baronnie, id_baron_baronnie=>$id_baron_baronnie, id_baronnie=>$id_baronnie, nom_baron=>$nom_baron, img_drapeau_baronnie=>$img_drapeau_baronnie, img_mini_blason_baronnie=>$img_mini_blason_baronnie, distance_pa=>$distance_pa ); $baronnies[$x_trone_baronnie+100][$y_trone_baronnie+100][]=$objet; } */ /* On retourne la position et le numéro */ $tab[t_quadrillage] = $quadrillage; $tab[t_trolls] = $trolls; $tab[t_monstres] = $streums; $tab[t_mythiques] = $mythiques; $tab[t_lieux] = $lieux; $tab[t_tresors] = $came; $tab[t_champignons] = $champi; $tab[t_laby] = $labyrinthe; //$tab[t_baronnies] = $baronnies; $tab[max_pa] = $taille_distance_pa; $tab[taille_vue] = $nCasesVue; $tab[x_position] = $X; $tab[y_position] = $Y; $tab[z_position] = $Z; $tab[trolls_disparus] = $trolls_disparus; if ($id_troll != "") { $tab[myTroll] = getTroll($id_troll); } return $tab; }
function selectDbRechercheMonstres($id_monstre, $nom_monstre = "", $x_monstre = "", $y_monstre = "", $z_monstre = "", $limite = "", $race = "", $famille = "", $niveau = "") { global $db_vue_rm; $i = 1; $sql = "SELECT id_monstre, nom_monstre,"; $sql .= " x_monstre, y_monstre, z_monstre, date_monstre"; $sql .= " FROM monstres"; // juste pour utiliser le where pour pas m'embetter avec après ! :) // à revoir surement... $sql .= " WHERE date_monstre != ''"; if ($x_monstre != "" && $y_monstre != "" && $z_monstre != "" && $limite != "") { $x_max = $x_monstre + $limite; $x_min = $x_monstre - $limite; $y_max = $y_monstre + $limite; $y_min = $y_monstre - $limite; $z_max = $z_monstre + $limite; $z_min = $z_monstre - $limite; $sql .= " AND x_monstre >= {$x_min}"; $sql .= " AND x_monstre <= {$x_max}"; $sql .= " AND y_monstre >= {$y_min}"; $sql .= " AND y_monstre <= {$y_max}"; $sql .= " AND z_monstre >= {$z_min}"; $sql .= " AND z_monstre <= {$z_max}"; } if ($id_monstre != "") { $sql .= " AND id_monstre like '%{$id_monstre}%'"; } if ($nom_monstre != "") { $sql .= " AND lower(nom_monstre) like '%" . strtolower($nom_monstre) . "%'"; } $sql .= " ORDER BY nom_monstre "; if (!($result = mysql_query($sql, $db_vue_rm))) { echo mysql_error(); echo "<br>chaine sql = {$sql}<br>"; } else { while ($monstre = mysql_fetch_assoc($result)) { if (is_numeric($x_monstre) && is_numeric($y_monstre) && is_numeric($z_monstre)) { $lesMonstres[$i]['distance_pa'] = calcPA($x_monstre, $y_monstre, $z_monstre, $monstre[x_monstre], $monstre[y_monstre], $monstre[z_monstre]); } unset($tab); $mNom = stripslashes(stripslashes($monstre['nom_monstre'])); $tab = getInfoFromMonstre($mNom); $infos_monstre = $tab; $caracs_moyennes = SelectCaracMoyMonstre($tab['id_race'], $tab['id_template'], $tab['id_age']); //if($caracs_moyennes['niv']!='?' && $caracs_moyennes['niv']!='') // $tab['niv']=$caracs_moyennes['niv']; // niveau calculé //else // $tab['niv']=$tab['niv']; // niveau estimé if ($niveau != "") { if ($niveau != $tab['niv'] && $niveau + 1 != $tab['niv'] && $niveau - 1 != $tab['niv']) { continue; } } if ($race != "") { //if ($tab['race'] != $race) if (!preg_match("/" . strtolower($race) . "/", strtolower($tab['race']))) { continue; } } if ($famille != "") { //if ($tab['famille'] != $famille) if (!preg_match("/" . strtolower($famille) . "/", strtolower($tab['famille']))) { continue; } } $lesMonstres[$i]['niveau'] = $tab['niv']; // niveau estim $lesMonstres[$i]['race'] = $tab['race']; $lesMonstres[$i]['famille'] = $tab['famille']; $lesMonstres[$i]['id_monstre'] = $monstre['id_monstre']; $lesMonstres[$i]['nom_monstre'] = $monstre['nom_monstre']; $lesMonstres[$i]['x_monstre'] = $monstre['x_monstre']; $lesMonstres[$i]['y_monstre'] = $monstre['y_monstre']; $lesMonstres[$i]['z_monstre'] = $monstre['z_monstre']; $lesMonstres[$i]['date_monstre'] = $monstre['date_monstre']; $i++; } } return $lesMonstres; }
function parseMonsters($array) { $retour = ""; $retour["id"] = trim($array[0]); $retour["name"] = trim($array[1]); $retour["X"] = trim($array[2]); $retour["Y"] = trim($array[3]); $retour["N"] = trim($array[4]); $monstre = getInfoFromMonstre($retour["name"]); $retour["level"] = estimeNivMonstre($monstre["race"], $monstre["id_template"], $monstre["id_age"]); return $retour; }