le tableau qui tableau

This commit is contained in:
Theo Mougnibas 2024-11-29 08:50:19 +01:00
parent 5456271202
commit 8ab2691546
2 changed files with 26 additions and 4 deletions

View file

@ -19,10 +19,27 @@ function remplirMagasin(){
const cout = document.createElement("td") const cout = document.createElement("td")
cout.innerText = el.cout cout.innerText = el.cout
const test = document.createElement("td")
const btn_acheter = document.createElement("button")
let tmp = key
btn_acheter.addEventListener("click", (event) =>{
console.log("clé : ",tmp)
let t = new Technologie(tmp)
t.chargerDepuisBdd(true)
})
btn_acheter.innerText = "Acheter"
test.appendChild(btn_acheter)
tr.appendChild(nom) tr.appendChild(nom)
tr.appendChild(boost) tr.appendChild(boost)
tr.appendChild(cout) tr.appendChild(cout)
tr.appendChild(test)
table.appendChild(tr) table.appendChild(tr)
}); });
}) })

View file

@ -3,15 +3,20 @@ class Technologie{
this.nom = nom this.nom = nom
} }
chargerDepuisBdd(){ chargerDepuisBdd( style){
fetch("../bdd/arbre.json").then((data)=>{ fetch("../bdd/arbre.json").then((data)=>{
data.json().then((data)=>{ data.json().then((data)=>{
console.log(data) console.log("clé dans technologie :",this.nom)
this.props = data["technologies"][this.nom] this.props = data["technologies"][this.nom]
this.cout = this.props.cout this.cout = this.props.cout
this.boost = this.props.boost this.boost = this.props.boost
if(style){
this.appliquerAmeliorationStyle()
}
}) })
}) })
} }