CharakterCreator: Unterschied zwischen den Versionen

Aus Dunkelherzen Wiki
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
 
(21 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
<html>
<html>
<style>
<head>
  .creator-form {
  <meta charset="UTF-8" />
    max-width: 800px;
  <style>
    margin: auto;
    .creator-form {
    font-family: sans-serif;
      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>
</head>
<body>
  <div class="creator-form">
    <h2>Charakter Creator</h2>


  .creator-form label {
    <label for="name">Name:</label>
    font-weight: bold;
     <input type="text" id="name" placeholder="Name des Charakters">
     display: block;
    margin-top: 10px;
  }


  .creator-form input,
    <label for="speziestyp">Speziestyp:</label>
  .creator-form select {
    <select id="speziestyp">
    width: 100%;
      <option value="">Keine</option>
    padding: 5px;
      <option value="Humanoid">Humanoid</option>
     margin-bottom: 10px;
      <option value="Ätherer">Ätherer</option>
  }
      <option value="Mensch-Ätherer">Mensch-Ätherer</option>
      <option value="Andere Ätherer">Andere Ätherer</option>
      <option value="Non-Humanoide / Andere">Non-Humanoide / Andere</option>
      <option value="Xeutano">Xeutano</option>
      <option value="Androidenartige">Androidenartige</option>
  <option value="Androidenartige">Androiden</option>
     </select>


  .creator-form button {
     <label for="rasse">Spezies:</label>
     margin-top: 15px;
     <select id="rasse">
     padding: 10px;
      <option value="">Keine</option>
     width: 100%;
     </select>
  }


  .attribute-inputs {
     <label for="subspezies">Subspezies:</label>
     display: grid;
     <select id="subspezies">
     grid-template-columns: 1fr 1fr;
      <option value="">Keine (+20 GP Ausgleich)</option>
     gap: 10px;
      <option value="Waldelf">Waldelf</option>
  }
      <option value="Stadelf">Stadelf</option>
     </select>


  .output {
     <label for="klasse">Klasse:</label>
     margin-top: 20px;
     <select id="klasse">
     padding: 10px;
      <option value="">Keine</option>
    background: #f8f8f8;
      <option value="Arbeiter">Arbeiter</option>
    border: 1px solid #ccc;
      <option value="Barde">Barde</option>
     white-space: pre-wrap;
      <option value="Bote">Bote</option>
  }
      <option value="Gelehrter">Gelehrter</option>
      <option value="Gläubiger">Gläubiger</option>
      <option value="Kind">Kind</option>
      <option value="Krieger">Krieger</option>
      <option value="Schurke">Schurke</option>
      <option value="Schütze">Schütze</option>
      <option value="Seelenkünstler">Seelenkünstler</option>
      <option value="Soldat">Soldat</option>
      <option value="Techniker">Techniker</option>
      <option value="Vagabunde">Vagabunde</option>
     </select>


  .points-remaining {
     <label for="subklasse">Subklasse:</label>
     font-weight: bold;
     <select id="subklasse">
     color: #b00;
      <option value="">Keine (+15 GP Ausgleich)</option>
    margin-top: 10px;
      <option value="Auserwählter">Auserwählter</option>
  }
      <option value="Diener">Diener</option>
</style>
      <option value="Drogenjunkie">Drogenjunkie</option>
      <option value="Dummkopf">Dummkopf</option>
      <option value="Dunkler Künstler">Dunkler Künstler</option>
      <option value="Gesetzloser">Gesetzloser</option>
      <option value="Glücksspieler">Glücksspieler</option>
      <option value="Händler">Händler</option>
      <option value="Koch">Koch</option>
      <option value="Kopfgeldjäger">Kopfgeldjäger</option>
      <option value="Ödländer">Ödländer</option>
      <option value="Okkultist">Okkultist</option>
      <option value="Pazifist">Pazifist</option>
      <option value="Politiker">Politiker</option>
      <option value="Revolutionär">Revolutionär</option>
      <option value="Seefahrer">Seefahrer</option>
      <option value="Spion">Spion</option>
      <option value="Mutant">Mutant</option>
    </select>


<div class="creator-form">
    <label for="gegenstaende">Gegenstände wählen:</label>
  <h2>Charakter Creator</h2>
    <select id="gegenstaende">
      <option value="0">Keine</option>
      <option value="1">1 Gegenstand (-10 GP)</option>
      <option value="2">2 Gegenstände (-20 GP)</option>
      <option value="3">3 Gegenstände (-30 GP)</option>
    </select>


  <label for="name">Name:</label>
    <div class="points-remaining" id="punkteInfo"></div>
  <input type="text" id="name" placeholder="Name des Charakters">


  <label for="klasse">Klasse:</label>
    <label>Attribute:</label>
  <select id="klasse">
     <div class="attribute-inputs" id="attributeInputs"></div>
     <option value="">Keine</option>
    <option value="Krieger">Krieger</option>
    <option value="Magier">Magier</option>
  </select>


  <label for="subklasse">Subklasse:</label>
     <button onclick="berechneCharakter()">Charakter berechnen</button>
  <select id="subklasse">
     <button onclick="exportiereCharakter()">Exportieren</button>
     <option value="">Keine (+20 GP ausgleich)</option>
    <option value="Berserker">Berserker</option>
     <option value="Hexenmeister">Hexenmeister</option>
  </select>


  <label for="rasse">Rasse:</label>
    <div class="output" id="ausgabe"></div>
  <select id="rasse">
   </div>
    <option value="">Keine</option>
    <option value="Mensch">Mensch</option>
    <option value="Elf">Elf</option>
   </select>


   <label for="subspezies">Subspezies:</label>
   <script>
  <select id="subspezies">
    const attributeListe = [
    <option value="">Keine (+15 GP GP ausgleich)</option>
      "Agilität", "Ausdauer", "Charisma", "Geschick",
     <option value="Waldelf">Waldelf</option>
      "Intelligenz", "Konstitution", "Resistenz",
     <option value="Stadelf">Stadelf</option>
      "Stärke", "Wahrnehmung"
  </select>
     ];
     const basisPunkte = 160;


  <label for="gegenstaende">Gegenstände wählen:</label>
    const zeroBoni = () =>
  <select id="gegenstaende" onchange="updateRemainingPoints()">
      Object.fromEntries(attributeListe.map(attr => [attr, 0]));
    <option value="0">Keine</option>
    <option value="1">1 Gegenstand (+10 GP ausgleich)</option>
    <option value="2">2 Gegenstände (+20 GP ausgleich)</option>
    <option value="3">3 Gegenstände (+30 GP ausgleich)</option>
  </select>


  <div class="points-remaining" id="punkteInfo"></div>
    const klassenBoni = Object.fromEntries([
      "Arbeiter", "Barde", "Bote", "Gelehrter", "Gläubiger", "Kind", "Krieger", "Schurke",
      "Schütze", "Seelenkünstler", "Soldat", "Techniker", "Vagabunde"
    ].map(name => [name, zeroBoni()]));


  <label>Attribute:</label>
    const subklassenBoni = Object.fromEntries([
  <div class="attribute-inputs" id="attributeInputs"></div>
      "Auserwählter", "Diener", "Drogenjunkie", "Dummkopf", "Dunkler Künstler", "Gesetzloser",
      "Glücksspieler", "Händler", "Koch", "Kopfgeldjäger", "Ödländer", "Okkultist",
      "Pazifist", "Politiker", "Revolutionär", "Seefahrer", "Spion", "Mutant"
    ].map(name => [name, zeroBoni()]));


  <button onclick="berechneCharakter()">Charakter berechnen</button>
    const speziestypBoni = Object.fromEntries([
  <button onclick="exportiereCharakter()">Exportieren</button>
      "Humanoid", "Ätherer", "Mensch-Ätherer", "Andere Ätherer",
      "Non-Humanoide / Andere", "Xeutano", "Androidenartige", "Androiden"
    ].map(name => [name, zeroBoni()]));


   <div class="output" id="ausgabe"></div>
    Object.assign(speziestypBoni, {
</div>
      "Humanoid":        { "Agilität": 0, "Ausdauer": 0, "Charisma": 1, "Geschick": 0, "Intelligenz": 0, "Konstitution": 0, "Resistenz": 0, "Stärke": 0, "Wahrnehmung": 0 },
      "Ätherer":          { "Agilität": 0, "Ausdauer": 0, "Charisma": 0, "Geschick": 0, "Intelligenz": 1, "Konstitution": 0, "Resistenz": 0, "Stärke": 0, "Wahrnehmung": 0 },
      "Mensch-Ätherer":   { "Agilität": 0, "Ausdauer": 0, "Charisma": 0, "Geschick": 0, "Intelligenz": 1, "Konstitution": 0, "Resistenz": 0, "Stärke": 0, "Wahrnehmung": 0 },
      "Andere Ätherer":  { "Agilität": 0, "Ausdauer": 0, "Charisma": 0, "Geschick": 0, "Intelligenz": 0, "Konstitution": 1, "Resistenz": 0, "Stärke": 0, "Wahrnehmung": 0 },
  "Andere":    { "Agilität": 0, "Ausdauer": 0, "Charisma": 0, "Geschick": 0, "Intelligenz": 0, "Konstitution": 1, "Resistenz": 0, "Stärke": 0, "Wahrnehmung": 0 },
  "Xeutano":          { "Agilität": 0, "Ausdauer": 0, "Charisma": 0, "Geschick": 0, "Intelligenz": 0, "Konstitution": 1, "Resistenz": 0, "Stärke": 0, "Wahrnehmung": 0 },
  "Androidenartige":  { "Agilität": 0, "Ausdauer": 0, "Charisma": 0, "Geschick": 0, "Intelligenz": 0, "Konstitution": 1, "Resistenz": 0, "Stärke": 0, "Wahrnehmung": 0 },
  "Androiden":    { "Agilität": 0, "Ausdauer": 0, "Charisma": 0, "Geschick": 0, "Intelligenz": 0, "Konstitution": 1, "Resistenz": 0, "Stärke": 0, "Wahrnehmung": 0 }
    });


<script>
    const speziesNachTyp = {
  const attributeListe = [
      "Humanoid": [
    "Agilität", "Ausdauer", "Charisma", "Geschick",
        "Arcadier / Byzantone", "Astroma", "Caesaren", "Fijen", "Floratia",
    "Intelligenz", "Konstitution", "Resistenz",
        "Kalani", "Lugier", "Nore", "Pendräa", "Rubinnia", "Sowi", "Varene", "Zarcore"
    "Stärke", "Wahrnehmung"
      ],
  ];
      "Ätherer": ["Maggarn", "Sapiée"],
      "Mensch-Ätherer": ["Cilina", "Gaimane"],
      "Andere Ätherer": ["Matari"],
      "Non-Humanoide / Andere": [],
      "Xeutano": [],
      "Androidenartige": [],
  "Androiden": []
    };


  const basisPunkte = 160;
    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 klassenBoni = {
    const subspeziesBoni = {
    "Krieger": { "Agilität": 0, "Ausdauer": 1, "Charisma": 0, "Geschick": 0, "Intelligenz": 0, "Konstitution": 0, "Resistenz": 0, "Stärke": 2, "Wahrnehmung": 0 },
      "Waldelf": { "Agilität": 0, "Ausdauer": 0, "Charisma": 0, "Geschick": 1, "Intelligenz": 0, "Konstitution": 0, "Resistenz": 0, "Stärke": 0, "Wahrnehmung": 1 },
    "Magier": { "Agilität": 0, "Ausdauer": 0, "Charisma": 0, "Geschick": 0, "Intelligenz": 2, "Konstitution": 0, "Resistenz": 1, "Stärke": 0, "Wahrnehmung": 0 }
      "Stadelf": { "Agilität": 0, "Ausdauer": 0, "Charisma": 1, "Geschick": 0, "Intelligenz": 1, "Konstitution": 0, "Resistenz": 0, "Stärke": 0, "Wahrnehmung": 0 }
  };
    };


  const subklassenBoni = {
    attributeListe.forEach(attr => {
    "Berserker":    { "Agilität": 1, "Ausdauer": 1, "Charisma": 0, "Geschick": 0, "Intelligenz": 0, "Konstitution": 0, "Resistenz": 0, "Stärke": 1, "Wahrnehmung": 0 },
      const input = document.createElement("input");
    "Hexenmeister":  { "Agilität": 0, "Ausdauer": 0, "Charisma": 2, "Geschick": 0, "Intelligenz": 1, "Konstitution": 0, "Resistenz": 0, "Stärke": 0, "Wahrnehmung": 0 }
      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);
    });


  const rassenBoni = {
    function getBonus(boni, key) {
    "Mensch": { "Agilität": 0, "Ausdauer": 0, "Charisma": 1, "Geschick": 0, "Intelligenz": 0, "Konstitution": 0, "Resistenz": 0, "Stärke": 0, "Wahrnehmung": 0 },
      return boni[key] || zeroBoni();
     "Elf":    { "Agilität": 1, "Ausdauer": 0, "Charisma": 0, "Geschick": 1, "Intelligenz": 0, "Konstitution": 0, "Resistenz": 0, "Stärke": 0, "Wahrnehmung": 0 }
     }
  };


  const subspeziesBoni = {
    function sumUserInput() {
    "Waldelf":  { "Agilität": 0, "Ausdauer": 0, "Charisma": 0, "Geschick": 1, "Intelligenz": 0, "Konstitution": 0, "Resistenz": 0, "Stärke": 0, "Wahrnehmung": 1 },
      return attributeListe.reduce((sum, attr) => {
     "Stadelf":  { "Agilität": 0, "Ausdauer": 0, "Charisma": 1, "Geschick": 0, "Intelligenz": 1, "Konstitution": 0, "Resistenz": 0, "Stärke": 0, "Wahrnehmung": 0 }
        const val = parseInt(document.getElementById(`attr_${attr}`).value) || 0;
  };
        return sum + val;
      }, 0);
     }


  const attributeInputs = document.getElementById("attributeInputs");
    function updateRemainingPoints() {
  attributeListe.forEach(attr => {
      let total = basisPunkte;
    const input = document.createElement("input");
      if (!document.getElementById("subspezies").value) total += 20;
    input.type = "number";
      if (!document.getElementById("subklasse").value) total += 15;
    input.min = "0";
      total -= parseInt(document.getElementById("gegenstaende").value || "0") * 10;
    input.value = "0";
      const used = sumUserInput();
    input.id = `attr_${attr}`;
      document.getElementById("punkteInfo").textContent = `Verbleibende Punkte: ${total - used} / ${total}`;
    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) {
    function berechneCharakter() {
    return boni[key] || attributeListe.reduce((acc, attr) => (acc[attr] = 0, acc), {});
      const name = document.getElementById("name").value;
  }
      const speziestyp = document.getElementById("speziestyp").value;
      const rasse = document.getElementById("rasse").value;
      const subspezies = document.getElementById("subspezies").value;
      const klasse = document.getElementById("klasse").value;
      const subklasse = document.getElementById("subklasse").value;
      const gegenstaende = parseInt(document.getElementById("gegenstaende").value) || 0;


  function sumUserInput() {
      const basisAttribute = {};
    return attributeListe.reduce((sum, attr) => {
      attributeListe.forEach(attr => {
      const val = parseInt(document.getElementById(`attr_${attr}`).value) || 0;
        basisAttribute[attr] = parseInt(document.getElementById(`attr_${attr}`).value) || 0;
       return sum + val;
       });
    }, 0);
  }


  function updateRemainingPoints() {
      const gesamt = {};
    let total = basisPunkte;
      attributeListe.forEach(attr => {
    if (!document.getElementById("subspezies").value) total += 20;
        gesamt[attr] =
    if (!document.getElementById("subklasse").value) total += 15;
          basisAttribute[attr] +
          getBonus(speziestypBoni, speziestyp)[attr] +
          getBonus(rassenBoni, rasse)[attr] +
          getBonus(subspeziesBoni, subspezies)[attr] +
          getBonus(klassenBoni, klasse)[attr] +
          getBonus(subklassenBoni, subklasse)[attr];
      });


    const gegenstaende = parseInt(document.getElementById("gegenstaende").value) || 0;
      const daten = {
    total += gegenstaende * 10;
        Name: name,
        Speziestyp: speziestyp,
        Spezies: rasse,
        Subspezies: subspezies || "Keine (20 Punkte erhalten)",
        Klasse: klasse,
        Subklasse: subklasse || "Keine (15 Punkte erhalten)",
        Gegenstände: `${gegenstaende} (${gegenstaende * 10} Punkte abgezogen)`,
        Verwendete_Punkte: sumUserInput(),
        Gesamt_Punkte: basisPunkte + (subklasse ? 0 : 15) + (subspezies ? 0 : 20) - (gegenstaende * 10),
        Attribute: gesamt
      };


    const used = sumUserInput();
      document.getElementById("ausgabe").textContent = JSON.stringify(daten, null, 2);
     const remaining = total - used;
     }


     document.getElementById("punkteInfo").textContent = `Verbleibende Punkte: ${remaining} / ${total}`;
     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);
    }


  function berechneCharakter() {
     document.getElementById("speziestyp").addEventListener("change", function () {
     const name = document.getElementById("name").value;
      const typ = this.value;
    const klasse = document.getElementById("klasse").value;
      const rasseSelect = document.getElementById("rasse");
    const subklasse = document.getElementById("subklasse").value;
      rasseSelect.innerHTML = '<option value="">Keine</option>';
    const rasse = document.getElementById("rasse").value;
      if (speziesNachTyp[typ]) {
    const subspezies = document.getElementById("subspezies").value;
        speziesNachTyp[typ].forEach(spezies => {
    const gegenstaende = parseInt(document.getElementById("gegenstaende").value) || 0;
          const opt = document.createElement("option");
 
          opt.value = spezies;
    const basisAttribute = {};
          opt.textContent = spezies;
    attributeListe.forEach(attr => {
          rasseSelect.appendChild(opt);
       basisAttribute[attr] = parseInt(document.getElementById(`attr_${attr}`).value) || 0;
        });
      }
       updateRemainingPoints();
     });
     });


     const gesamt = {};
     document.addEventListener("DOMContentLoaded", () => {
    attributeListe.forEach(attr => {
      const inputs = document.querySelectorAll("select, input[type='number']");
      gesamt[attr] =
      inputs.forEach(el => {
         basisAttribute[attr] +
         el.addEventListener("input", updateRemainingPoints);
        getBonus(klassenBoni, klasse)[attr] +
         el.addEventListener("change", updateRemainingPoints);
         getBonus(subklassenBoni, subklasse)[attr] +
      });
        getBonus(rassenBoni, rasse)[attr] +
      updateRemainingPoints();
        getBonus(subspeziesBoni, subspezies)[attr];
     });
     });
 
   </script>
    const daten = {
</body>
      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();
</script>
</html>
</html>

Aktuelle Version vom 29. Juli 2025, 19:59 Uhr

Charakter Creator