CharakterCreator: Unterschied zwischen den Versionen
Aus Dunkelherzen Wiki
DRP (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung Markierung: Zurückgesetzt |
DRP (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung Markierung: Manuelle Zurücksetzung |
||
| Zeile 1: | Zeile 1: | ||
< | <html> | ||
< | <style> | ||
.creator-form { | |||
max-width: 800px; | |||
margin: auto; | |||
font-family: sans-serif; | |||
} | |||
.creator-form label { | |||
font-weight: bold; | |||
display: block; | |||
margin-top: 10px; | |||
} | |||
.creator-form input, | |||
.creator-form select { | |||
width: 100%; | |||
padding: 5px; | |||
margin-bottom: 10px; | |||
} | |||
.creator-form button { | |||
margin-top: 15px; | |||
padding: 10px; | |||
width: 100%; | |||
} | |||
.attribute-inputs { | |||
display: grid; | |||
grid-template-columns: 1fr 1fr; | |||
gap: 10px; | |||
} | |||
.output { | |||
margin-top: 20px; | |||
padding: 10px; | |||
background: #f8f8f8; | |||
border: 1px solid #ccc; | |||
white-space: pre-wrap; | |||
} | } | ||
.points-remaining { | |||
font-weight: bold; | |||
color: #b00; | |||
margin-top: 10px; | |||
} | |||
</style> | |||
<div class="creator-form"> | |||
<h2>Charakter Creator</h2> | <h2>Charakter Creator</h2> | ||
| Zeile 60: | Zeile 55: | ||
<label for="klasse">Klasse:</label> | <label for="klasse">Klasse:</label> | ||
<select id="klasse"> | <select id="klasse"> | ||
<option value=""> | <option value="">Keine</option> | ||
<option value="Krieger">Krieger</option> | <option value="Krieger">Krieger</option> | ||
<option value=" | <option value="Magier">Magier</option> | ||
</select> | </select> | ||
<label for="subklasse">Subklasse:</label> | <label for="subklasse">Subklasse:</label> | ||
<select id="subklasse"> | <select id="subklasse"> | ||
<option value="">Keine | <option value="">Keine (+20 GP ausgleich)</option> | ||
<option value=" | <option value="Berserker">Berserker</option> | ||
<option value=" | <option value="Hexenmeister">Hexenmeister</option> | ||
</select> | </select> | ||
<label for="rasse">Rasse:</label> | <label for="rasse">Rasse:</label> | ||
<select id="rasse"> | <select id="rasse"> | ||
<option value=""> | <option value="">Keine</option> | ||
<option value="Mensch">Mensch</option> | <option value="Mensch">Mensch</option> | ||
<option value="Elf">Elf</option> | <option value="Elf">Elf</option> | ||
</select> | </select> | ||
<label for=" | <label for="subspezies">Subspezies:</label> | ||
<select id=" | <select id="subspezies"> | ||
<option value="">Keine | <option value="">Keine (+15 GP ausgleich)</option> | ||
<option value=" | <option value="Waldelf">Waldelf</option> | ||
<option value=" | <option value="Stadelf">Stadelf</option> | ||
</select> | </select> | ||
<label for=" | <label for="gegenstaende">Gegenstände wählen:</label> | ||
<select id=" | <select id="gegenstaende" onchange="updateRemainingPoints()"> | ||
<option value="0"> | <option value="0">Keine</option> | ||
<option value="1">1 Gegenstand ( | <option value="1">1 Gegenstand (-10 GP ausgleich)</option> | ||
<option value="2">2 Gegenstände ( | <option value="2">2 Gegenstände (-20 GP ausgleich)</option> | ||
<option value="3">3 Gegenstände ( | <option value="3">3 Gegenstände (-30 GP ausgleich)</option> | ||
</select> | </select> | ||
< | <div class="points-remaining" id="punkteInfo"></div> | ||
< | <label>Attribute:</label> | ||
<div class="attribute-inputs" id="attributeInputs"></div> | |||
<button | <button onclick="berechneCharakter()">Charakter berechnen</button> | ||
<button | <button onclick="exportiereCharakter()">Exportieren</button> | ||
<div class="output" id="ausgabe"></div> | <div class="output" id="ausgabe"></div> | ||
</div> | |||
<script> | |||
const attributeListe = [ | |||
"Agilität", "Ausdauer", "Charisma", "Geschick", | |||
"Intelligenz", "Konstitution", "Resistenz", | |||
"Stärke", "Wahrnehmung" | |||
]; | |||
const basisPunkte = 160; | |||
const klassenBoni = { | |||
"Krieger": { "Agilität": 0, "Ausdauer": 1, "Charisma": 0, "Geschick": 0, "Intelligenz": 0, "Konstitution": 0, "Resistenz": 0, "Stärke": 2, "Wahrnehmung": 0 }, | |||
"Magier": { "Agilität": 0, "Ausdauer": 0, "Charisma": 0, "Geschick": 0, "Intelligenz": 2, "Konstitution": 0, "Resistenz": 1, "Stärke": 0, "Wahrnehmung": 0 } | |||
}; | |||
const subklassenBoni = { | |||
"Berserker": { "Agilität": 1, "Ausdauer": 1, "Charisma": 0, "Geschick": 0, "Intelligenz": 0, "Konstitution": 0, "Resistenz": 0, "Stärke": 1, "Wahrnehmung": 0 }, | |||
"Hexenmeister": { "Agilität": 0, "Ausdauer": 0, "Charisma": 2, "Geschick": 0, "Intelligenz": 1, "Konstitution": 0, "Resistenz": 0, "Stärke": 0, "Wahrnehmung": 0 } | |||
}; | |||
const rassenBoni = { | |||
"Mensch": { "Agilität": 0, "Ausdauer": 0, "Charisma": 1, "Geschick": 0, "Intelligenz": 0, "Konstitution": 0, "Resistenz": 0, "Stärke": 0, "Wahrnehmung": 0 }, | |||
"Elf": { "Agilität": 1, "Ausdauer": 0, "Charisma": 0, "Geschick": 1, "Intelligenz": 0, "Konstitution": 0, "Resistenz": 0, "Stärke": 0, "Wahrnehmung": 0 } | |||
}; | |||
const subspeziesBoni = { | |||
"Waldelf": { "Agilität": 0, "Ausdauer": 0, "Charisma": 0, "Geschick": 1, "Intelligenz": 0, "Konstitution": 0, "Resistenz": 0, "Stärke": 0, "Wahrnehmung": 1 }, | |||
"Stadelf": { "Agilität": 0, "Ausdauer": 0, "Charisma": 1, "Geschick": 0, "Intelligenz": 1, "Konstitution": 0, "Resistenz": 0, "Stärke": 0, "Wahrnehmung": 0 } | |||
}; | |||
const attributeInputs = document.getElementById("attributeInputs"); | |||
attributeListe.forEach(attr => { | |||
const input = document.createElement("input"); | |||
}; | input.type = "number"; | ||
input.min = "0"; | |||
input.value = "0"; | |||
input.id = `attr_${attr}`; | |||
input.oninput = updateRemainingPoints; | |||
const label = document.createElement("label"); | |||
label.textContent = attr; | |||
label.htmlFor = input.id; | |||
attributeInputs.appendChild(label); | |||
attributeInputs.appendChild(input); | |||
}); | |||
function getBonus(boni, key) { | |||
return boni[key] || attributeListe.reduce((acc, attr) => (acc[attr] = 0, acc), {}); | |||
} | |||
function sumUserInput() { | |||
return attributeListe.reduce((sum, attr) => { | |||
const val = parseInt(document.getElementById(`attr_${attr}`).value) || 0; | |||
return sum + val; | |||
}, 0); | |||
} | |||
function updateRemainingPoints() { | |||
let total = basisPunkte; | |||
if (!document.getElementById("subspezies").value) total += 20; | |||
if (!document.getElementById("subklasse").value) total += 15; | |||
const gegenstaende = parseInt(document.getElementById("gegenstaende").value) || 0; | |||
total -= gegenstaende * 10; | |||
const used = sumUserInput(); | |||
const remaining = total - used; | |||
document.getElementById("punkteInfo").textContent = `Verbleibende Punkte: ${remaining} / ${total}`; | |||
} | |||
function berechneCharakter() { | |||
const name = document.getElementById("name").value; | |||
const klasse = document.getElementById("klasse").value; | |||
const subklasse = document.getElementById("subklasse").value; | |||
const rasse = document.getElementById("rasse").value; | |||
const subspezies = document.getElementById("subspezies").value; | |||
const gegenstaende = parseInt(document.getElementById("gegenstaende").value) || 0; | |||
const basisAttribute = {}; | |||
} | attributeListe.forEach(attr => { | ||
basisAttribute[attr] = parseInt(document.getElementById(`attr_${attr}`).value) || 0; | |||
}); | |||
const gesamt = {}; | |||
attributeListe.forEach(attr => { | |||
gesamt[attr] = | |||
basisAttribute[attr] + | |||
getBonus(klassenBoni, klasse)[attr] + | |||
getBonus(subklassenBoni, subklasse)[attr] + | |||
getBonus(rassenBoni, rasse)[attr] + | |||
getBonus(subspeziesBoni, subspezies)[attr]; | |||
}); | |||
const daten = { | |||
Name: name, | |||
} | Klasse: klasse, | ||
Subklasse: subklasse || "Keine (15 Punkte erhalten)", | |||
Rasse: rasse, | |||
Subspezies: subspezies || "Keine (20 Punkte erhalten)", | |||
Gegenstände: `${gegenstaende} (${gegenstaende * 10} Punkte erhalten)`, | |||
Verwendete_Punkte: sumUserInput(), | |||
Gesamt_Punkte: basisPunkte + (subklasse ? 0 : 15) + (subspezies ? 0 : 20) + (gegenstaende * 10), | |||
Attribute: gesamt | |||
}; | |||
document.getElementById("ausgabe").textContent = JSON.stringify(daten, null, 2); | |||
} | |||
function exportiereCharakter() { | |||
const daten = document.getElementById("ausgabe").textContent; | |||
if (!daten) { | |||
alert("Bitte zuerst berechnen!"); | |||
return; | |||
} | |||
const blob = new Blob([daten], { type: "application/json" }); | |||
const url = URL.createObjectURL(blob); | |||
const a = document.createElement("a"); | |||
a.href = url; | |||
a.download = "charakter.json"; | |||
a.click(); | |||
URL.revokeObjectURL(url); | |||
} | |||
updateRemainingPoints(); | |||
// Automatische Aktualisierung bei jeder Eingabe | |||
document.addEventListener("DOMContentLoaded", function () { | |||
const inputs = document.querySelectorAll("select, input[type='number']"); | |||
inputs.forEach(el => { | |||
el.addEventListener("input", updateRemainingPoints); | |||
el.addEventListener("change", updateRemainingPoints); | |||
}); | |||
}); | |||
</script> | |||
</html> | </html> | ||
Version vom 26. Juli 2025, 11:34 Uhr
