Commit 1a585a58 authored by thibaut-felten's avatar thibaut-felten

ménage

parent 5085fdff
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TP 3.1</title>
</head>
<body>
<div id="board">
<div id="p1">
<div class="avatar_info"><img id="img" src="img.jpg"/></div>
<div class="hand">
<button class="tile" data-value="5" data-family="bamboo">5 b</button>
<button class="tile" data-value="5" data-family="bamboo">5 b</button>
<button class="tile" data-value="5" data-family="bamboo">5 b</button>
</div>
<div class="actionZone">
<p> Action zone </p>
<div class="pon" data-turn="3" data-status="visible">
<button class="tile" data-value="4" data-family="circle">4 c</button>
<button class="tile" data-value="4" data-family="circle">4 c</button>
<button class="tile" data-value="4" data-family="circle">4 c</button>
</div>
</div>
</div>
</div>
<button id="drawForExample"></button>
<button id="Kan">Kan</button>
</body>
<script src="script.js" ></script>
</html>
var drawButton = document.getElementById("drawForExample");
var img = document.getElementById("img");
let hand = document.querySelector(".hand");
let kanButton = document.querySelector("#Kan");
let actionZone = document.querySelector(".actionZone");
function draw(){
console.log(hand);
let tile = document.createElement("button");
tile.setAttribute("class", "tile");
tile.setAttribute("data-value", "5");
tile.setAttribute("data-family", "bamboo");
tile.textContent = "5 b";
console.log(tile);
let newTile = hand.appendChild(tile);
}
function countTiles(){
var par = document.querySelector(".avatar_info");
let count = hand.childElementCount;
let n = document.createElement("div");
n.setAttribute("class", "countIndic")
n.textContent = count + " tiles";
let ntnte = par.appendChild(n);
}
function deleteCount(){
var countIndicator = document.querySelector(".countIndic");
countIndicator.remove();
}
function kan(tiles){
// let value = tiles[0].dataset.value;
let value = 5;
let family = "bamboo";
tiles.forEach(element => {
element.remove();
});
let newKan = document.createElement("div");
newKan.setAttribute("class", "kan");
newKan.setAttribute("data-status", "visible");
newKan.setAttribute("data-turn", "4");
let kanZone = actionZone.appendChild(newKan);
for(let i = 0; i < 4; i++){
let tile = document.createElement("button");
tile.setAttribute("class", "tile");
tile.setAttribute("data-value", value);
tile.setAttribute("data-family", family);
tile.textContent= "5 b";
kanZone.appendChild(tile);
}
}
drawButton.addEventListener("click", () => draw());
img.addEventListener('mouseover', () => countTiles());
img.addEventListener('mouseleave', () => deleteCount())
kanButton.addEventListener('click', () => kan(tiles));
\ No newline at end of file
Binary files a/frontend/src/model/README.md and /dev/null differ Binary files a/frontend/src/model/README.md and /dev/null differ
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment