CharakterCreator: Unterschied zwischen den Versionen
Aus Dunkelherzen Wiki
DRP (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
DRP (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
| Zeile 5: | Zeile 5: | ||
margin: auto; | margin: auto; | ||
font-family: sans-serif; | font-family: sans-serif; | ||
} | } | ||
| Zeile 22: | Zeile 10: | ||
font-weight: bold; | font-weight: bold; | ||
display: block; | display: block; | ||
margin-top: | margin-top: 10px; | ||
} | } | ||
.creator-form input, .creator-form select { | .creator-form input, | ||
.creator-form select { | |||
width: 100%; | width: 100%; | ||
padding: 5px; | padding: 5px; | ||
margin-bottom: 10px; | |||
} | } | ||
.creator-form button { | .creator-form button { | ||
margin-top: | margin-top: 15px; | ||
padding: 10px; | padding: 10px; | ||
width: 100%; | width: 100%; | ||
} | |||
.attribute-inputs { | |||
display: grid; | |||
grid-template-columns: 1fr 1fr; | |||
gap: 10px; | |||
} | } | ||
.output { | .output { | ||
margin-top: | margin-top: 20px; | ||
padding: 10px; | padding: 10px; | ||
background: #f8f8f8; | background: #f8f8f8; | ||
| Zeile 44: | Zeile 40: | ||
} | } | ||
.points- | .points-remaining { | ||
font-weight: bold; | font-weight: bold; | ||
color: #b00; | |||
margin-top: 10px; | margin-top: 10px; | ||
} | } | ||
</style> | </style> | ||
| Zeile 65: | 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 value="Krieger">Krieger</option> | ||
<option value="Magier">Magier | <option value="Magier">Magier</option> | ||
</select> | </select> | ||
| Zeile 73: | Zeile 63: | ||
<select id="subklasse"> | <select id="subklasse"> | ||
<option value="">Keine</option> | <option value="">Keine</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 value="Mensch">Mensch</option> | ||
<option value="Elf">Elf | <option value="Elf">Elf</option> | ||
</select> | </select> | ||
| Zeile 87: | Zeile 77: | ||
<select id="subspezies"> | <select id="subspezies"> | ||
<option value="">Keine</option> | <option value="">Keine</option> | ||
<option value="Waldelf">Waldelf | <option value="Waldelf">Waldelf</option> | ||
<option value=" | <option value="Stadelf">Stadelf</option> | ||
</select> | </select> | ||
<div class="points- | <div class="points-remaining" id="punkteInfo"></div> | ||
< | <label>Attribute:</label> | ||
<div class="attribute-inputs" id="attributeInputs"></div> | |||
<button onclick=" | <button onclick="berechneCharakter()">Charakter berechnen</button> | ||
<button onclick=" | <button onclick="exportiereCharakter()">Exportieren</button> | ||
<div class="output" id="ausgabe"></div> | <div class="output" id="ausgabe"></div> | ||
| Zeile 113: | Zeile 93: | ||
<script> | <script> | ||
const | const attributeListe = [ | ||
"Agilität", "Ausdauer", "Charisma", "Geschick", "Intelligenz", | "Agilität", "Ausdauer", "Charisma", "Geschick", | ||
"Intelligenz", "Konstitution", "Resistenz", | |||
"Stärke", "Wahrnehmung" | |||
]; | ]; | ||
const | const basisPunkte = 160; | ||
const klassenBoni = { | const klassenBoni = { | ||
"Krieger": { "Stärke": 2, " | "Krieger": { "Agilität": 0, "Ausdauer": 1, "Charisma": 0, "Geschick": 0, "Intelligenz": 0, "Konstitution": 0, "Resistenz": 0, "Stärke": 2, "Wahrnehmung": 0 }, | ||
"Magier": { "Intelligenz": 2, "Wahrnehmung": | "Magier": { "Agilität": 0, "Ausdauer": 0, "Charisma": 0, "Geschick": 0, "Intelligenz": 2, "Konstitution": 0, "Resistenz": 1, "Stärke": 0, "Wahrnehmung": 0 } | ||
}; | }; | ||
const subklassenBoni = { | 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 = { | const rassenBoni = { | ||
"Mensch": { "Charisma": 1, "Konstitution": | "Mensch": { "Agilität": 0, "Ausdauer": 0, "Charisma": 1, "Geschick": 0, "Intelligenz": 0, "Konstitution": 0, "Resistenz": 0, "Stärke": 0, "Wahrnehmung": 0 }, | ||
"Elf": { "Geschick": 1, "Intelligenz": | "Elf": { "Agilität": 1, "Ausdauer": 0, "Charisma": 0, "Geschick": 1, "Intelligenz": 0, "Konstitution": 0, "Resistenz": 0, "Stärke": 0, "Wahrnehmung": 0 } | ||
}; | }; | ||
const subspeziesBoni = { | const subspeziesBoni = { | ||
"Waldelf": { "Wahrnehmung": 1 }, | "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 } | ||
}; | }; | ||
function | 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 used = sumUserInput(); | |||
const remaining = total - used; | |||
document.getElementById("punkteInfo").textContent = `Verbleibende Punkte: ${remaining} / ${total} | |||
(Du kannst theoretisch 3 Gegenstände für je +10 Punkte auswählen.)`; | |||
} | |||
function berechneCharakter() { | |||
const name = document.getElementById("name").value; | const name = document.getElementById("name").value; | ||
const klasse = document.getElementById("klasse").value; | const klasse = document.getElementById("klasse").value; | ||
| Zeile 147: | Zeile 166: | ||
const subspezies = document.getElementById("subspezies").value; | const subspezies = document.getElementById("subspezies").value; | ||
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] + | |||
const | getBonus(subklassenBoni, subklasse)[attr] + | ||
getBonus(rassenBoni, rasse)[attr] + | |||
getBonus(subspeziesBoni, subspezies)[attr]; | |||
}); | }); | ||
const daten = { | const daten = { | ||
Name: name, | Name: name, | ||
Klasse: klasse, | Klasse: klasse, | ||
Subklasse: subklasse || "Keine", | Subklasse: subklasse || "Keine (15 Punkte erhalten)", | ||
Rasse: rasse, | Rasse: rasse, | ||
Subspezies: subspezies || "Keine", | Subspezies: subspezies || "Keine (20 Punkte erhalten)", | ||
Verwendete_Punkte: sumUserInput(), | |||
Gesamt_Punkte: basisPunkte + (subklasse ? 0 : 15) + (subspezies ? 0 : 20), | |||
Hinweis: "Du kannst zusätzlich 3 Gegenstände | Hinweis: "Du kannst zusätzlich 3 Gegenstände für je 10 Punkte auswählen.", | ||
Attribute: gesamt | |||
}; | }; | ||
| Zeile 191: | Zeile 196: | ||
} | } | ||
function | function exportiereCharakter() { | ||
const | const daten = document.getElementById("ausgabe").textContent; | ||
if (! | if (!daten) { | ||
alert("Bitte | alert("Bitte zuerst berechnen!"); | ||
return; | return; | ||
} | } | ||
const blob = new Blob([daten], { type: "application/json" }); | |||
const blob = new Blob([ | |||
const url = URL.createObjectURL(blob); | const url = URL.createObjectURL(blob); | ||
const a = document.createElement("a"); | const a = document.createElement("a"); | ||
a.href = url; | a.href = url; | ||
a.download = "charakter.json"; | a.download = "charakter.json"; | ||
a.click(); | a.click(); | ||
URL.revokeObjectURL(url); | URL.revokeObjectURL(url); | ||
} | } | ||
updateRemainingPoints(); | |||
</script> | </script> | ||
</html> | </html> | ||
Version vom 26. Juli 2025, 08:09 Uhr
