brouillon21
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| brouillon21 [2026/05/05 21:08] – nanaki | brouillon21 [2026/05/06 09:47] (Version actuelle) – nanaki | ||
|---|---|---|---|
| Ligne 86: | Ligne 86: | ||
| <button onclick=" | <button onclick=" | ||
| + | |||
| + | <button onclick=" | ||
| + | <button onclick=" | ||
| + | <button onclick=" | ||
| <pre id=" | <pre id=" | ||
| Ligne 555: | Ligne 559: | ||
| result.textContent = | result.textContent = | ||
| - | "===== STATS =====\n" | + | |
| + | "===== PERSONNAGE =====\n" | ||
| + | "Race : " | ||
| + | |||
| + | "\n\n===== STATS =====\n" | ||
| JSON.stringify(char, | JSON.stringify(char, | ||
| Ligne 578: | Ligne 586: | ||
| "Jet FM : " | "Jet FM : " | ||
| sorts; | sorts; | ||
| - | |||
| - | |||
| } | } | ||
| Ligne 661: | Ligne 667: | ||
| updateCost(); | updateCost(); | ||
| })); | })); | ||
| + | |||
| // ===== INIT ===== | // ===== INIT ===== | ||
| Ligne 666: | Ligne 673: | ||
| calculate(); | calculate(); | ||
| calculatePush(); | calculatePush(); | ||
| + | |||
| + | |||
| + | // ===== ENCODE / DECODE ULTRA SIMPLE ===== | ||
| + | function encodeBuild(data){ | ||
| + | return JSON.stringify(data); | ||
| + | } | ||
| + | |||
| + | function decodeBuild(code){ | ||
| + | return JSON.parse(code); | ||
| + | } | ||
| + | |||
| + | // ===== EXPORT ===== | ||
| + | function exportBuild(){ | ||
| + | |||
| + | let data = { | ||
| + | race: raceSelect.value, | ||
| + | stats: {}, | ||
| + | equip: {}, | ||
| + | skills: [], | ||
| + | spells: [] | ||
| + | }; | ||
| + | |||
| + | for(let s in costTable){ | ||
| + | data.stats[s] = +document.getElementById(s).value || 0; | ||
| + | } | ||
| + | |||
| + | Object.entries(slots).forEach(([k, | ||
| + | data.equip[k] = s.value; | ||
| + | }); | ||
| + | |||
| + | document.querySelectorAll(" | ||
| + | data.skills.push(s.dataset.name); | ||
| + | }); | ||
| + | |||
| + | document.querySelectorAll(" | ||
| + | data.spells.push({ | ||
| + | dex: +s.dataset.dex, | ||
| + | prot: +s.dataset.prot | ||
| + | }); | ||
| + | }); | ||
| + | |||
| + | let code = encodeBuild(data); | ||
| + | |||
| + | // 🔥 important → stringify lisible | ||
| + | prompt(" | ||
| + | } | ||
| + | |||
| + | // ===== IMPORT ===== | ||
| + | function importBuild(codeInput){ | ||
| + | |||
| + | let code = codeInput || prompt(" | ||
| + | if(!code) return; | ||
| + | |||
| + | try{ | ||
| + | |||
| + | code = code.trim(); | ||
| + | |||
| + | let data = decodeBuild(code); | ||
| + | |||
| + | raceSelect.value = data.race; | ||
| + | |||
| + | for(let s in costTable){ | ||
| + | document.getElementById(s).value = data.stats[s] || 0; | ||
| + | } | ||
| + | |||
| + | Object.entries(slots).forEach(([k, | ||
| + | s.value = data.equip[k] || ""; | ||
| + | }); | ||
| + | |||
| + | document.querySelectorAll(" | ||
| + | s.checked = data.skills.includes(s.dataset.name); | ||
| + | }); | ||
| + | |||
| + | document.querySelectorAll(" | ||
| + | s.checked = data.spells.some(sp => | ||
| + | sp.dex == +s.dataset.dex && sp.prot == +s.dataset.prot | ||
| + | ); | ||
| + | }); | ||
| + | |||
| + | displayBase(); | ||
| + | checkLimit(); | ||
| + | autoCalculate(); | ||
| + | |||
| + | }catch(e){ | ||
| + | alert(" | ||
| + | console.log(e); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | // ===== LIEN PARTAGE ===== | ||
| + | function copyLink(){ | ||
| + | |||
| + | let data = { | ||
| + | race: raceSelect.value, | ||
| + | stats: {}, | ||
| + | equip: {}, | ||
| + | skills: [], | ||
| + | spells: [] | ||
| + | }; | ||
| + | |||
| + | for(let s in costTable){ | ||
| + | data.stats[s] = +document.getElementById(s).value || 0; | ||
| + | } | ||
| + | |||
| + | Object.entries(slots).forEach(([k, | ||
| + | data.equip[k] = s.value; | ||
| + | }); | ||
| + | |||
| + | document.querySelectorAll(" | ||
| + | data.skills.push(s.dataset.name); | ||
| + | }); | ||
| + | |||
| + | document.querySelectorAll(" | ||
| + | data.spells.push({ | ||
| + | dex: +s.dataset.dex, | ||
| + | prot: +s.dataset.prot | ||
| + | }); | ||
| + | }); | ||
| + | |||
| + | let code = encodeBuild(data); | ||
| + | |||
| + | // 🔥 ENCODAGE URL OBLIGATOIRE | ||
| + | let url = window.location.origin + window.location.pathname + "? | ||
| + | |||
| + | navigator.clipboard.writeText(url).catch(()=> | ||
| + | prompt(" | ||
| + | }); | ||
| + | |||
| + | alert(" | ||
| + | } | ||
| + | |||
| + | // ===== AUTO LOAD URL ===== | ||
| + | (function(){ | ||
| + | |||
| + | let params = new URLSearchParams(window.location.search); | ||
| + | let code = params.get(" | ||
| + | |||
| + | if(!code) return; | ||
| + | |||
| + | try{ | ||
| + | code = decodeURIComponent(code); | ||
| + | importBuild(code); | ||
| + | }catch(e){ | ||
| + | console.log(" | ||
| + | } | ||
| + | |||
| + | })(); | ||
| </ | </ | ||
| </ | </ | ||
| </ | </ | ||
brouillon21.1778008135.txt.gz · Dernière modification : 2026/05/05 21:08 de nanaki
