403Webshell
Server IP : 109.234.162.214  /  Your IP : 216.73.216.222
Web Server : Apache
System : Linux servd162214.srv.odns.fr 4.18.0-372.26.1.lve.1.el8.x86_64 #1 SMP Fri Sep 16 14:08:19 EDT 2022 x86_64
User : carpe ( 1178)
PHP Version : 8.0.30
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/carpe/public_html/CURSED/V3/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/carpe/public_html/CURSED/V3/cursedV3.php
<?php

session_start();
if(isset($_SESSION['login'])){
    
}else{
    header("Location: first.php");
}

if(isset($_POST['decon_x'])){

    if (isset($_SESSION['login'])) {
        unset($_SESSION['login']);
        session_destroy();
        header("Location: first.php");
    }
}

if(isset($_POST['finito'])){

    include '../database.php';
    $database = new Database();
    $connexion = $database->getConnection();

    if (isset($_SESSION['login'])) {
        $username = $_SESSION['login'];
        
        $sql = "DELETE FROM `users` WHERE pseudo = '$username'";
        $statement = $connexion->prepare($sql);
        $statement->execute();
        
        $sql = "SELECT * from users where pseudo = '$username'";
        $statement = $connexion->prepare($sql);
        $statement->execute();
                    
        $results = $statement->fetchAll(PDO::FETCH_ASSOC);
        foreach ($results as $row) {
            $id = $row['id_user'];
        }
        
        $sql = "DELETE FROM `inv` WHERE id_user = '$id'";
        $statement = $connexion->prepare($sql);
        $statement->execute();
        
        
        unset($_SESSION['login']);
        session_destroy();
        header("Location: first.php");
        
        
        
    }
}


?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CURSED</title>
    <link rel="icon" type="image/png" href="images/coin2.png">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Pixelify+Sans:wght@400..700&display=swap" rel="stylesheet">
    
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Pixelify+Sans:wght@400..700&family=VT323&display=swap" rel="stylesheet">
<style>
    body{
        width:100%;
        height:100vh;
        background:url('images/texture.png');
        background-size:cover;
        margin:0;
        padding:0;
        font-family: "Pixelify Sans", serif;
        font-optical-sizing: auto;
        font-weight: <weight>;
        font-style: normal;
        position:fixed;
    }
    
    #menu_principal{
        width:28%;
        height:100%;
        position:relative;
        z-index:10;
        min-width:450px;
        background:url('images/texture.png');
        background-size:cover;
        box-shadow: 8px 0px 2px 1px rgba(0, 0, 0, 0.5);
        overflow-y:auto;
        overflow-x:hidden;
    }
    
    
    
    #canvas{
        position:absolute;
        width:1200px;
        height:780px;
        top:50%;
        left:60%;
        transform:translate(-50%,-50%);
        background-image:url('images/skyV2.png');
    	background-size:cover;
    	background-position:center;
    	image-rendering: pixelated;
    	overflow:hidden;
    	border:4px #543626 solid;
    	box-shadow: 8px 8px 2px 1px rgba(0, 0, 0, 0.5);
    }

    #east{
        position:absolute;
        width:1200px;
        height:780px;
        top:50%;
        left:60%;
        transform:translate(-50%,-50%);
        background:#252525;
    	image-rendering: pixelated;
    	overflow:hidden;
    	border:4px #543626 solid;
    	box-shadow: 8px 8px 2px 1px rgba(0, 0, 0, 0.5);
    	display:none;
    	background:url('images/prison2.png');
    	background-size:cover;
    }
    
    #talk_again{
        width:800px;
        height:200px;
        background-image:url('images/Vector10.png');
    	background-size: 100% 100%;
        background-repeat: no-repeat; /* Pour éviter la répétition */
        background-position: center;
        position:absolute;
        left:50%;
        bottom:10%;
        transform:translate(-50%);
        display:flex;
        justify-content:center;
        align-items:center;
        gap:10px;
    }
    
    .bord1{
        height:80%;
        image-rendering: pixelated;
    }
    
    #premiere{
        height:100%;
    }
    
    #premiere img{
        height:50%;
        margin-top:25px;
    }
    
    #premiere h2{
        margin:0;
        border:0;
        font-size:1.2rem;
        color:#543626;
    }
    
    #seconde{
        width:40%;
        height:90%;
        overflow:auto;
        position:relative;
    }
    
    #seconde a{
        text-decoration:underline;
    }
    
    #him{
        
    }
    
    #you9{
        position:absolute;
        bottom:0;
        
    }
    
    #discuss2 p{
        color:#543626;
        font-weight:800;
        margin:0;
        margin-top:5px;
        
    }
    
    #discuss2 h3{
        padding:0;
        margin:0;
        margin-top:5px;
        
    }
    
    #you9:hover{
        text-decoration:underline;
        cursor:pointer;
    }
    
    #seconde h3{
        width:90%;
        font-size:1rem;
        color:#543626;
    }
    
    #talk_again div{
        
    }
    
    #troisieme{
        width:30%;
    }
    
    #troisieme h1{
        color:#543626;
        font-size:1.2rem;
        text-decoration:underline;
        padding:0;
        margin:0;
        margin-top:10px;
    }
    
    #troisieme h3{
        color:#543626;
        font-size:1rem;
        padding:0;
        margin:0;
        margin-top:10px;
    }
    
    #left10{
        cursor:pointer;
    }
    
    #eau{
        position:absolute;
        left:0;
        width:100%;
        z-index:2;
        bottom:0px;
    }
    
    #radeau{
        width:220px;
        height:120px;
        position:absolute;
        bottom:70px;
        z-index:4;
        left:400px;
    }
    

    
    #texture_map{
        width:97%;
        height:100%;
        background:#BCA489;
        
    }
    .logo{
        position:relative;
        left:42px;
        top:10px;
        width:80%;
    }
    
    .titre1{
        position:relative;
        left:35px;
        text-decoration:underline;
        color:#543626;
    }
    
    #infos_perso{
        margin-left:30px;
        margin-right:30px;
        display:flex;
        align-items:center;
        justify-content:space-between;
        gap:20px;
    }
    
    #infos_right{
        display:flex;
        flex-wrap:wrap;
        gap:15px;
    }
    
    .infos{
        display:flex;
        align-items:center;
        margin:0;
        width:100%;
        gap:5px;
    }
    
    .infos img{
        width:25px;
    }
    
    .infos h2{
        margin:0;
        padding:0;
        color:#543626;
    }
    
    .infos_cont{
        display:flex;
        justify-content:space-between;
        align-items:center;
        width:100%;
        position:relative;
    }
    
    #inventaire{
        padding-left:35px;
        margin:50px;
        margin-top:0px;
        width:73%;
        height:160px;
        background:url('images/texture_inv.png');
        background-size: 100% 100%;
        background-repeat: no-repeat; /* Pour éviter la répétition */
        background-position: center;
        padding-top:30px;
        position:relative;
        display:flex;
        flex-wrap:wrap;
        gap:25px;
        align-items:start;
        overflow:auto;
        padding-bottom:40px;
        margin-bottom:0;
    }
    
    #titre_inv{
        background:url('images/texture_texte.png');
        background-size: 100% 100%;
        background-repeat: no-repeat; /* Pour éviter la répétition */
        background-position: center;
        display:inline;
        padding:5px 15px 5px 15px;
        color:#543626;
        position:relative;
        top:10px;
        left:30%;
        transform:translate(-50%);
        z-index:1001;
    }
    
    #inventaire div .hey{
        width:90%;
        
    }
    
    #inventaire div{
        background:url('images/case.png');
        background-size: 100% 100%;
        background-repeat: no-repeat; /* Pour éviter la répétition */
        background-position: center;
        width:25%;
        height:80px;
        display:flex;
        justify-content:center;
        align-items:center;
        position:relative;
        cursor:pointer;
        transition:.5s all;
    }
    #inventaire div:hover{
        transform:scale(1.05);
        transition:.5s all;
    }
    
    #bip{
        position:absolute;
        left:400px;
        z-index:1002;
    }
    
    .fishing_astuce img{
        width:30px;
        z-index:1003;
        position:relative;
        top:-10px;
    }
    
    .fishing_astuce p{
        width:300px;
        color:#543626;
        background:#BCA489;
        padding:10px 15px 10px 15px;
         background:url('images/texture_texte.png');
        background-size: 100% 100%;
        background-repeat: no-repeat; /* Pour éviter la répétition */
        background-position: center;
        position:absolute;
        top:-10px;
        left:20px;
        z-index:1002;
        display:none;
    }
    
    #info_bateau{
        width:160px;
    }
    
    #error_message{
        display:none;
    }
    
    #error_mess{
        display:none;
    }
    
    #money{
        margin-left:40px;
        margin-right:40px;
        margin-top:10px;
        display:flex;
        align-items:center;
        gap:20px;
        justify-content:center;
        width:80%;
        color:#543626;
    }
    
    #quests{
        margin-left:40px;
        width:84%;

        color:#543626;
        position:relative;
    }
    

    
    #quests div{
        display:flex;
        justify-content:space-around;
        align-items:center;
        margin:10px;
        gap:10px;
    }
    
    #quests div h3{
        margin:0;
        padding:0;
    }
    
    #sauvegarder{
        background:url('images/save.png');
        background-size: 100% 100%;
        background-repeat: no-repeat; /* Pour éviter la répétition */
        background-position: center;
        display:inline;
        position:relative;
        left:24%;
        transform:translate(-50%);
        color:#BCA489;
        text-decoration:underline;
        padding:10px 20px 10px 20px;
        top:20px;
        cursor:pointer;
        transition:.5s all;
    }
    
    #sauvegarder:hover{
        font-size:2.1rem;
    }
    
    @media screen and (max-width: 1100px) {
        #responsive{
            width:100%;
            height:100%;
            z-index:999;
            backdrop-filter: blur(3px);
            background: rgba(255, 255, 255, 0.2);
            position:absolute;
            display:flex;
            justify-content:center;
            align-items:center;
        }
        
        #error_message{
            display:block;
            background:red;
            margin:30px;
            text-align:center;
            height:30%;
            display:flex;
            flex-wrap:wrap;
            justify-content:center;
            align-items:center;
            background:url('images/bg.png');
            background-size: 100% 100%;
            background-repeat: no-repeat; /* Pour éviter la répétition */
            background-position: center;
            padding:10px;
            color:#543626;
            position:relative;
        }
        
        #error_mess{
            display:block;
            position:absolute;
            z-index:1000;
            top:-10px;
            right:-10px;
            width:50Px;
        }
        
        body{
            position:fixed;
        }
    }
    
    #deco{
        position:absolute;
        bottom:35px;
        left:35px;
        z-index:1003;
        width:50px;
        
    }

    
    #bip2{

        left:340px;
        position:relative;
        bottom:30px;
        

    }
    
    #bip3{
        right:-20px;
        position:absolute;
        top:-20px;
        display:none;
    }

    
    #prix6{
        font-family: "VT323", serif;
          font-weight: 1200;
          font-style: normal;
          font-size:1.8rem;
          margin:0;
          padding:0;
    }
    
    #prix5{
        font-family: "VT323", serif;
          font-weight: 1200;
          font-style: normal;
          font-size:1.8rem;
          margin:0;
          padding:0;
    }
    
    .contain2 div{
        font-family: "VT323", serif;
          font-weight: 1200;
          font-style: normal;
          font-size:1.2rem;
    }
    
    #golds{
        font-family: "VT323", serif;
          font-weight: 1200;
          font-style: normal;
          font-size:2.6rem;
          margin:0;
          padding:0;
    }
    
    #fishing_road{
        position:absolute;
        z-index:100;
        left:584px;
        bottom:65px;
        width:130px;
        display:none;
    }
    #fishing_road0{
        position:absolute;
        z-index:100;
        left:584px;
        bottom:65px;
        width:130px;
        display:none;
        transition:.5s bottom;
    }
    
    #fished{
        position:absolute;
        bottom:20px;
        left:45%;
        transform:translate(-50%);
        z-index:101;
        font-size:1.3rem;
        background-image:url('images/texture_texte.png');
        background-size: 100% 100%;
        background-repeat: no-repeat; /* Pour éviter la répétition */
        background-position: center;
        padding:10px 15px 15px 15px;
        text-align:center;
        color:#50321d;
        cursor:pointer;
        transition:.5s all;
        display:none;
    }
    
    .quant{
        position:absolute;
        top:-10px;
        left:-10px;
        width:30px;
        z-index:1;
    }

    .quantite{
        position:absolute;
        top:-7px;
        left:0px;
        z-index:2;
        margin:0;
        padding:0;
        color:#50321d;
        font-family: "VT323", serif;
          font-weight: 1200;
          font-style: normal;
          font-size:1.6rem;
    }  
    
    .quantite2{
        position:absolute;
        top:-7px;
        left:-3px;
        z-index:2;
        margin:0;
        padding:0;
        color:#50321d;
        font-family: "VT323", serif;
          font-weight: 1200;
          font-style: normal;
          font-size:1.6rem;
    }    
    
    #clouds{
        position:absolute;
        top:-100px;
    }
    
    #clouds2{
        position:absolute;
        left:1200px;
        top:-100px;
    }
    
    #map2{
        width:70%;
        position:absolute;
        z-index:100;
        left:50%;
        top:50%;
        transform:translate(-50%,-50%);
        display:none;
    }
    
    #journal2{
        width:40%;
        position:absolute;
        z-index:100;
        left:50%;
        top:50%;
        transform:translate(-50%,-50%);
        display:none;
    }
    
    #lettre2{
        width:40%;
        position:absolute;
        z-index:100;
        left:50%;
        top:50%;
        transform:translate(-50%,-50%);
        display:none;
    }
    
    #notifs{
        position:absolute;
        bottom:20px;
        font-size:1.6rem;
        left:55%;
        transform:translate(-50%);
        color:#986623;
        
    }
    
    #ile{
        width:600px;
        position:absolute;
        bottom:125px;
        z-index:2;
        left:1200px;
    }
    
    #menu_ile{
        width:25%;
        height:100%;
        position:absolute;
        z-index:10;
        min-width:400px;
        right:0;
        background:url('images/texture.png');
        background-size:cover;
        box-shadow: -8px 0px 2px 1px rgba(0, 0, 0, 0.5);
        display:none;
        overflow:auto;
    }
    
    #ile_name{
        color:#BCA489;
        text-decoration:underline;
        margin:20px;
        font-size:2.4rem;
    }
    
    #ile_desc{
        margin:20px;
        width:80%;
        background-image:url('images/texture_ile_1.png');
        background-size: 100% 100%;
        background-repeat: no-repeat; /* Pour éviter la répétition */
        background-position: center;
        padding:15px;
        color:#543626;
        font-weight:600;
        height:100px;
        overflow:auto;
    }
    
    #menu_buy{
        margin-left:22px;
        margin-top:10px;
    }
    
    #titres_buy{
        display:flex;
        margin:0;
    }
    
    #contain_buy{
        padding-top:20px;
        width:356px;
        height:180px;
         background-image:url('images/contain_buy.png');
        background-size: 100% 100%;
        background-repeat: no-repeat; /* Pour éviter la répétition */
        background-position: center;
        z-index:3;
        position:relative;
        bottom:25px;
        display:flex;
        overflow:auto;
        flex-wrap:wrap;
        gap:25px;
        align-items:start;
        padding-bottom:30px;
        padding-left:15px;

    }
    
    .contain1{
        display:flex;
        align-items:start;
        gap:20px;
        color:#543626;
        width:95%;
        position:relative;
    }
    
    .achet{
        color:#BCA489;
        text-decoration:none;
        cursor:pointer;
        background:url('images/save.png');
        background-size: 100% 100%;
        background-repeat: no-repeat; /* Pour éviter la répétition */
        background-position: center;
        text-align:center;
    }
    
    .vend{
        color:#BCA489;
        text-decoration:none;
        cursor:pointer;
        background:url('images/save.png');
        background-size: 100% 100%;
        background-repeat: no-repeat; /* Pour éviter la répétition */
        background-position: center;
        text-align:center;
    }
    
    .contain2{
    }
    
    .contain2 div{
        display:flex;
        gap:5px;
    }
    
    .contain1 h2{
        margin:0;
        padding:0;
        
        text-decoration:underline
    }
    
    .contain1 h3{
        margin:0;
        padding:0;
    }
    .g{
        cursor:pointer;
    }
    
    .d{
        cursor:pointer;
    }
    
    #contain_buy div img{
        width:100px;
        height:100px;
        background-image:url('images/case_buy.png');
        background-size: 100% 100%;
        background-repeat: no-repeat; /* Pour éviter la répétition */
        background-position: center;
    }
    
#contain_sell div img{
        width:100px;
        height:100px;
        background-image:url('images/case_sell.png');
        background-size: 100% 100%;
        background-repeat: no-repeat; /* Pour éviter la répétition */
        background-position: center;
    }


    
 #contain_sell{
        padding-top:20px;
        width:356px;
        height:180px;
         background-image:url('images/contain_sell.png');
        background-size: 100% 100%;
        background-repeat: no-repeat; /* Pour éviter la répétition */
        background-position: center;
        z-index:3;
        position:relative;
        bottom:25px;
        display:flex;
        overflow:auto;
        flex-wrap:wrap;
        gap:25px;
        align-items:start;
        padding-bottom:30px;
        padding-left:15px;
        display:none;

    }
    
    #buy{
        margin:0;
        background-image:url('images/buy.png');
        background-size: 100% 100%;
        background-repeat: no-repeat; /* Pour éviter la répétition */
        background-position: center;
        padding:5px 30px 25px 30px;
        color:#543626;
        text-decoration:underline;
        z-index:2;
        position:relative;
        cursor:pointer;
    }
    
    #sell{

        margin:0;
        background-image:url('images/sell.png');
        background-size: 100% 100%;
        background-repeat: no-repeat; /* Pour éviter la répétition */
        background-position: center;
        padding:5px 35px 30px 39px;
        color:#543626;
        text-decoration:underline;
        z-index:1;
        position:relative;
        right:10px;
        cursor:pointer;
    }
    
    #repair{
        color:#D7B68F;
        text-decoration:underline;
        margin-left:25px;
        cursor:pointer;
    }
    
    #food2{
        color:#D7B68F;
        text-decoration:underline;
        margin-left:25px;
        cursor:pointer;
    }
    
    #contain_repair{
        display:flex;
        align-items:center;
        gap:10px;
        color:#D7B68F;
        
    }
    
    #contain_food{
        display:flex;
        align-items:center;
        gap:10px;
        color:#D7B68F;
    }
    
    #contain_food img{
        width:30px;
    }
    
    
    #contain_repair img{
        width:30px;
    }
    
    #talk{
        color:#D7B68F;
        text-decoration:underline;
        margin-left:25px;
        cursor:pointer;
        margin-top:0;
    }
    
    #talk_div{
        margin-left:22px;
        width:87%;
        height:130px;
        background-image:url('images/talk_case.png');
        background-size: 100% 100%;
        background-repeat: no-repeat; /* Pour éviter la répétition */
        background-position: center;
        display:flex;
        gap:20px;
        align-items:end;
        justify-content:space-around;
    }
    
    #talk_div img{
        width:auto;
        height:100px;
        cursor:pointer;
    }
    
    #leave{
        background:url('images/leave_bg.png');
        background-size: 100% 100%;
        background-repeat: no-repeat; /* Pour éviter la répétition */
        background-position: center;
        display:inline;
        position:relative;
        left:20%;
        transform:translate(-50%);
        color:#543626;
        text-decoration:underline;
        padding:10px 20px 10px 20px;
        top:35px;
        cursor:pointer;
        transition:.5s all;

    }
    
    #leave:hover{
        font-size:2.1rem;
    }
    
    .div_select{
        position:absolute;
        bottom:-30px;
        right:-10px;
        color:#543626;
        width:auto;
        display:flex;
    }
    
    .h2g{
        cursor:pointer;
    }
    
    .h2d{
        cursor:pointer;
    }

    #notif{
        background-image:url('images/notif2.png');
        background-size: 100% 100%;
        background-repeat: no-repeat; /* Pour éviter la répétition */
        background-position: center;
        width:600px;
        position:absolute;
        top:110Px;
        z-index:999;
        left:59%;
        transform:translate(-50%);
        padding-bottom:15px;
        display:none;
    }
    
    #notif img{
        width:40px;
        position:absolute;
        top:-15px;
        left:-15px;
    }
    
    #notif h2{
        color:#543626;
        text-decoration:underline;
        margin:0;
        padding:0;
        margin-top:10px;
        margin-left:20Px;
    }
    
    #notif p{
        color:#543626;
        margin:0;
        padding:0;
        margin-top:10px;
        margin-left:20Px;
        font-weight:600;
    }
    
    #dialogue{
        position:absolute;
        background-image:url('images/dialogue.png');
        background-size: 100% 100%;
        background-repeat: no-repeat; /* Pour éviter la répétition */
        background-position: center;
        width:600px;
        left:38%;
        top:50%;
        transform:translate(-50%,-50%);
        z-index:100;
        display:flex;
        align-items:center;
        padding:50px;
        gap:20px;
        display:none;
    }
    
    #ancre{
        position:absolute;
        background-image:url('images/dialogue.png');
        background-size: 100% 100%;
        background-repeat: no-repeat; /* Pour éviter la répétition */
        background-position: center;
        width:600px;
        left:38%;
        top:50%;
        transform:translate(-50%,-50%);
        z-index:101;
        padding:30px;
        padding-top:10px;
        padding-bottom:10px;
        display:none;
    }
    
    #ancre h1{
        color:#543626;
        text-align:center;
        text-decoration:underline;
    }
    
    #ancre h2{
        color:#543626;
        margin-left:20px;
        cursor:pointer;
    }
    
    
    
    #bord{
        height:65%;
    }
    
    #left{
        color:#543626;
        text-align:center;
        
    }
    
    #nom{
        margin:0;
        padding:0;
        text-decoration:underline;
    }
    
    #metier{
        margin:0;
        padding:0;
    }
    
    #left img{
        width:200px;
    }
    
    #right{
        color:#543626;
        position:relative;
        height:300px;
        width:100%;
    }
    
    #right a{
        text-decoration:underline;
        font-weight:500;
    }
    
    #vous{
        position:absolute;
        bottom:10px;
        
    }
    
    #vous a{
        margin:0;
        padding:0;
    }
    
    #vous p{
        margin:0;
        margin-top:3px;
        padding:0;
        cursor:pointer;
        width:100%;
    }
    
    #vous p:hover{
        text-decoration:underline;
    }
    
    .outside{
        position:absolute;
        top:-23px;
        right:-15px;
        cursor:pointer;
        z-index:1003;
        width:50px;
    }
    
    
    #leaderboard{
        background-image:url('images/leaderboard.png');
        background-size: 100% 100%;
        background-repeat: no-repeat; /* Pour éviter la répétition */
        background-position: center;
        width:270px;
        position:absolute;
        top:50px;
        right:50px;
        z-index:999;
        padding-bottom:10px;
        
        height:35px;
        overflow:hidden;
        cursor:pointer;
        transition:.5s all;
        
        
        
    }
    
    #leaderboard div{
        margin:0;
        padding:0;
        display:flex;
        gap:5px;
        align-items:start;
        margin-left:15px;
        margin-top:10px;
        
    }
    
    #leaderboard h3{
        color:#543626;
        margin:0;
        padding:0;
    }

    
    #leaderboard h2{
        
        color:#543626;
        margin:0;
        padding:0;
        margin-left:15px;
        text-decoration:underline;
        margin-top:10px;
    }
    
    #discussion{
        height:60%;
        overflow:auto;
    }
    
    
    #end{
        position:absolute;
        width:600px;
        left:25%;
        top:39%;
        transform:translate(-40%,-50%);
        z-index:10;
        display:flex;
        justify-content:center;
        flex-wrap:wrap;
        align-items:start;
        z-index:999;
        display:none;
        gap:30px;
    }
    
    #end h3{

        color:#543626;
        width:80%;
        text-align:center;
    }
    
    #end img{
        
    }
    
    #end input{
        all:initial;
        font-family: "Pixelify Sans", serif;
        font-optical-sizing: auto;
        font-weight: 700;
        font-style: normal;
        font-size:1.4rem;
        margin:auto;
        text-align:center;
        background:url('images/leave_bg.png');
        background-size: 100% 100%;
        background-repeat: no-repeat; /* Pour éviter la répétition */
        background-position: center;
        padding:10px 20px 10px 20px;
        color:#543626;
        cursor:pointer;
    }
    
     #end h2{
        all:initial;
        font-family: "Pixelify Sans", serif;
        font-optical-sizing: auto;
        font-weight: 700;
        font-style: normal;
        font-size:1.4rem;
        margin:auto;
        text-align:center;
        background:url('images/leave_bg.png');
        background-size: 100% 100%;
        background-repeat: no-repeat; /* Pour éviter la répétition */
        background-position: center;
        padding:10px 20px 10px 20px;
        color:#543626;
        cursor:pointer;
    }
    
    #finito2{
        display:none;
    }
    
    #discuss2{

        height:55%;
        overflow:auto;
    }

</style>
<body>
    <form method='post' action='cursedV3.php'>
        <input id='deco' type='image' name='decon' src='images/deco.png'>
    </form>
    <div id='responsive'>
        <div id='error_message'>
            <h2>Désolé... Le jeu n’est encore pas disponible pour votre format d’écran. </h2>
            <h2>Il est recommandé de jouer sur un ordinateur, </h2>
            <img id='error_mess' src='images/error.png'>
        </div>
    </div>
    <div id='menu_ile'>
        <h1 id='ile_name'>Seavy Bay</h1>
        <h3 id='ile_desc'>1ère ile du jeu, elle constitue la 1ère île de l’archipel. La plupart des voyageurs s’arrêtent ici pour se réapprovisionner, avant de s’en aller vers la capitale.</h3>
        <div id='contain_repair'>
            <h2 id='repair'>- Améliorer le bateau</h2>
            <h2 id='prix5'>100</h2>
            <img src='images/coin2.png'>
        </div>
        <div id='contain_food'>
            <h2 id='food2'>- Réaprovisionner</h2>
            <h2 id='prix6'>30</h2>
            <img src='images/coin2.png'>
        </div>
        <div id='menu_buy'>
            <div id='titres_buy'>
                <h1 id='buy'>Acheter</h1>
                <h1 id='sell'>Vendre</h1>
            </div>
            <div id='contain_buy'>
                
                
            </div>
            <div id='contain_sell'>

            </div>
        </div>
        <h2 id='talk'>- Discuter</h2>
        <div id='talk_div'>
            
        </div>
        <h1 id='leave'>Lever l'ancre</h1>
    </div>
    <div id='menu_principal'>
        <div id='texture_map'>
            <img class='logo' src='images/logo2.png'> 
            <h1 class='titre1'>Informations :</h1>
            <div id='infos_perso'>
                <img id='info_bateau' src='images/radeau.png'>
                <div id='infos_right'>
                    <div class='infos'>
                        <img class='icon' src='images/heart2.png'>
                        <div class='infos_cont'>
                            <h2>- Vie</h2>
                            <h2 id='life'>100%</h2>
                            <div id='bip3' class='fishing_astuce'>
                                <img src='images/error.png'>
                                <p>Vous n'avez plus de vivres ! Réapprovisionnez vous sur l'ile la plus proche !!
                                </p>
                            </div>
                        </div>
                    </div>
                    <div class='infos'>
                        <img class='icon' src='images/food.png'>
                        <div class='infos_cont'>
                            <h2>- Vivres</h2>
                            <h2 id='food'>100%</h2>
                        </div>
                    </div>
                </div>
            </div>
            <div id='money'>
                <img src='images/coin2.png'>
                <h1 id='golds'>100</h1>
                <h1>pièces d'or</h1>
            </div>
            <h1 id='titre_inv'>Inventaire</h1>
            <div id='bip' class='fishing_astuce'>
                <img src='images/error.png'>
                <p>
                    Cliquer sur un des objets de l'inventaire pour intéragir avec.
                </p>
            </div>
            
            <div id='inventaire'>
                
            </div>
            <h1 class='titre1'>Quetes :</h1>
            <div id='quests'>
                
                <div>
                    <img src='images/case2.png'>
                    <h3>Fouillez votre inventaire pour comprendre ce qui vous est arrivé</h3>
                </div>

            </div>
            <h1 id='sauvegarder'>Sauvegarder</h1>
            <div id='bip2' class='fishing_astuce'>
                <img src='images/error.png'>
                <p>
                    Permet de sauvegarder votre progression (position, vie, or, inventaire, etc...)
                </p>
            </div>
        </div>
    </div>
    <img src='images/map.png' id='map2'>
    <img src='images/lettre2.png' id='lettre2'>
    <img src='images/journal2.png' id='journal2'>
    <div id='east'>
            <div id='talk_again'>
                <div id='premiere'>
                    <img src='images/pirate4.png'>
                    <h2>Kreaks Staas</h2>
                    <h2>Prisonnier</h2>
                </div>
                <img class='bord1' src='images/bord.png'>
                
                
                <div id='seconde'>
                    <div id='discuss2'>
                        <h3 id='him'><a>Kreaks Staas :</a>Qu'est ce que tu me veux....</h3>
                    </div>
                    <h3 id='you9'><a>Vous :</a> Vos tatouages, j'ai trouvé une lettre contenant les mêmes symboles, d'ou viennent ils ?</h3>
                </div>
                
                
                
                <img class='bord1' src='images/bord.png'>
                <div id='troisieme'>
                    <h1>East Prison</h1>
                    <h3>Cette ile est strictement réservée aux prisonniers les plus dangereux de l'archipel et du monde entier. </h3>
                    <h1 id='left10'>Quitter l'ile</h1>
                </div>
                
            </div>
    </div>
    <div id='canvas'>
        <div id='leaderboard'>
            <h2>LeaderBoard</h2>
            <?php
            
            include '../database.php';

            $database = new Database();
            $connexion = $database->getConnection();
            
                $sql = "SELECT * FROM `users` ORDER BY gold DESC limit 10";
                $statement = $connexion->prepare($sql);
                $statement->execute();
                $index = 0;
                $results = $statement->fetchAll(PDO::FETCH_ASSOC);
                foreach ($results as $row) {
                    $pseudo = $row['pseudo'];
                    $gold = $row['gold'];
                    $index++;
                    echo "<div>";
                    echo "<h3>$index -</h3>";
                    echo "<h3>$pseudo</h3>";
                    echo "<h3 class='ohh'>$gold</h3>";
                    echo "<h3>golds</h3>";
                    echo "</div>";
                }
                
            ?>
        </div>
        <div id='ancre'>
            <h1>Lever l'ancre</h1>
            <img class='outside' id='outside1' src='images/deco.png'>
        </div>
        <div id='dialogue'>
            <img class='outside' id='outside' src='images/deco.png'>
            <div id='left'>
                <img  id='pirate_actif' src='images/pirate1.png'>
                <h2 id='nom'>Halls Brook</h2>
                <h2 id='metier'>Barman</h2>
            </div>
            <img src='images/bord.png' id='bord'>
            <div id='right'>
                <div id='discussion'>
                    <p id='discuss'><a id='person9'>Halls Brook :</a>1ère ile du jeu, elle constitue la 1ère île de l’archipel. La plupart des voyageurs s’arrêtent ici pour se réapprovisionner, avant de s’en aller vers la capitale.</p>
                </div>
                <div id='vous'>
                    <a>Vous :</a>
                    
                    <p id='you8'> - l’archipel. La plupart des voyageurs s’arrêtent ici pour se réapprovisionner, avant</p>
                </div>
            </div>
        </div>
        <img id='eau' src='../aie/Untitled00086401.png'>
        <img src='images/clouds3.png' id='clouds'>
        <img src='images/clouds3.png' id='clouds2'>
        <img src='../images/ile1.png' id='ile'>
        <img id='radeau' class='boat' src='../images/bateau1.png'>
        <img id='fishing_road' class='boat' src='../images/fishing_road11.png'>
        <img id='fishing_road0' class='boat' src='../images/fishing_road0.png'>
        <h2 id='fished'>Pécher le poisson</h2>
    </div>
    <div id='notifs'>
        
    </div>
    <div id='notif'>
        <img src='images/error.png'>
        <h2>Notification :</h2>
        <p id='edit'>Vous avez attrapé un poisson !</p>
    </div>
    <div id='end'>
        <img id='logo' src='images/logo2.png'>
        <h3 id='why'></h3>
        <form method='post' action='cursedV3.php'>
        <input type='submit' id='finito' name='finito' value='Retour au menu'>
        <h2 id='finito2' >Retour sur l'ile</h2>
        </form>
        
    </div>
    
    
    
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script>

var dec = 0;
$('#you9').on('click',function(){
    dec++;
    if(dec == 1){
        $('#discuss2').append(
        `<p>${$('#you9').text()}</p>
        <p><a>Kreaks Staas :</a> On a mené une expédition avec Barbe Noir, vers le bout du monde à l'Est... On raconte que personne n'est jamais allé aussi loin, et que rien ne s'y trouve, mais c'est faux... Nous y sommes allés, tu y es allé, mais je vois que la malédiction t'a frappé d'une autre façon que moi... </p>`
        );
        $('#you9').text("Vous : Quelle chose ??? Que c'est-il passé la bas ?")
    }
    if(dec == 2){
        $('#discuss2').append(
        `<p>${$('#you9').text()}</p>
        <p><a>Kreaks Staas :</a>Aucune idée, je peux pas savoir d'ou je suis, et même si je le pouvais, j'en ai aucune envie. T'a qu'a vérifier par toi même, à Loadly, apparament, il existe une ile, End Valley, va te renseigner...</p>`
        );
        $('#you9').text("Vous : ...")
        
        
    }
    if(dec == 3){
        if(quest == 4){
            quest = 5;
            update_quest(quest);
        }
        $('#east').css('display','none');
        $('#canvas').css('display','block');
        stop=false;
        pop_ile(2)
        $('#ile').css('left','220px')
        
        
        
        var h2s = document.querySelectorAll("#ancre h2");
        h2s.forEach(item=>{
            item.remove();
        })
        
        var ancreDiv = document.getElementById('ancre');
        var titres = ["Seavy Bay","Loadly Ridges"];
        titres.forEach(titre => {
            let h2 = document.createElement('h2'); // Crée un élément <h2>
            h2.textContent = titre; // Définit le texte
            ancreDiv.appendChild(h2); // Ajoute le <h2> à #ancre
        });
    
    }
    
    
})
/**
$('#nom').text('Halls Brook');
        $('#metier').text('Barman');
        
        $('#discuss').html('<a>Halls Brook : </a>Bienvenu au bar de Seavy Bay, qu\'est ce que je te sers ?');
        $('#you8').text("Je ne sais pas vraiment d'ou je viens, tout ce que j'ai c'est cette lettre, est ce qu'elle vous dit quelque chose ?");

        let fin = false;
        $('#you8').off('click').on('click', function() {
            if (!fin) {
                $('#discussion').append(
                    `<p>Vous : ${$('#you8').text()}</p>
                     <p><a>Halls Brook : </a>Ces symboles... J'en ai déja vu, un ancien pirate, il en avait tatoué sur tous le corps. A l'heure qu'il est, il doit être en train de croupir à East Prison, si il n'est pas déja mort...</p>`
                );
                $('#you8').text('Merci, merci beaucoup pour ces informations.');
                fin = true;
            } else {
                $('#dialogue').hide();
                $('#discussion').children().not('[id]').remove();
                fin = false;
                if(quest == 3){
                    
                    quest = 4;
                    update_quest(quest)
                }
            }
        });
**/

$('#finito2').on('click',function(){
    monde=3;
    //gestion_ile(monde);
    pop_ile(monde);
    $('#ile').css('display','block')
    $('#radeau').css('display','none')
    $('#end').css('display','none')
    
    $('#canvas').css('width','1200px')
    $('#canvas').css('height','780px')
    $('#canvas').css('top','50%')
    $('#canvas').css('left','60%')
    $('#canvas').css('transform','translate(-50%,-50%)')
    $('#canvas').css('margin','0')
    $('#menu_principal').css('display','block');
    
    quest = 9;
    update_quest(quest);
    
     $('#deco').css('display','block')
     
})

function fin(raison){
    $('#end').css('display','flex')
    $('#menu_principal').css('display','none');
        $('#canvas').css('width','100%')
        $('#canvas').css('height','100%')
        $('#canvas').css('top','0')
        $('#canvas').css('left','0')
        $('#canvas').css('transform','none')
        $('#canvas').css('margin','0')
        $('#leaderboard').css('display','none')
        $('#ile').css('display','none')
        $('#radeau').css('bottom','10%')
        $('#radeau').css('left','50%')
        $('#menu_ile').css('display','none')
        clearInterval(fine)
        $('#deco').css('display','none')
        

    
    if(raison == "mort"){
        $('#why').text("Vous n'avez pas fait assez attention à vos reserves de nourriture, et vous êtes mort de fin. N'hésitez pas à retenter votre chance, sinon, merci d'avoir joué au jeu !!")
        
        $('#finito').css('display','block');
        $('#finito2').css('display','none');
        
    }else{
        $('#why').text("Désolé, cette partie du jeu n'est pas encore développée, mais mercid d'avoir été jusque la !! Vous pouvez toujours conserver votre progression, et essayer de faire partie des meilleurs pirates du classement. Dans tous les cas, merci d'avoir joué !")
        
        $('#finito').css('display','none');
        $('#finito2').css('display','block');
    }
    
    
    
}


    $('#leaderboard').on('click',function(){
        var height = $('#leaderboard').css('height');
        if(height == "35px"){
            $('#leaderboard').css('height','380px');
        }else{
            $('#leaderboard').css('height','35px');
        }
        
    })


    var fine = setInterval(function(){
    if(stop){
        $('#leaderboard').css('display','none')
        
    }else{
        $('#leaderboard').css('display','block')
    }
    },40)



$('#left10').on('click',function(){
    $('#east').css('display','none');
    $('#canvas').css('display','block');
    stop=false;
    pop_ile(2)
    $('#ile').css('left','220px')
    
    
    
    var h2s = document.querySelectorAll("#ancre h2");
    h2s.forEach(item=>{
        item.remove();
    })
    
    var ancreDiv = document.getElementById('ancre');
    var titres = ["Seavy Bay","Loadly Ridges"];
    titres.forEach(titre => {
        let h2 = document.createElement('h2'); // Crée un élément <h2>
        h2.textContent = titre; // Définit le texte
        ancreDiv.appendChild(h2); // Ajoute le <h2> à #ancre
    });
    
})

function check(){
    if($('#contain_food').css('display') == "none" && $('#contain_repair').css('display') == "none"){
        //console.log('deux none')
        $('#ile_desc').css('height','150px')
    }
    if($('#contain_food').css('display') == "none" && $('#contain_repair').css('display') != "none"){
        //console.log('juste repair')
        $('#ile_desc').css('height','100px')
    }
    
    if($('#contain_food').css('display') != "none" && $('#contain_repair').css('display') == "none"){
        //console.log('juste food')
        $('#ile_desc').css('height','100px')
    }
    
    if($('#contain_food').css('display') != "none" && $('#contain_repair').css('display') != "none"){
        //console.log('deux block')
        $('#ile_desc').css('height','50px')
    }
}

/**
Seavy Bay = ile 1
The Last Outpost = ile 2;
Loadly Ridges = ile 3;
East prison = ile 4;
End Valley = ile 5;

Seavy Bay -> The last Outpost = 6
Seavy Bay -> Loadly Ridges = 7;
The Last Outpost -> Seavy Bay = 8;
The Last Outpost -> Loadly Ridges = 9;
The Last Outpost -> East Prison = 10;
Loadly Ridges -> Seavy Bay = 11;
Loadly Ridges -> The last Outpost -> 12;
Loadly Ridges -> End Valley -> 13;

 **/


$('#outside').on('click',function(){
    $('#dialogue').css('display','none')
    $('#discussion').children().not('[id]').remove();
})


$('#outside1').on('click',function(){
    $('#ancre').css('display','none')
})

$('#sell').on('click',function(){
    $('#buy').css('z-index','1');
    $('#sell').css('z-index','2');
    $('#contain_buy').css('display','none');
    $('#contain_sell').css('display','flex')
})

$('#buy').on('click',function(){
    $('#buy').css('z-index','2');
    $('#sell').css('z-index','1');
    $('#contain_buy').css('display','flex');
    $('#contain_sell').css('display','none')
})

var touche_peche = false;
var touche_lettre=false;

var stop=false;

function menu_vendre(obj,quantite2,ile){

    var objs = document.querySelectorAll('#inventaire > div');

    for (let item of objs) {
        let title = item.getAttribute("title");
        
        if (title === "map" && obj === title) {
            //console.log('map');
            return; // Arrête la boucle complètement
        }
    
        if (title === "journal" && obj === title) {
            return; // Arrête la boucle
        }
        
         if (title === "fishing_road" && obj === title) {
            return; // Arrête la boucle
        }
        if (title === "lettre" && obj === title) {
            return; // Arrête la boucle
        }
        if (title === "boussole" && obj === title) {
            return; // Arrête la boucle
        }
        if (title === "marchandise2" && obj === title && monde !=1) {
            return; // Arrête la boucle
        }
    }


    
    const contain1 = document.createElement('div');
    contain1.classList.add('contain1');
    
    // Création de l'image
    const img = document.createElement('img');
    img.src = 'images/'+ obj +'.png';
    contain1.appendChild(img);
    
    // Création de la div interne
    const contain2 = document.createElement('div');
    contain2.classList.add('contain2');
    
    // Création du titre
    const title = document.createElement('h2');
    title.textContent = obj;
    contain2.appendChild(title);
    
    var prix=0;


    if(ile ==1){
        //seavy bay
        if(obj == "bar"){
            prix = 10;
        }
        if(obj == "saumon"){
            prix = 15;
        }
        if(obj == "thon"){
            prix = 10;
        }
        if(obj == "map"){
            prix = "10";
        }
        if(obj == "journal"){
            prix = 10;
        }
        if(obj == "marchandises"){
            prix = 35;
        }
        if(obj == "marchandise2"){
            prix = 70;
        }

    }
    
    if(ile ==2){
        //seavy bay
        if(obj == "bar"){
            prix = 15;
        }
        if(obj == "saumon"){
            prix = 20;
        }
        if(obj == "thon"){
            prix = 15;
        }
        if(obj == "map"){
            prix = "15";
        }
        if(obj == "journal"){
            prix = 15;
        }
        if(obj == "marchandises"){
            prix = 25;
        }

    }
    
    if(ile ==3){
        //seavy bay
        if(obj == "bar"){
            prix = 15;
        }
        if(obj == "saumon"){
            prix = 30;
        }
        if(obj == "thon"){
            prix = 15;
        }
        if(obj == "map"){
            prix = "10";
        }
        if(obj == "journal"){
            prix = 10;
        }
        if(obj == "marchandises"){
            prix = 20;
        }

    }
        
    //console.log(prix)
    // Création de la div pour le prix
    const priceDiv = document.createElement('div');
    const priceLabel = document.createElement('h3');
    priceLabel.textContent = 'Prix : ';
    const priceValue = document.createElement('h3');
    priceValue.textContent = prix + 'or';
    priceDiv.appendChild(priceLabel);
    priceDiv.appendChild(priceValue);
    contain2.appendChild(priceDiv);
    
    // Création de la div pour la quantité
    
        
    
    const quantityDiv = document.createElement('div');
    const quantityLabel = document.createElement('h3');
    quantityLabel.textContent = 'Quantite : ';
    const decreaseBtn = document.createElement('h3');
    decreaseBtn.classList.add('g');
    decreaseBtn.textContent = '<';
    const quantityValue = document.createElement('h3');
    quantityValue.textContent = quantite2;
    const increaseBtn = document.createElement('h3');
    increaseBtn.classList.add('d');
    increaseBtn.textContent = '>';
    
    //ajouter une vérif dans l'inventaire
    var quantite_max;
    
    var items = document.querySelectorAll('#inventaire div');
    items.forEach(item => {
        if (item.title === obj) {
            var quantite = item.querySelector("h3");
            quantite_max = quantite.textContent;
        }
    });

    
    decreaseBtn.addEventListener('click',function(){
        var quantite = parseInt(quantityValue.textContent, 10);
        if(quantite > 0){
            quantite--;
        }
        quantityValue.textContent = quantite;
    
        
    })
    
    increaseBtn.addEventListener('click',function(){
        var quantite = parseInt(quantityValue.textContent, 10);
        if(quantite < quantite_max){
            quantite++;
            quantityValue.textContent = quantite;
        }
        
    })
    
    quantityDiv.appendChild(quantityLabel);
    quantityDiv.appendChild(decreaseBtn);
    quantityDiv.appendChild(quantityValue);
    quantityDiv.appendChild(increaseBtn);
    
    
        contain2.appendChild(quantityDiv);

    
    // Création du bouton d'achat
    const buyBtn = document.createElement('h2');
    buyBtn.classList.add('vend');
    buyBtn.textContent = 'Vendre';
    contain2.appendChild(buyBtn);
    
    buyBtn.addEventListener('click',function(){
        var quantite = parseInt(quantityValue.textContent, 10);
        //console.log(quantite)
        supp(obj,quantite)
        
        var sous = $('#golds').text();
        sous = parseInt(sous, 10);
        sous = sous + prix * quantite;
        $('#golds').text(sous);
        
        if(obj == "marchandise2"){
            quest = 7;
            update_quest(quest)
        }
        
        //supprimer dans la div;
        
        
        
        /**
        var sous = $('#golds').text();
        console.log(prix)
        var result = sous - prix;
        if(result >= 0){
            var quantite = parseInt(quantityValue.textContent, 10);
            sous = sous - prix * quantite;
            $('#golds').text(sous)
            
            //ajouter quant à l'inventaire 
            
            add(obj,quantite)
        }else{
            notif("Vous n'avez pas assez d'argent !")
        }
        **/
    })
    
    // Ajout de contain2 à contain1
    contain1.appendChild(contain2);
    
    
    $('#contain_sell').append(contain1)
}

///

function pop_ile(num){
    check();
    if(num == 1){
        $('#ile_desc').text("Première île de l'archipel, les voyageurs s'arrêtent ici pour faire le plein de provisions avant un long voyage vers le reste du monde, à l'Ouest.")
    }
    if(num == 2){
        $('#ile_desc').text("Capitale Sinistre de l'archipel, la plupart des bourgeois encore présent vivent confinés ici, entre eux. La marine y est également très présente, en raison de la célèbre prison située à seulement quelques noeuds.")
    }
    if(num == 3){
        $('#ile_desc').text("Ile marchande de l'archipel, la plus propice au commerce. De nombreuses affaires sont effectuées ici. ")
    }
    stopFishing();
    pechee=false;
    if(num == 2){
        monde=2;
    }
    if(num == 1){
        monde=1;
    }
    if(num == 3){
        monde=3;
    }
    var personnages = document.querySelectorAll('#talk_div div');
    personnages.forEach(item=>{
        item.remove();
    })
    
    
    var ancreDiv = document.getElementById('ancre');
    var titres = ["Seavy Bay", "East Prison", "The Last Outpost", "Loadly Ridges", "End Valley"];
    titres.forEach(titre => {
        let h2 = document.createElement('h2'); // Crée un élément <h2>
        h2.textContent = titre; // Définit le texte
        ancreDiv.appendChild(h2); // Ajoute le <h2> à #ancre
    });
    

    var vendez = document.querySelectorAll("#contain_sell div");
    vendez.forEach(item=>{
        item.remove();
    })
    var acheter = document.querySelectorAll("#contain_buy div");
    acheter.forEach(item=>{
        item.remove();
    })
    
    
    /**
    var vendez = document.getElementById('#contain_sell');
    if(vendez)
    vendez.remove();
        
    var achetez = document.getElementById('#contain_buy');
    if(achetez)
    achetez.remove();
    **/
        
    if(bateau > 1){
        $('#contain_repair').css('display','none');
        $('#radeau').attr('src','images/boat.png');
        $('#radeau').css('height','auto')
        $('#radeau').css('width','400px');
        $('#radeau').css('left','300px');
        $('#radeau').css('bottom','20px');

    }
    if(num == 1){
        
        
        var div = document.createElement('div');
        var img = document.createElement('img');
        img.setAttribute('src', 'images/pirate1.png');
        div.appendChild(img)
        $('#talk_div').append(div)
        
        var div = document.createElement('div');
        var img = document.createElement('img');
        img.setAttribute('src', 'images/pirate2.png');
        div.appendChild(img)
        $('#talk_div').append(div)
        
        var div = document.createElement('div');
        var img = document.createElement('img');
        img.setAttribute('src', 'images/pirate3.png');
        div.appendChild(img)
        $('#talk_div').append(div)
        
        var h2s = document.querySelectorAll('#ancre h2');
        h2s.forEach(item => {
            if (item.textContent.trim() === "Seavy Bay") {
                item.style.display = "none";
            }
            if (item.textContent.trim() === "End Valley") {
                item.style.display = "none";
            }
            if (item.textContent.trim() === "East Prison") {
                item.style.display = "none";
            }
        });

        
    }
    
    if(num == 2){
        var div = document.createElement('div');
        var img = document.createElement('img');
        img.setAttribute('src', 'images/pirate1.png');
        div.appendChild(img)
        $('#talk_div').append(div)
        
        var div = document.createElement('div');
        var img = document.createElement('img');
        img.setAttribute('src', 'images/pirate2.png');
        div.appendChild(img)
        $('#talk_div').append(div)
        
        var div = document.createElement('div');
        var img = document.createElement('img');
        img.setAttribute('src', 'images/pirate3.png');
        div.appendChild(img)
        $('#talk_div').append(div)
        var h2s = document.querySelectorAll('#ancre h2');
            h2s.forEach(item => {
                    item.style.display = "block";
            });
        //console.log('The Last Outpost')
        h2s.forEach(item => {
            if (item.textContent.trim() === "End Valley") {
                item.style.display = "none";
            }
            if (item.textContent.trim() === "The Last Outpost") {
                item.style.display = "none";
            }
            if (item.textContent.trim() === "East Prison") {
                item.style.display = "none";
            }
        });
    }
    
    if(num == 3){
        var div = document.createElement('div');
        var img = document.createElement('img');
        img.setAttribute('src', 'images/pirate1.png');
        div.appendChild(img)
        $('#talk_div').append(div)
        
        var div = document.createElement('div');
        var img = document.createElement('img');
        img.setAttribute('src', 'images/pirate2.png');
        div.appendChild(img)
        $('#talk_div').append(div)
        
        var div = document.createElement('div');
        var img = document.createElement('img');
        img.setAttribute('src', 'images/pirate3.png');
        div.appendChild(img)
        $('#talk_div').append(div)
        var h2s = document.querySelectorAll('#ancre h2');
            h2s.forEach(item => {
                    item.style.display = "block";
            });
        //console.log('Loadly Ridges')
        h2s.forEach(item => {
            if (item.textContent.trim() === "Loadly Ridges") {
                item.style.display = "none";
            }
            if (item.textContent.trim() === "East Prison") {
                item.style.display = "none";
            }
            if (item.textContent.trim() === "End Valley") {
                item.style.display = "none";
            }
        });
        
        

        
        
    }
    
    
    
    if(quest==2){
        quest++;
        $('#quests > div > h3').css('text-decoration', 'line-through');
        setTimeout(function(){
            update_quest(quest);
        },2000)
    }
    
    if(num == 1){
        $('#ile').attr('src','../images/ile1.png')
        $('#ile').css('bottom','125px')
        $('#ile').css('left','220px')
        
        //bottom 125px
        //left 220px
        
        //$('#radeau').css('display','none');
        stop=true;
        $('#menu_ile').css('display','block')
        $('#ile_name').text('Seavy Bay')
        //gérer le menu vendre ici..
        
        setTimeout(function(){
           // console.log('bah ?')
            var objs = document.querySelectorAll('#inventaire > div');
            var index_map = 0;
            var index_journal = 0;
            var index_boussole = 0;
            objs.forEach(item =>{
                let title = item.getAttribute("title");
                let h2Text = item.querySelector("h3").textContent;
                menu_vendre(title,h2Text,num)
                if(title == "map"){
                    index_map++;
                }
                if(title == "journal"){
                    index_journal++;
                }
                if(title == "boussole"){
                    index_boussole++;
                }
            })
            if(index_journal == 0){
                add_market("journal",1,1);
            }
            if(index_map == 0){
                add_market("map",1,1);
            }
            if(index_boussole == 0){
                //add_market("boussole",1,1);
            }
            add_market("marchandises",1,1);
            
        },500)
    }
    
    
    
    if(num == 2){
        setTimeout(function(){
            //console.log('bah ?')
            var objs = document.querySelectorAll('#inventaire > div');
            var index_map = 0;
            var index_journal = 0;
            var index_boussole = 0;
            objs.forEach(item =>{
                let title = item.getAttribute("title");
                let h2Text = item.querySelector("h3").textContent;
                menu_vendre(title,h2Text,num)
                if(title == "map"){
                    index_map++;
                }
                if(title == "journal"){
                    index_journal++;
                }
                if(title == "boussole"){
                    index_boussole++;
                }
            })
            if(index_journal == 0){
                add_market("journal",1,2);
            }
            if(index_map == 0){
                add_market("map",1,2);
            }
            if(index_boussole == 0){
                //add_market("boussole",1,1);
            }
            add_market("marchandises",1,2);
            
        },500)
    }
    
    if(num == 3){
        setTimeout(function(){
            //console.log('bah ?')
            var objs = document.querySelectorAll('#inventaire > div');
            var index_map = 0;
            var index_journal = 0;
            var index_boussole = 0;
            objs.forEach(item =>{
                let title = item.getAttribute("title");
                let h2Text = item.querySelector("h3").textContent;
                menu_vendre(title,h2Text,num)
                if(title == "map"){
                    index_map++;
                }
                if(title == "journal"){
                    index_journal++;
                }
                if(title == "boussole"){
                    index_boussole++;
                }
            })
            if(index_journal == 0){
                add_market("journal",1,3);
            }
            if(index_map == 0){
                add_market("map",1,3);
            }
            if(index_boussole == 0){
                //add_market("boussole",1,1);
            }
            add_market("marchandises",1,3);
            
        },500)
    }
    
    
    if(num == 3){
        //$('#radeau').css('display','none');
        stop=true;
        $('#menu_ile').css('display','block');
        
        $('#ile_name').text('Loadly Ridges')
        $('#ile').attr('src','images/loadly ridgees.png')
        $('#ile').css('bottom','100px')
        $('#ile').css('left','120px')
        
        //bottom 125px
        //left 220px
    }
    
    if(num == 2){
        //$('#radeau').css('display','none');
        stop=true;
        $('#menu_ile').css('display','block');
        
        $('#ile_name').text('The Last Outpost')
        $('#ile').attr('src','images/last outpost.png')
    }
    setTimeout(function(){
        add_market("bar",1,3);
        add_market("saumon",1,3);
        add_market("thon",1,3);
    },600)
    
    
    
    
$('#leave').off('click').on('click', function() {
    $('#dialogue').css('display', 'none');
    
    
    var invs = document.querySelectorAll("#inventaire > div");
        invs.forEach(item => {

            if (item.title.includes('boussole')) {
                var h2s = document.querySelectorAll('#ancre h2');
                h2s.forEach(item2 => {
                    if (item2.textContent.trim() === "End Valley") {
                        if(num == 3){
                            if(quest == 8){
                                item2.style.display = "block";
                            }
                        }
                    }
                });
            }
    });
        
        

    // Vérifie si une carte est dans l'inventaire
    var items = document.querySelectorAll('#inventaire div');
    var index_carte = 0;
    items.forEach(item => {
        if (item.title === "map") {
            index_carte++;
        }
    });

    if (index_carte === 0) {
        notif("Vous ne pouvez pas reprendre la mer avant d'avoir acheté une carte...");
        return;
    } else if (bateau < 2) {
        notif("Améliorez votre bateau avant de reprendre la mer");
        return;
    } else {
        $('#ancre').css('display', 'block');
    }

    var h2s = document.querySelectorAll('#ancre h2');

    if (h2s.length > 0) {
        //console.log('hey');
        h2s.forEach(item => {
            //console.log(item);
            item.removeEventListener('click', handleClick2); // Supprime tout ancien écouteur
            item.addEventListener('click', handleClick2, { once: true }); // Ajoute un unique écouteur
        });
    }
    
    
    

});

function handleClick2(event) {
    
    let item = event.target; // Récupère l'élément cliqué

    if(num == 1){
        if (item.textContent.trim() === "The Last Outpost") {
            monde = 6;
        } else if (item.textContent.trim() === "Loadly Ridges") {
            monde = 7;
        }
    }
    
    if(num == 2){
        if (item.textContent.trim() === "Seavy Bay") {
            monde = 8;
        } else if (item.textContent.trim() === "Loadly Ridges") {
            monde = 9;
        } else if (item.textContent.trim() === "East Prison") {
            monde = 10;
        }
    }
    
    if(num == 3){
        if (item.textContent.trim() === "Seavy Bay") {
            monde = 11;
        } else if (item.textContent.trim() === "The Last Outpost") {
            monde = 12;
        } else if (item.textContent.trim() === "End Valley") {
            monde = 13;
        }
    }

    

    $('#radeau').css('display', 'block');
    stop = false;
    $('#menu_ile').css('display', 'none');
    $('#dialogue').css('display', 'none');
    $('#ancre').css('display', 'none');

    gestion_ile(monde);

    // Supprime tous les <h2> après le clic
    document.querySelectorAll('#ancre h2').forEach(item => item.remove());
}
    $('#food2').on('click',function(){
        //console.log('un')
        var or2 = $('#golds').text();
        or2 = parseInt(or2.match(/\d+/)[0], 10)
        var prix = 30;
        if(or2 >= prix){
            //console.log(prix)
            or('moins',prix);
            $('#contain_food').css('display','none');
            $('#food').text('100%')
            $('#life').text('100%')
            $('#bip3').css('display','none')
            
            check();
        }else{
            notif("Vous n'avez pas assez d'argent")
        }
    })
    
    $('#repair').on('click',function(){
        
        var or2 = $('#golds').text();
        or2 = parseInt(or2.match(/\d+/)[0], 10)
        var prix = $('#prix5').text();
        prix = parseInt(prix.match(/\d+/)[0], 10)
        if(or2 >= prix){
            or('moins',prix);
            $('#contain_repair').css('display','none');
            bateau++;

            $('#radeau').attr('src','images/boat.png');
            $('#radeau').css('height','auto')
            $('#radeau').css('width','400px');
            $('#radeau').css('left','300px');
            $('#radeau').css('bottom','20px');
            check();
        }else{
            notif("Vous n'avez pas assez d'argent")
        }
      
    })
    
    var persos = document.querySelectorAll('#talk_div img');
    persos.forEach(item =>{
        item.addEventListener('click',function(){
            var display = $('#dialogue').css('display');
            if(display == "none"){

                $('#dialogue').css('display','flex');
                $('#ancre').css('display','none');
                
                //en fonction de la ou on a cliquer / afficher en conséquences
                if(item.src.includes("pirate1")){
                    pirate(1);
                    
                }
                if(item.src.includes("pirate2")){
                    pirate(2);
                    
                }
                if(item.src.includes("pirate3")){
                    pirate(3);
                    
                }
            }else{
                $('#dialogue').css('display','none');
                
                // ICI, reset la div
                $('#discussion').children().not('[id]').remove();
            }
            
        })
    })
    $('#contain_food').css('display','flex');
    setTimeout(function(){
        
        //console.log('OH STOP')
        var food10 = $('#food').text();
        if(food10 == "100%"){
            //console.log('wtf ?')
            $('#contain_food').css('display','none');
        }
        //ptite condition pour check si la food est à 100%
        check();
    },600)
    
}

function pirate(num){
    //console.log(monde)
    $('#pirate_actif').attr('src','images/pirate' + num + '.png');

    if (num === 1 && monde === 1) {
        $('#nom').text('Halls Brook');
        $('#metier').text('Boucanier');
    
        $('#discuss').html('<a>Halls Brook : </a>Bienvenue à la taverne de Seavy Bay, étranger ! Que veux-tu boire, un grog ou du rhum ?');
        $('#you8').text("J'ignore d'où je viens, tout c'que j'ai c'est c'te lettre... Est-c'qu'elle t'parle, l'ami ?");
    
        let fin = false;
        $('#you8').off('click').on('click', function() {
            if (!fin) {
                $('#discussion').append(
                    `<p>Vous : ${$('#you8').text()}</p>
                     <p><a>Halls Brook : </a>Par les sept mers ! Ces symboles... J'les ai déjà vus, gravés sur la peau d'un vieux loup d'mer. Un ancien pirate, qu'on dit pourrissant dans les cachots d'East Prison... s'il n'a pas déjà nourri les poissons !</p>`
                );
                $('#you8').text('Merci, mille sabords, pour ces précieuses infos !');
                fin = true;
            } else {
                $('#dialogue').hide();
                $('#discussion').children().not('[id]').remove();
                fin = false;
                if(quest == 3){
                    
                    quest = 4;
                    update_quest(quest)
                }
            }
        });
    }

    
    if(num == 2 && monde == 1){
        $('#nom').text('Glost Tonwso');
        $('#metier').text('Pêcheur');
    
        $('#discuss').html("<a>Glost Tonwso : </a>Alors, qu'est-ce que j'te sers, moussaillon ?");
        $('#you8').text("J'ai pas vraiment d'or... désolé, j'suis un peu perdu.");
    
        let fin = false;
        $('#you8').off('click').on('click', function() {
            if (!fin) {
                $('#discussion').append(
                    `<p>Vous : ${$('#you8').text()}</p>
                     <p><a>Glost Tonwso : </a>C'est l'quotidien ici, p'tit gars. Bien des âmes échouent sur l'archipel sans savoir où mettre l'cap. Si t'as pas d'or, va jeter l'harpon dans l'eau salée, la pêche ça rapporte, surtout si tu vends à Loadly Ridges. Sinon, y'a les livraisons entre les îles... C'est long comme un calme plat, mais ça remplit bien les poches !</p>`
                );
                $('#you8').text('Merci, bon vent à vous !');
                fin = true;
            } else {
                $('#dialogue').hide();
                $('#discussion').children().not('[id]').remove();
                fin = false;
            }
        });
    }

    
    if(num == 3 && monde == 1){
        $('#nom').text('Stan Klouss');
        $('#metier').text('Ivrogne');
    
        $('#discuss').html("<a>Stan Klouss : </a>Fais gaffe, p'tit gars... R'mets pas l'cap sur la mer, pas ici... Pas dans c't'archipel... Des choses sombres y rôdent...");
        $('#you8').text("Des choses sombres ? Vous savez quelque chose à propos de cette lettre ???");
    
        let fin = false;
        $('#you8').off('click').on('click', function() {
            if (!fin) {
                $('#discussion').append(
                    `<p>Vous : ${$('#you8').text()}</p>
                     <p><a>Stan Klouss : </a>Ces symboles... non... pas ça... PAS ÇA... PAS ENCORE... LAISSEZ-MOI !</p>`
                );
                $('#you8').text('...');
                fin = true;
            } else {
                $('#dialogue').hide();
                $('#discussion').children().not('[id]').remove();
                fin = false;
            }
        });
    }

    
    
    if(quest == 4){
    
        if(num == 1 && monde == 2){
            $('#nom').text('Jessie Louds');
            $('#metier').text('Garde');
    
            $('#discuss').html("<a>Jessie Louds : </a>Qu'est-ce que tu viens faire sur c't'île, maraud ? T'es pas l'bienvenu ici !");
            $('#you8').text("J'suis à la recherche d'un homme, l'corps couvert d'étranges symboles... Vous savez où il s'trouve ?");
            
            let index = 0;
            let fin = false;
            $('#you8').off('click').on('click', function() {
                if (!fin) {
                    index++;
                    if(index == 1){
                       $('#discussion').append(
                        `<p>Vous : ${$('#you8').text()}</p>
                         <p><a>Jessie Louds : </a>Qu'est-ce que tu lui veux, l'ami ? C't'un ancien pirate, un chien d'la mer qui a servi sous l'capitaine Barbe-Noire ! PERSONNE n'est autorisé à l'voir. Et toi, t'as pas l'ombre d'une piécette dans tes poches... Reviens quand t'auras une centaine d'pièces d'or, ou dégage d'cette île !</p>`
                        );
                        $('#you8').text("Payer les 100 pièces d'or."); 
                    }
                    fin = true;
                    
                } else {
                    $('#dialogue').hide();
                    $('#discussion').children().not('[id]').remove();
                    fin = false;
    
                    var sous = $('#golds').text();
                    if((sous - 100) > 0){
                        sous = sous - 100;
                        $('#golds').text(sous);
                        
                        monde = 10;
                        gestion_ile(monde);
                        $('#menu_ile').css('display','none');
                    }else{
                        notif("Vous n'avez pas assez d'or, reviens quand tu pourras aligner les 100 pièces !");
                    }
                }
            });
        }
    
    }else{
        if(num == 1 && monde == 2){
            $('#nom').text('Jessie Louds');
            $('#metier').text('Garde');
    
            $('#discuss').html("<a>Jessie Louds : </a>Qu'est-ce que tu viens faire sur c't'île, maraud ? T'es pas l'bienvenu ici !");
            $('#you8').text("J'ai une étrange lettre, couverte d'symboles... Vous en savez quelque chose ?");
            
            let index = 0;
            let fin = false;
            $('#you8').off('click').on('click', function() {
                if (!fin) {
                    index++;
                    if(index == 1){
                       $('#discussion').append(
                        `<p>Vous : ${$('#you8').text()}</p>
                         <p><a>Jessie Louds : </a>Pfff... N'importe quoi ! J'ai pas d'temps pour tes balivernes, dégage d'ici avant qu'j'te fasse goûter l'acier !</p>`
                        );
                        $('#you8').text("...");
                    }
                    fin = true;
                    
                } else {
                    $('#dialogue').hide();
                    $('#discussion').children().not('[id]').remove();
                    fin = false;
                }
            });
        }
    }

    
    
    
    if(num == 2 && monde == 2){
        
    if(quest == 5){
        
        $('#nom').text('Ilis Leaubedois');
        $('#metier').text('Bourgeois');

        $('#discuss').html("<a>Ilis Leaubedois : </a>Eh vous là ! J'ai des marchandises à faire livrer vers Seavy Bay. Elles doivent arriver le plus VITE POSSIBLE, mais je ne peux pas quitter l'île pour l'instant. AIDEZ-MOI, je vous en prie ! Vous pourrez garder l'argent, mais livrez-la à temps... et surtout, n'ouvrez pas la boîte.");
        $('#you8').text("C'est d'accord...");

        $('#you8').off('click').on('click', function() {
            $('#dialogue').hide();
            $('#discussion').children().not('[id]').remove();
            
            // Ajout dans l'inventaire de la boîte de marchandise
            add('marchandise2', 1);
            quest = 6;
            update_quest(quest);
        });

    } else if(quest == 7){

        $('#nom').text('Ilis Leaubedois');
        $('#metier').text('Bourgeois');

        $('#discuss').html("<a>Ilis Leaubedois : </a>C'est livré ? Et dans les temps ? OUF... Merci, mille fois merci ! Tenez, prenez cette boussole. Elle ne fonctionne pas très bien, elle n'indique pas le nord et se dérègle sans cesse, mais elle semble avoir de la valeur... Alors, elle est à vous !");
        $('#you8').text("Merci beaucoup !");

        $('#you8').off('click').on('click', function() {
            $('#dialogue').hide();
            $('#discussion').children().not('[id]').remove();
            
            // Ajout dans l'inventaire de la boussole
            add('boussole', 1);
            quest = 8;
            update_quest(quest);
        });

    } else if(quest == 6){

        $('#nom').text('Ilis Leaubedois');
        $('#metier').text('Bourgeois');

        $('#discuss').html("<a>Ilis Leaubedois : </a>Alors ? C'est livré ?! Qu'attendez-vous ? Dépêchez-vous, le temps presse !");
        $('#you8').text("Je fais au plus vite...");

        $('#you8').off('click').on('click', function() {
            $('#dialogue').hide();
            $('#discussion').children().not('[id]').remove();
        });

    } else {

        $('#nom').text('Ilis Leaubedois');
        $('#metier').text('Bourgeois');

        $('#discuss').html("<a>Ilis Leaubedois : </a>Désolé, je ne peux rien pour vous. Les affaires sont compliquées ces temps-ci, surtout avec les autres îles... Alors laissez-moi tranquille !");
        $('#you8').text("Je comprends...");

        $('#you8').off('click').on('click', function() {
            $('#dialogue').hide();
            $('#discussion').children().not('[id]').remove();
        });
    }
}

    
    
    
    if(num == 3 && monde == 2){
        $('#nom').text('Pons Qarter');
        $('#metier').text('Marin');
        
        $('#discuss').html("<a>Pons Qarter : </a>Qu'est-ce qui t'amène sur cette île ? T'as pas l'air d'avoir beaucoup d'argent...");
        $('#you8').text("J'ai trouvé une lettre avec d'étranges symboles, j'aimerais savoir d'où elle vient...");
    
        let fin = false;
        $('#you8').off('click').on('click', function() {
            if (!fin) {
                $('#discussion').append(
                    `<p>Vous : ${$('#you8').text()}</p>
                     <p><a>Pons Qarter : </a>Oh bon sang... encore ces signes... Écoute, notre archipel, c'est le plus à l'Est du monde. Au-delà, c'est le néant... enfin, presque. Un équipage s'y est aventuré jadis. Un seul homme est revenu... le corps marqué par ces mêmes symboles...</p>`
                );
                $('#you8').text('...');
                fin = true;
            } else {
                $('#dialogue').hide();
                $('#discussion').children().not('[id]').remove();
                fin = false;
            }
        });
    }

    
    
    
    if(num == 1 && monde == 3){
    $('#nom').text('Edward Blackthorn');
    $('#metier').text('Marchand');
    
    $('#discuss').html("<a>Edward Blackthorn : </a>Alors, qu'est-ce que je peux faire pour toi ? T'es là pour acheter ou juste pour rêver de richesse ?");
    $('#you8').text("Je cherche à faire fortune");

    let fin = false;
    $('#you8').off('click').on('click', function() {
        if (!fin) {
            $('#discussion').append(
                `<p>Vous : ${$('#you8').text()}</p>
                 <p><a>Edward Blackthorn : </a>Ouais, comme tout le monde, gamin. Le commerce, c'est la clé : tu achètes en gros là où c'est bon marché, et tu revends là où ça vaut de l'or. Et si t'as pas un rond, bah... va pêcher. C'est pas glorieux, mais ça remplit les poches lentement.</p>`
            );
            $('#you8').text('Merci pour le conseil');
            fin = true;
        } else {
            $('#dialogue').hide();
            $('#discussion').children().not('[id]').remove();
            fin = false;
        }
    });
}

    
    
    
    if(num == 2 && monde == 3){
        if(quest == 5){
            
        
            $('#nom').text('William Crowe');
            $('#metier').text('Marchand');
            
            $('#discuss').html("<a>William Crowe : </a>T'es pas d'ici, ça se voit. Qu'est-ce que tu veux, étranger ?");
            $('#you8').text("End Valley, vous connaissez cette ile ? Comment s'y rendre ???");
        
            let fin = false;
            $('#you8').off('click').on('click', function() {
                if (!fin) {
                    $('#discussion').append(
                        `<p>Vous : ${$('#you8').text()}</p>
                         <p><a>William Crowe : </a>End Valley ? Ah, c'est juste une légende… On dit que c’est une île encore plus à l’est, au-delà des eaux interdites. Seule une certaine boussole pourrait te guider vers elle, mais elle est perdue dans les mains des plus riches, là-bas, à The Last Outpost. Bonne chance si tu veux essayer de la récupérer...</p>`
                    );
                    $('#you8').text('Merci pour les infos.');
                    fin = true;
                } else {
                    $('#dialogue').hide();
                    $('#discussion').children().not('[id]').remove();
                    fin = false;
                }
            });
        }else{
            $('#nom').text('William Crowe');
            $('#metier').text('Marchand');
            
            $('#discuss').html("<a>William Crowe : </a>T'es pas d'ici, ça se voit. Qu'est-ce que tu veux, étranger ?");
            $('#you8').text("J'suis un peu perdu...");
        
            let fin = false;
            $('#you8').off('click').on('click', function() {
                if (!fin) {
                    $('#discussion').append(
                        `<p>Vous : ${$('#you8').text()}</p>
                         <p><a>William Crowe : </a>Perdu ? T'as atterri dans l'archipel le plus à l'Est du monde, gamin. Au-delà, c'est juste l'océan sans fin. Y'en a qui racontent des histoires, des légendes... mais moi, tant que ça fait vendre des babioles et des cartes au trésor, j'm'en fiche !</p>`
                    );
                    $('#you8').text('Merci pour les infos.');
                    fin = true;
                } else {
                    $('#dialogue').hide();
                    $('#discussion').children().not('[id]').remove();
                    fin = false;
                }
            });
        }
    }

    
    
    
    if(num == 3 && monde == 3){
        $('#nom').text('Jack Bloodworth');
        $('#metier').text('Ivrogne');
        
        $('#discuss').html("<a>Jack Bloodworth : </a>Ohhh... Ohhhh... oh....");
        $('#you8').text("Bonjour, vous savez ce qui se trouve plus à l'Est, on peut y aller ?");


        let fin = false;
        $('#you8').off('click').on('click', function() {
            if (!fin) {
                $('#discussion').append(
                    `<p>Vous : ${$('#you8').text()}</p>
                     <p><a>Jack Bloodworth : </a>OHHHH... Plus à l'Est... NANNNN... NANN.. nann......</p>`
                );
                $('#you8').text('...');
                fin = true;
            } else {
                $('#dialogue').hide();
                $('#discussion').children().not('[id]').remove();
                fin = false;
            }
        });
    }

    
    
}

setInterval(function(){
    if(!stop){
        var food = $('#food').text();
        food = parseInt(food.match(/\d+/)[0], 10);
        if(food - vitesse > 0){
            food = food - (vitesse / 2);
            food = food + "%";
            $('#food').text(food)
            //console.log(food)
        }else{
            $('#food').text('0%')
            var vie = $('#life').text();
            vie = parseInt(vie.match(/\d+/)[0], 10);
            $('#bip3').css('display','block')
            if(vie - vitesse > 0){
                vie = vie - vitesse;
                vie = vie + "%";
                $('#life').text(vie)
            }else{
                 $('#life').text('0%')
                 var raison = "mort";
                 fin(raison);
                 
                 // FIN A DESACTIVER ICIIIIIIIIIIIIIIIIIIIIIIIIIIIII
                //gérer la mort ici...
            }
            
        }
        
    }
},1500)

function update_quest(quest){
    //console.log('oh')
    //console.log(quest)
    var quetes = document.querySelectorAll('#quests div');
    quetes.forEach(item => {

            item.remove();

    })
            
            if(quest==2){
                creer_quete("Se laisser dériver jusqu'a l'ile la plus proche pour en savoir plus")
                
                //afficher l'ile ici
                
                intervalId = setInterval(function(){
                        if(stop==false){
                            
                            var leftValue_bg = parseFloat($('#ile').css('left'));
                            var nouvelleValeurbg = leftValue_bg - 2 - vitesse;
                            //console.log(nouvelleValeurbg)
                            $('#ile').css('left', nouvelleValeurbg + 'px');
                            
                            if(nouvelleValeurbg < 220){
                                monde = 1;
                                pop_ile(1);
                                $('#ile').css('left','220px');
                                clearInterval(intervalId);
                                //GERER LE STOP + LAFIN DE LILE
                                //stop=true;
                                
                                //chercher l'inventaire et le foutre dans le market sell avec une autre mise en forme
                                
                                $('#radeau').css('display','none');
                                
                            }
                        }
                    },40)


            }
            
            if(quest == 3){
                creer_quete("Chercher des informations sur la lettre")
            }
            
            if(quest == 4){
                creer_quete("Se rendre sur The Last Outpost à la recherche de l'homme tatoué")
            }
            
            if(quest == 5){
                creer_quete("Découvrir comment se rendre sur End Valley")
            }
            
            if(quest == 6){
                creer_quete("Livrer les marchandises sur Seavy Bay")
            }
            
            if(quest == 7){
                creer_quete("Retourner voir le propriétaire de la caisse sur The Last Outpost")
            }
            
            if(quest == 8){
                creer_quete("Se rendre sur Loadly Ridges et prendre la direction d'End Valley")
            }
            
            if(quest == 9){
                creer_quete("Devenir le plus riche possible !")
            }
    
}

function gestion_ile(monde){
    let ileId;
    var limit;
    if(monde == 6){
        ileId = 2;

        limit = 1200;
    }else if(monde == 7){
        ileId = 3;

        
        limit = 2000;
    } else if(monde == 8){
        ileId = 1;

        limit = 1200;
    } else if(monde == 9){
        ileId = 3;

        limit = 1000;
    } else if(monde == 10){
        ileId = 4;
    } else if(monde == 11){
        ileId = 1;

        limit = 2000;
    } else if(monde == 12){
        ileId = 2;

        limit = 1000;
    }
    
    if(ileId == 4){
        $('#ile_menu').css('display','none');
        $('#canvas').css('display','none');
        $('#east').css('display','block');
        stop=true;
        console.log('stop true;')
        return;
    }
    
    if(monde != 13){
        $('#ile').css('left', '220px');
    
        let disapear = false;
        let intervalId2 = setInterval(() => {
            if (!stop) {
                let leftValue_bg = parseFloat($('#ile').css('left'));
                let nouvelleValeurbg = leftValue_bg - 2 - vitesse;
                $('#ile').css('left', nouvelleValeurbg + 'px');
                if(leftValue_bg <= -600){
                    disapear=true;
                }
            }
        }, 40);
    
        let compteur = 0;
        let intervalId = setInterval(() => {
            
            compteur += 1 + vitesse;
    
            if (disapear && compteur < limit && !stop) {
                $('#ile').css('left', '1200px');
                //console.log('LAAAA')
                clearInterval(intervalId2);
                
                //ICI changement ile et tout
                if(monde == 6){
                    $('#ile').attr('src','images/last outpost.png')
                }else if(monde == 7){
                    $('#ile').attr('src','images/loadly ridgees.png')
                    $('#ile').css('bottom','100px')
                    $('#ile').css('left',120 + 1200 + 'px')
                } else if(monde == 8){
                    $('#ile').attr('src','../images/ile1.png')
                    $('#ile').css('bottom','125px')
                    $('#ile').css('left',220 + 1200 + 'px')
                } else if(monde == 9){
                    $('#ile').attr('src','images/loadly ridgees.png')
                    $('#ile').css('bottom','100px')
                    $('#ile').css('left',120 + 1200 + 'px')
                } else if(monde == 10){
                    //console.log("AHHH")
                    
                } else if(monde == 11){
                    $('#ile').attr('src','../images/ile1.png')
                    $('#ile').css('bottom','125px')
                    $('#ile').css('left', 220 + 1200 + 'px')
                } else if(monde == 12){
                    $('#ile').attr('src','images/last outpost.png')
                } else if(monde == 13){
                    //console.log("AHHH")
                    $('#ile').css('display','none')
                }
                
            }
            
            
    
    
            if (compteur > (limit + 100) && !stop) {
                let leftValue_bg = parseFloat($('#ile').css('left'));
                let nouvelleValeurbg = leftValue_bg - 1 - vitesse;
    
                $('#ile').css('left', nouvelleValeurbg + 'px');
    
                if (nouvelleValeurbg < 220) {
                    
                        pop_ile(ileId);
                        $('#ile').css('left', '220px');
                        clearInterval(intervalId);
                        
                        $('#radeau').css('display','none');

                }
            }
        }, 40);
    
    }else{
        fin();
    }
}


function creer_quete(desc){
    var img = document.createElement('img');
    var h3 = document.createElement('h3');
    img.src = 'images/case2.png';
    h3.textContent = desc;
    var div = document.createElement('div')
    div.appendChild(img)
    div.appendChild(h3);
    $('#quests').append(div)
}

var intervalId2 = setInterval(function () {
    if(touche_peche && touche_lettre && quest == 1){
        //clearInterval après
        clearInterval(intervalId2);
        quest++;
        $('#quests > div > h3').css('text-decoration', 'line-through');
        setTimeout(function(){
            update_quest(quest);
        },2000)
        
    }
},40)

/**
function notif(texte){
    $('#notifs').text(texte)
    setTimeout(function(){
        $('#notifs').text('')
    },2000)
}
**/

function notif(texte){
    var menu = $('#menu_ile').css('display');
    if(menu == 'none'){
        $('#notif').css('left','57%')
    }else{
        $('#notif').css('left','50%')
    }
    $('#notif').css('display','block')
    $('#edit').text(texte)
    setTimeout(function(){
        $('#notif').css('display','none')
    },2000)
}

setInterval(function(){
        var leftValue_bg = parseFloat($('#clouds').css('left'));
        var nouvelleValeurbg = leftValue_bg - 1 - vitesse + 2;
        var leftValue_bg2 = parseFloat($('#clouds2').css('left'));
        var nouvelleValeurbg2 = leftValue_bg2 - 1 - vitesse + 2;
        
        if(nouvelleValeurbg<-1200){
            nouvelleValeurbg = 1200;
        }
        
        if(nouvelleValeurbg2<-1200){
            nouvelleValeurbg2 = 1200;
        }
        //console.log(nouvelleValeurbg)
        $('#clouds').css('left', nouvelleValeurbg + 'px');
        $('#clouds2').css('left', nouvelleValeurbg2 + 'px');
},40)


////

var monde = 0;
var quest = 0;
var niv = 0;
var bateau = 0;
var mess=0;

var index10 = 0;
setInterval(function(){
    index10++
    $('#fishing_road').attr('src','../images/fishing_road1' + index10 + '.png')
    if(index10 ==4){
        index10=0;
    }
},400)

function or(plus,nb){
    var or = $('#golds').text();
    or = parseInt(or.match(/\d+/)[0], 10)
    if(plus == 'plus'){
        $('#golds').text(or + nb)
    }else{
        $('#golds').text(or - nb)
    }
}

$('#sauvegarder').on('click',function(){
    save();
})

function save(){
    var cause2 = "give";
    
    var vie4 = $('#life').text();
    vie4 = parseInt(vie4.match(/\d+/)[0], 10)
    var vivres4 = $('#food').text();
    vivres4 = parseInt(vivres4.match(/\d+/)[0], 10)
    
    var gold4 = $('#golds').text();
    //var gold5 = parseInt(gold4.match(/\d+/)[0], 10)
    
    //var niv2 = $('#niv').text();
    //var niv3 = parseInt(niv2.match(/\d+/)[0], 10)
    
    //var bateau_src = $('#radeau').attr('src');
    //var id_bateau = parseInt(bateau_src.match(/\d+/)[0], 10);
    

    
    $.ajax({
        url:'../data.php',
        data:{cause:cause2,vie:vie4,vivres:vivres4,gold:gold4,monde:monde,quest:quest,niv:niv,bateau:bateau,mess:mess},
        type:'POST',
        success: function(res){
                //console.log(res)
        }
    })
        
    cause2 = 'send2';
    $.ajax({
        url:'supp.php',
        type:'POST',
        success: function(res){
            let enfants = $('#inventaire').children();
            Array.from(enfants).forEach(enfant => {
                let img = enfant.querySelector('.hey');
                if (img) {
                    var nom = img.src.split('/').pop().replace('.png', '');
                }
                let h3 = enfant.querySelector('.quantite');
                        
                if (h3) {
                    quantite = h3.textContent;
                    quantite = parseInt(quantite.match(/\d+/)[0]);
                    //ICI MODIFIER EN INT
                    //console.log(nom)
                    //console.log(quantite)
                }
                
                console.log(nom);
                console.log(quantite);
        
                $.ajax({
                    url:'../inv.php',
                    data:{cause2:cause2,nom:nom,quantite:quantite},
                    type:'POST',
                    success: function(res){
                        notif('Sauvegarde effectuée avec succès')
                        //console.log(res)
                    }
                })
                    
            });
        }
    })

    
}



//detecter le click sur un des objets de l'inventaire

//setTimeout(mise_en_place, 500);
var pechee = false;

//add('map',1)

$('#map2').on('click',function(){
    $('#map2').css('display','none')
})

$('#journal2').on('click',function(){
    $('#journal2').css('display','none')
})

$('#lettre2').on('click',function(){
    $('#lettre2').css('display','none')
})

document.getElementById('inventaire').addEventListener('click', function(e) {
    var item = e.target.closest('div');
    if (!item) return;

    var img = item.querySelector('img');
    if (img) {
        if (img.src.includes("fishing_road")) {
            handleClick4();
        } else if (img.src.includes("map")) {
            handleClickmap();
        } else if (img.src.includes("lettre")) {
            handleClicklettre();
        } else if (img.src.includes("journal")) {
            handleClickjournal();
        }
    }
});
    
    
    //PROBLEME : LORSQUE UN OBJET EST AJOUT2 A LINVENTAIRE, IL NEST PAS DEFINIT PAR LA FONCTION mise en place, ET SI ON RAPPEL LA FONCTION, les fonctions s'executent 2 fois, IL FAUDRAIT AJOUTER UN blockage ?
    function handleClickjournal(){
        var display = $('#journal2').css('display');
            if(display == "none"){
                //console.log('block')
                $('#journal2').css('display','block')
            }else{
                 $('#journal2').css('display','none')
                 //console.log('none')
            }
            $('#map2').css('display','none')
            $('#lettre2').css('display','none')
    }
    
    function handleClicklettre(){
            //console.log('LETREEEEEEEE')
            touche_lettre = true;

            var display = $('#lettre2').css('display');
            if(display == "none"){
                //console.log('block')
                $('#lettre2').css('display','block')
            }else{
                 $('#lettre2').css('display','none')
                 //console.log('none')
            }
            $('#map2').css('display','none')
            $('#journal2').css('display','none')

    }
    
    function handleClickmap(){
        $('#lettre2').css('display','none')
        $('#journal2').css('display','none')
        //console.log(monde)
            if(monde == 1){
                $('#map2').attr('src','images/map1.png');
            }
            if(monde == 2){
                $('#map2').attr('src','images/map2.png');
            }
            if(monde == 3){
                $('#map2').attr('src','images/map3.png');
            }
            if(monde == 4){
                $('#map2').attr('src','images/map4.png');
            }
            if(monde == 5){
                $('#map2').attr('src','images/map5.png');
            }
            if(monde == 6){
                $('#map2').attr('src','images/map6.png');
            }
            if(monde == 7){
                $('#map2').attr('src','images/map7.png');
            }
            if(monde == 8){
                $('#map2').attr('src','images/map6.png');
            }
            if(monde == 9){
                $('#map2').attr('src','images/map9.png');
            }
            if(monde == 10){
                $('#map2').attr('src','images/map10.png');
            }
            if(monde == 11){
                $('#map2').attr('src','images/map7.png');
            }
            if(monde == 12){
                $('#map2').attr('src','images/map9.png');
            }
            if(monde == 13){
                $('#map2').attr('src','images/map13.png');
            }
            
            /**
Seavy Bay = ile 1
The Last Outpost = ile 2;
Loadly Ridges = ile 3;
East prison = ile 4;
End Valley = ile 5;

Seavy Bay -> The last Outpost = 6
Seavy Bay -> Loadly Ridges = 7;
The Last Outpost -> Seavy Bay = 8;
The Last Outpost -> Loadly Ridges = 9;
The Last Outpost -> East Prison = 10;
Loadly Ridges -> Seavy Bay = 11;
Loadly Ridges -> The last Outpost -> 12;
Loadly Ridges -> End Valley -> 13;

 **/
            
            
            var check = $('#map2').css('display');
            if(check == 'none'){
                $('#map2').css('display','block')
            }else{
                $('#map2').css('display','none')
            }


    }
    
    function handleClick4(){
        $('#map2').css('display','none')
        $('#lettre2').css('display','none')
        if(!stop){
            touche_peche = true;
            //console.log('odazadzh')
            if(pechee == false){
                if(bateau == 1){
                    
                
                    $('#radeau').attr('src', '../images/fishing1.png');
                    $('#fishing_road').css('display', 'block');
                    $('#fishing_road0').css('display', 'block');
                }else{
                    $('#radeau').attr('src', 'images/boat1.png');
                    $('#fishing_road').css('display', 'block');
                    $('#fishing_road0').css('display', 'block');
                    $('#fishing_road').css('transform', 'scaleX(-1)');
                    $('#fishing_road').css('left','300px')
                    $('#fishing_road0').css('left', '220px');
                }
                
                pechee = true;
                peche();
            }else{
                stopFishing();
                pechee=false;
            }
        }
        
        
    }


//add('Carte', '1');

var descente; // Variable pour stocker l'intervalle de descente
var montee;
var timeoutId;

function stopFishing() {
    
    //console.log('soluce')
    // Réinitialise tout l'état lié à la pêche
    isRunning = false;
    clearInterval(montee);
    clearInterval(descente);
    clearTimeout(timeoutId);
    isClicable = false;
    touche_peche = false;
    
    index9 = 65; // Remet la position à l'état initial
    
    if(bateau == 1){

        $('#radeau').attr('src', 'images/bateau1.png');
        $('#fishing_road').css('display', 'none');
        $('#fishing_road0').css('display', 'none');
        $('#fished').css('display', 'none');
        
        $('#fishing_road0').css('bottom','65px');
        $('#fishing_road0').css('opacity', 1);
    }else{
        $('#radeau').attr('src', 'images/boat.png');
        $('#fishing_road').css('display', 'none');
        $('#fishing_road0').css('display', 'none');
        $('#fished').css('display', 'none');
    }
}



    
function poisson() {
    //console.log('pb4')
    var index9 = 65; // Position initiale
    var isClicable = false; // Permet de contrôler si un clic est possible
     // Variable pour stocker l'intervalle de montée
     // Variable pour stocker l'identifiant du setTimeout
    var isRunning = true; // Contrôle si le jeu est actif

    function descendre() {
       //console.log('pb3')
       //console.log("descendre")
        descente = setInterval(() => {
             //console.log('why')
            if (!isRunning) {
                clearInterval(descente);
                return;
            }
            if (index9 > 62) {
                index9 -= 1;
                $('#fishing_road0').css('bottom', index9 + 'px');
                timeoutId = setTimeout(() => {
                    $('#fishing_road0').css('opacity', 0);
                }, 250);
            } else {
                clearInterval(descente);
                isClicable = true;
                $('#fished').css('display', 'block');
                //console.log("Le curseur est en bas, vous pouvez cliquer !");

                // afficher une div -> attraper le poisson
                timeoutId = setTimeout(() => {
                    if (isClicable && isRunning) {
                        remonter();
                    }
                }, 400);
            }
        }, 50);
    }

    function remonter() {
        //console.log('pb2')
        montee = setInterval(() => {
            //console.log('why')
            if (!isRunning) {
                clearInterval(montee);
                return;
            }
            if (index9 < 65) {
                index9 += 1;
                $('#fishing_road0').css('bottom', index9 + 'px');
                $('#fishing_road0').css('opacity', 1); // Rend visible à nouveau
            } else {
                clearInterval(montee);
                $('#fished').css('display', 'none');
                isClicable = false; // Désactive le clic lorsque le curseur est remonté
            }
        }, 50);
        peche();
    }

    // Déclenche la descente initiale
    descendre();

    // Gestion du clic sur le poisson
    $('#fished').on('click', function () {
        if (isClicable) {
            //console.log("Clic détecté pendant que le curseur est en bas !");
            isClicable = false;
            $('#fishing_road').css('display', 'none');
            $('#fishing_road0').css('display', 'none');
            $('#fished').css('display', 'none');
            
            const tableau = ["thon", "saumon", "bar"];
            const itemAleatoire = tableau[Math.floor(Math.random() * tableau.length)];
            

            notif("Vous avez attrapé un " + itemAleatoire + " !")
            add(itemAleatoire, '1');

            
            clearInterval(montee);
            clearInterval(descente);
            clearTimeout(timeoutId);

        }
    });
}

setInterval(function(){
    var src = $('#radeau').attr('src');
    if(src == '../images/bateau1.png' || src == 'images/bateau1.png'){
        clearInterval(montee);
        clearInterval(descente);
        clearTimeout(timeoutId);
        isClicable = false;
    }else{
        
    }
},40)

function peche() {
    //console.log('pb1')
    timeoutId = setTimeout(function () {
        var intervalId = setInterval(function () {
            let randomNumber = Math.floor(Math.random() * 3) + 1;
            if (randomNumber == 1) {
                poisson();
                clearInterval(intervalId);
            }
        }, 1000);
        //console.log('pb5')
    }, 1000);
}




//EAU

var vitesse = 3;

var eau_src = $('#eau').attr('src');
var eau_index = parseInt(eau_src.match(/\d+/)[0]);

setInterval(function(){
    eau_index++;
    var eau_src2 = "../aie/Untitled000" + eau_index + ".png";
    $('#eau').attr('src',eau_src2);
    if(eau_index>86574){
        eau_index=86402;
    }
    //console.log(vitesse)
},60)

//dérive du bateau

var boat = document.querySelectorAll('.boat');
var derive = 0;
var derive_var = true;

setInterval(function(){
    boat.forEach(index =>{
        if(!stop && derive_var){
            
        
            var leftValue = parseFloat(window.getComputedStyle(index).left)
            var nouvelleValeur3 = 0;
                    
            if(derive<34){
                nouvelleValeur3 = leftValue + 1;
            }else{
                nouvelleValeur3 = leftValue - 0.5;
            }
            nouvelleValeur3 = nouvelleValeur3
            index.style.left = nouvelleValeur3 + 'px';
            
            }
            })
            derive++;
            
            if(derive>100){
                derive=0;
            }
        
        
},40)

var touched = false;
setInterval(function(){
    //console.log(vitesse)
    boat.forEach(index =>{
        var leftValue = parseFloat(window.getComputedStyle(index).left)
        /**
        if(!stop && leftValue < 400 && touched){
            var nouvelleValeur3 = 0;
            nouvelleValeur3 = leftValue + 1;
            nouvelleValeur3 = nouvelleValeur3 + vitesse;
            index.style.left = nouvelleValeur3 + 'px';
        }
        **/
        
    })
    if(bateau == 2 && !stop){
        derive_var=false;
        //console.log('bateau 2')
        document.addEventListener('keydown', (event) => {
            if (event.key === 'd' || event.key === 'D') {
                vitesse=8;
                touched=true;
            
            }
        })
        document.addEventListener('keyup', (event) => {
            vitesse=3;
            touched=false;
        })
    }
    
},40)


var cause = "lookfor";
    $.ajax({
            url:'../data.php',
            data:{cause:cause},
            type:'POST',
            success: function(res){
                tab = res.split(',');
                vie = tab[0];
                vivres = tab[1];
                gold2 = tab[2];
                monde = tab[3];
                quest = tab[4];
                niv = tab[5];
                bateau = tab[6];
                mess = tab[7];
                
                console.log(monde)
                
                if(quest >1){
                    update_quest(quest)
                }
                
                if(bateau > 1){
                    $('#contain_repair').css('display','none');
                    $('#radeau').attr('src','images/boat.png');
                    $('#radeau').css('height','auto')
                    $('#radeau').css('width','400px');
                    $('#radeau').css('left','300px');
                    $('#radeau').css('bottom','20px')
                    
                    $('#info_bateau').attr('src','images/boat.png')
                    $('#info_bateau').css('width','120px')
                }
                
                if(monde < 6 && monde > 0){
                    $('#ile').css('left','220px');
                    pop_ile(monde);
                    $('#radeau').css('display','none');
                }else if(monde == 0){
                    //console.log('monde 0')
                }else{

                    if(monde == 8 || monde == 9){
                        $('#ile').attr('src','images/last outpost.png')

                    }
                    if(monde == 12 || monde == 11 || monde == 13){
                        $('#ile').attr('src','images/loadly ridgees.png')
                        $('#ile').css('bottom','100px')
                        $('#ile').css('left','120px')

                    }
                    
                    
                    
                    //affecter la source de l'ile ici !
                    
                    gestion_ile(monde)
                }
                
                
                
                
                $('#life').text(vie + "%");
                $('#food').text(vivres + "%")
                $('#golds').text(gold2)
                
            }
        })
    var cause2 = 'take';
    $.ajax({
            url:'../inv.php',
            data:{cause2:cause2},
            type:'POST',
            success: function(res){
                var tab = res.split('.');
                tab.pop();
                tab.forEach(index =>{
                    var tab2 = index.split(',');

                    add(tab2[0],tab2[1]);
                })
            }
        })


function add_market(obj, quantite2,ile) {
    
const contain1 = document.createElement('div');
contain1.classList.add('contain1');

// Création de l'image
const img = document.createElement('img');
img.src = 'images/'+ obj +'.png';
contain1.appendChild(img);

// Création de la div interne
const contain2 = document.createElement('div');
contain2.classList.add('contain2');

// Création du titre
const title = document.createElement('h2');
title.textContent = obj;
contain2.appendChild(title);

var prix=0;
//console.log(ile)
    
    if(ile ==1){
        
        //seavy bay
        if(obj == "bar"){
            prix = 15;
        }
        if(obj == "saumon"){
            prix = 20;
        }
        if(obj == "thon"){
            prix = 15;
        }
        if(obj == "map"){
            prix = "25";
        }
        if(obj == "journal"){
            prix = 50;
        }
        if(obj == "marchandises"){
            prix = 50;
        }

    }
    
    if(ile ==2){
        
        //the last outpost
        if(obj == "bar"){
            prix = 20;
        }
        if(obj == "saumon"){
            prix = 25;
        }
        if(obj == "thon"){
            prix = 20;
        }
        if(obj == "map"){
            prix = 20;
        }
        if(obj == "journal"){
            prix = 45;
        }
        if(obj == "marchandises"){
            prix = 40;
        }

    }
    
    if(ile ==3){
        //loadly ridges
        if(obj == "bar"){
            prix = 20;
        }
        if(obj == "saumon"){
            prix = 35;
        }
        if(obj == "thon"){
            prix = 20;
        }
        if(obj == "map"){
            prix = 60;
        }
        if(obj == "journal"){
            prix = 75;
        }
        if(obj == "marchandises"){
            prix = 25;
        }
        if(obj == "boussole"){
            prix = 75;
        }

    }
    


// Création de la div pour le prix
const priceDiv = document.createElement('div');
const priceLabel = document.createElement('h3');
priceLabel.textContent = 'Prix : ';
const priceValue = document.createElement('h3');
priceValue.textContent = prix + 'or';
priceDiv.appendChild(priceLabel);
priceDiv.appendChild(priceValue);
contain2.appendChild(priceDiv);

// Création de la div pour la quantité
const quantityDiv = document.createElement('div');
const quantityLabel = document.createElement('h3');
quantityLabel.textContent = 'Quantite : ';
const decreaseBtn = document.createElement('h3');
decreaseBtn.classList.add('g');
decreaseBtn.textContent = '<';
const quantityValue = document.createElement('h3');
quantityValue.textContent = quantite2;
const increaseBtn = document.createElement('h3');
increaseBtn.classList.add('d');
increaseBtn.textContent = '>';



decreaseBtn.addEventListener('click',function(){
    var quantite = parseInt(quantityValue.textContent, 10);
    if(quantite > 0){
        quantite--;
    }
    quantityValue.textContent = quantite;

    
})

increaseBtn.addEventListener('click',function(){
    var quantite = parseInt(quantityValue.textContent, 10);
    quantite++;
    quantityValue.textContent = quantite;
})

quantityDiv.appendChild(quantityLabel);
quantityDiv.appendChild(decreaseBtn);
quantityDiv.appendChild(quantityValue);
quantityDiv.appendChild(increaseBtn);
if(obj != "map" && obj != "journal" && obj != "boussole"){
contain2.appendChild(quantityDiv);
}

// Création du bouton d'achat
const buyBtn = document.createElement('h2');
buyBtn.classList.add('achet');
buyBtn.textContent = 'Acheter';
contain2.appendChild(buyBtn);

buyBtn.addEventListener('click',function(){
    var sous = $('#golds').text();
    //console.log(prix)
    var result = sous - prix;
    if(result >= 0){
        var quantite = parseInt(quantityValue.textContent, 10);
        sous = sous - prix * quantite;
        $('#golds').text(sous)
        
        //ajouter quant à l'inventaire 
        
        add(obj,quantite)
        
        if(obj == "journal" ){
            var divs = document.querySelectorAll('#contain_buy div');
            divs.forEach(item=>{
                var h2s = item.querySelectorAll('h2')
                h2s.forEach(item2=>{
                    if(item2.textContent == "journal"){
                        item.remove();
                    }
                })
            });
        }
        
        if(obj == "map" ){
            var divs = document.querySelectorAll('#contain_buy div');
            divs.forEach(item=>{
                var h2s = item.querySelectorAll('h2')
                h2s.forEach(item2=>{
                    if(item2.textContent == "map"){
                        item.remove();
                    }
                })
            });
        }
        
        if(obj == "boussole" ){
            var divs = document.querySelectorAll('#contain_buy div');
            divs.forEach(item=>{
                var h2s = item.querySelectorAll('h2')
                h2s.forEach(item2=>{
                    if(item2.textContent == "boussole"){
                        item.remove();
                    }
                })
            });
        }
        //mise_en_place();
    }else{
        notif("Vous n'avez pas assez d'argent !")
    }
    
})

// Ajout de contain2 à contain1
contain1.appendChild(contain2);


$('#contain_buy').append(contain1)

}

function supp(obj,quantite2){
    
    const div = document.querySelector('div[title=' + obj + '');

    if (div) {
        var h2 = div.querySelector('.quantite');
        h3 = h2.textContent;
        h3 = parseInt(h3, 10);
        //console.log(h2)
        
        var quantite = parseInt(quantite2, 10);
        if((h3 - quantite) > 0){
            h3 = h3 - quantite;
            h2.textContent = h3;
        }else{
            div.remove();
            
            const divs = document.querySelectorAll('#contain_sell div');

            divs.forEach(div2 => {
                const h2 = div2.querySelector('h2');
                if (h2 && h2.textContent.trim() === obj) {
                    div2.remove();
                }
            });

            
        }
    } else {
        //console.log("Aucune div avec title='saumon' trouvée.");
    }

    
}

function add(obj, quantite2) {
    var enfants = document.querySelectorAll('#inventaire > div');
    var tableauEnfants = Array.from(enfants);
    
    // Trouver la div contenant l'objet (Poisson)
    var divPoisson = tableauEnfants.find(function(div) {
        var img = div.querySelector('img');
        return img && img.src.includes(obj);
    });

    if (divPoisson) {
        //console.log('YA DEJA')
        
        var h3 = divPoisson.querySelector('h3');
        var quantite = h3.textContent.trim();
        var intquantite = parseInt(quantite.match(/\d+/)[0]);
        
        var plus = parseInt(quantite2); 
        intquantite += plus; 
        h3.textContent = `${intquantite}`;
        

    } else {
        var div = document.createElement('div');
        var img = document.createElement('img');
        var src = "images/" + obj + ".png";
        img.src = src;
        img.classList.add('hey')
        div.appendChild(img)
        
        div.setAttribute('title',obj);
        
        
        
        if(quantite2>0){

            var quant = document.createElement('img')
            quant.src = "images/quant.png";
            quant.classList.add('quant');
            
            var h3 = document.createElement('h3');
            h3.textContent = quantite2;
            h3.classList.add('quantite')
            
            div.appendChild(quant)
            div.appendChild(h3)
        }

        $('#inventaire').append(div);
    }
    

    

}

document.addEventListener("DOMContentLoaded", () => {
    document.querySelectorAll(".fishing_astuce").forEach(fishingAstuce => {
        var image = fishingAstuce.querySelector("img");
        var astuce = fishingAstuce.querySelector("p");

        if (image && astuce) {
            image.addEventListener("mouseenter", () => {
                astuce.style.display = "block";
            });

            image.addEventListener("mouseleave", () => {
                astuce.style.display = "none";
            });
        }
    });
});


</script>
</body>
</html>

Youez - 2016 - github.com/yon3zu
LinuXploit