convertlog recreatelog potions plantes stats_clan zn_distance stats_kill cartfidel common_function sources outils

Source du fichier potions.php :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
 <head>
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-15">
    <meta name="KEYWORDS" content="heroes,chronicles,HC,potion,potions,PV,calculateur">
        <title>Calculateur des PV de son stock de potions - HC</title>
        <?php require_once('common_function.php'); include('designhc.html'); ?>
 </head>
  <body><?php include 'outils.php' ?>
  <div id="title">
     <a href="<?php echo query_strip(); ?>"><img src="fp.gif" alt="Lien original" id="accueil" title="Retour au lien original" /></a>
     Calculateur des PV de son stock de potions v1.2 <span id="by">(par LittleBoss)</span></div>
  <div id="entete">Cet outil permet de calculer automatiquement les PV de son stock de potions et poisons de <a href="http://heroeschronicles.nainwak.org/">Heroes Chronicles</a>.
  <br />Entrer votre stock de potion/poisons ci dessous (mélanger les deux ne fonctionnera pas).
  <br />Vous pouvez indiquer des paliers pour savoir combien de potions/poisons vous avez dans des intervalles de PV 
  <br />Indiquer des paliers négatifs pour les poisons.
  </div>
<?php

if(isset($_POST['log']) && strlen(trim($_POST['log'])) > 0)  // ne faire que si valider a été cliqué ET SI C'EST PAS VIDE ;)
{
  
    // définition des variables contenant les balises, fonction secur_ent défini en bas du fichier
    $log = ''; // variable qui contiendra le log final
    
    $p1=secur_ent($_POST['p1']);
    $p2=secur_ent($_POST['p2']);    
    $p3=secur_ent($_POST['p3']);    
    $p4=secur_ent($_POST['p4']);
    if (!is_numeric($p1)) { $p1 = 0; }
    if (!is_numeric($p2)) { $p2 = 0; }
    if (!is_numeric($p3)) { $p3 = 0; }
    if (!is_numeric($p4)) { $p4 = 0; }
    if ($p1 || $p2 || $p3 || $p4) { 
        if (!$p4) { $p4 = 'max';
            if (!$p3) { $p3 = 'max'; $p4 = 0;
                if (!$p2) { $p2 = 'max'; $p3 = 0; }
            }
        }
    }
    

    $fichier_log = explode("\n", $_POST['log']);

    // boucle qui étudie chaque ligne du log pour le mettre en forme
    $pv = 0; $type = ''; $pv_bact = 0; $pv_mega = 0; $pv_ultra = 0; $pv_jansen = 0;
    $pv_tot = 0; $pv_norm = 0; $pv_champ = 0; $pv_oeuf = 0; $pv_off = 0; 
    $pal0 = 0; $pal1 = 0; $pal2 = 0; $pal3 = 0; $pal4 = 0;
    $nb_bact = 0; $nb_mega = 0; $nb_ultra = 0; $nb_jansen = 0; $nb_tot = 0; $nb_norm = 0; $nb_champ = 0; $nb_oeuf = 0; $nb_off = 0;
    $nb_pal0 = 0; $nb_pal1 = 0; $nb_pal2 = 0; $nb_pal3 = 0; $nb_pal4 = 0;
    foreach($fichier_log as $lignei) {
        $lignei = trim($lignei); $pv = 0; $offert = FALSE;
        if($lignei) { // si la ligne i est non vide
            if (preg_match('`\(\+(\d+)pv\) \(offert`', $lignei,$match)) { $pv = $match[1]; $type = 'champ'; $offert = TRUE; }
            elseif (preg_match('`\(\+(\d+)pv\)`', $lignei,$match)) { $pv = $match[1]; $type = 'champ'; }
            elseif (preg_match('`Soigne (\d+) points de vie \(offert`', $lignei,$match)) { $pv = $match[1]; $type = 'normal'; $offert = TRUE; }
            elseif (preg_match('`Soigne (\d+) points de vie`', $lignei,$match)) { $pv = $match[1]; $type = 'normal'; }
            elseif (preg_match('`Un Oeuf coloré \- donne (\d+)PV \(offert`', $lignei,$match)) { $pv = $match[1]; $type = 'oeuf'; $offert = TRUE; }
            elseif (preg_match('`Un Oeuf coloré \- donne (\d+)PV`', $lignei,$match)) { $pv = $match[1]; $type = 'oeuf'; }
            elseif (preg_match('`Jansen Sp.{2,10}Un breuvage de mauvet film \(offert`', $lignei,$match)) { $pv = 200; $type = 'jansen'; $offert = TRUE; }
            elseif (preg_match('`Jansen Sp.{2,10}Un breuvage de mauvet film`', $lignei,$match)) { $pv = 200; $type = 'jansen'; }
            elseif (preg_match('`Enleve (-\d+) points de vie \(offert`', $lignei,$match)) { $pv = $match[1]; $type = 'normal'; $offert = TRUE; }
            elseif (preg_match('`Enleve (-\d+) points de vie`', $lignei,$match)) { $pv = $match[1]; $type = 'normal'; }
        }
        //print_r($match); echo "$pv <br />";
        if ($pv != 0) {
            $pv_tot += $pv; $nb_tot++;
            if ($offert) { $pv_off += $pv; $nb_off++; }
            if ($type == 'champ') { $pv_champ += $pv; $nb_champ++; }
            if ($type == 'oeuf') { $pv_oeuf += $pv; $nb_oeuf++; }
            if ($type == 'jansen') { $pv_jansen += $pv; $nb_jansen++; }
            elseif ($type == 'normal') {
                if ($pv == 100) { $pv_bact += 100; $nb_bact++; }
                elseif ($pv == 200) { $pv_mega += 200; $nb_mega++; }
                elseif ($pv == 400) { $pv_ultra += 400; $nb_ultra++; }
                else {
                    $pv_norm += $pv; $nb_norm++;
                    if ($p1 AND $pv < $p1) { $pal0 += $pv; $nb_pal0++; }
                    elseif ($p2 || $p1<0 AND $pv >= $p1 && ($p2 == 'max' || $pv <$p2)) { $pal1 += $pv; $nb_pal1++; }
                    elseif ($p3 || $p2<0 AND $pv >= $p2 && ($p2 == 'max' || $pv <$p3)) { $pal2 += $pv; $nb_pal2++; }
                    elseif ($p4 || $p3<0 AND $pv >= $p3 && ($p2 == 'max' || $pv <$p4)) { $pal3 += $pv; $nb_pal3++; }
                    elseif ($p4 AND $pv >= $p4) { $pal4 += $pv; $nb_pal4++; }
                }
            }
        }
    } 
    if ($pv_tot < 0) { $type = 'poisons'; }
    else { $type = 'potions'; }
    //echo "$p1 - $p2 - $p3 - $p4<br />";
    ($nb_ultra > 0)? $ultra = "<br />- $nb_ultra ultra potions pour $pv_ultra PV" : $ultra='';
    ($nb_jansen > 0)? $jansen = "<br />- $nb_jansen potions de Jansen pour $pv_jansen PV" : $jansen='';
    if ($type == 'potions') {
        echo "Vous avez un total de $nb_tot potions pour $pv_tot Points de vie de potion, dont :
        <br />- $nb_champ potions alcolisés pour $pv_champ PV
        $ultra
        <br />- $nb_mega mégas potions pour $pv_mega PV
        $jansen
        <br />- $nb_bact potions de bactic pour $pv_bact PV
        <br />- $nb_oeuf oeufs pour $pv_oeuf PV
        <br />- $nb_norm potions restantes pour $pv_norm PV
        <br />Ceci inclu $nb_off potions offertes pour $pv_off PV.<br />";
    }
    else { 
        echo "Vous avez un total de $nb_tot poisons pour $pv_tot Points de vie de poisons
        <br />Ceci inclu $nb_off poisons offerts pour $pv_off PV.<br />";
    }
    if ($p1 || $p2 || $p3 || $p4) {
        
        if ($type == 'potions') { $palier = "<br />Parmis le reste des potions, vous avez :"; }
        else { $palier = "<br />Parmis ces poisons, vous avez :"; }
        if ($pal0) $palier .= "<br />- $nb_pal0 $type pour $pal0 PV de $type dans l'intervalle \[min;$p1\[";
        if ($pal1) $palier .= "<br />- $nb_pal1 $type pour $pal1 PV de $type dans l'intervalle \[$p1;$p2\[";
        if ($pal2) $palier .= "<br />- $nb_pal2 $type pour $pal2 PV de $type dans l'intervalle \[$p2;$p3\[";
        if ($pal3) $palier .= "<br />- $nb_pal3 $type pour $pal3 PV de $type dans l'intervalle \[$p3;$p4\[";
        if ($pal4) $palier .= "<br />- $nb_pal4 $type pour $pal4 PV de $type dans l'intervalle \[$p4;max\[";
        echo stripslashes($palier);
    }
/*
    if (isset($_POST['logurl'])) { // calcul l'url direct avec les paramètres de couleurs choisis
        if ($coup != $dcoup) { $url .= $et . 'coup=' . $coup; $et = '\&'; }
        if (preg_match('`.{4,}`', $url)) {
            echo '________________________________'. '<br />';
            $urlg = 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"];
            $urlg .= stripslashes($url);
            ?>
            Pour garder votre configuration de couleur, garder <a href="<?php echo $urlg ?>">ce lien</a> dans vos marques pages. <br /><br />
            <?php
        }
        
    }
*/
}
elseif (isset($_POST['log'])) {
    echo 'Erreur : vous n\'avez pas rempli le log<br />'; 
}
?>
<!-- Création de la zone de texte pour entrer le log  -->
<form action="<?php echo $_SERVER["REQUEST_URI"]; ?>" method="post">
    <p><input type="submit" value="Valider" /></p>
    <p><label>Palier 1 : <input type="text" size="5" name="p1" value=''></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <label>Palier 2 : <input type="text" size="5" name="p2" value=''></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <label>Palier 3 : <input type="text" size="5" name="p3" value=''></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <label>Palier 4 : <input type="text" size="5" name="p4" value=''></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    </p>
    <p><textarea name="log" rows="20" cols="80" ></textarea></p>
    <p><input type="submit" value="Valider" /></p>
</form>
<p></p>
 <div id="changelog"><br />Changelog :
 <br />1.2 :
 <br />- Modification graphique
 <br />1.1 :
 <br />- Ajout de l'ultra potion et de la potion de Jansen
 </div>

</body>
</html>
<?php
    
?>