projet-clicodrome/js/element.js

32 lines
No EOL
838 B
JavaScript

class Element{
constructor(techno,tag) {
this.tag = tag
this.techno = techno
}
async chargerDepuisBdd(){
let data = await fetch("../bdd/arbre.json")
data = await data.json()
this.props = data["technologies"][this.techno]["elements"][this.tag]
this.cout = this.props.cout
this.nom = this.props.nom
this.boost = this.props.boost
}
afficherDropsDansHtml(){
const table= document.getElementById("table_technologies_body")
const tr = document.createElement("tr")
const nom = document.createElement("td")
nom.innerText = this.nom
const boost = document.createElement("td")
boost.innerText = this.boost
tr.appendChild(nom)
tr.appendChild(boost)
table.appendChild(tr)
}
}