MediaWiki:Common.js:修订间差异

来自赛尔号精灵图鉴
跳转到导航 跳转到搜索
无编辑摘要
标签已被回退
无编辑摘要
标签已被回退
第8行: 第8行:
});
});


<style>
document.addEventListener("DOMContentLoaded", function () {
.stat-calc {
   function getNatureModifiers(nature) {
   background: rgba(255,255,255,0.8);
    const map = {
  padding: 15px;
      adamant: [1.1, 1.0, 1.0, 0.9, 1.0], // +Atk -SpA
  border-radius: 10px;
      modest: [0.9, 1.0, 1.0, 1.1, 1.0],  // -Atk +SpA
  max-width: 600px;
      jolly:  [1.0, 1.0, 1.0, 0.9, 1.1],  // -SpA +Spe
   margin: 0 auto;
      bold[0.9, 1.1, 1.0, 1.0, 1.0],  // -Atk +Def
  font-family: sans-serif;
      calm[0.9, 1.0, 1.0, 1.0, 1.1],  // -Atk +SpD
}
      neutral: [1, 1, 1, 1, 1]
.config-block {
    };
  display: flex;
    return map[nature] || map["neutral"];
   flex-wrap: wrap;
   }
  gap: 10px;
 
  align-items: center;
  function calcStats() {
   margin-bottom: 10px;
    const level = parseInt(document.getElementsByName("level2")[0].value);
}
    const iv = parseInt(document.getElementsByName("geti")[0].value);
.config-block label {
    const natureKey = document.getElementsByName("character")[0].value;
  display: flex;
    const natures = getNatureModifiers(natureKey);
  flex-direction: column;
    const baseStats = document.querySelectorAll("._race2");
  font-size: 14px;
    const evs = document.getElementsByName("ev");
}
    const results = document.querySelectorAll(".result");
.stat-table {
 
  width: 100%;
    let totalEV = 0;
  border-collapse: collapse;
 
  margin-top: 10px;
    for (let i = 0; i < 6; i++) {
}
      const base = parseInt(baseStats[i].textContent || "0");
.stat-table th, .stat-table td {
      const ev = parseInt(evs[i].value || "0");
  border: 1px solid #ccc;
      totalEV += ev;
  padding: 5px;
 
  text-align: center;
      let stat = 0;
}
      if (i === 0) {
.stat-table input {
        stat = Math.floor(((base * 2 + iv + Math.floor(ev / 4)) * level) / 100 + level + 10);
  width: 60px;
      } else {
}
        stat = Math.floor(((((base * 2 + iv + Math.floor(ev / 4)) * level) / 100) + 5) * natures[i - 1]);
.result {
      }
  font-weight: bold;
      results[i].textContent = stat;
  color: #FF6600;
    }
}
 
#calc-btn {
    document.getElementById("ev-remaining").textContent = Math.max(510 - totalEV, 0);
  background: #4CAF50;
   }
  color: white;
 
  border: none;
  document.getElementById("calc-btn").addEventListener("click", calcStats);
  padding: 6px 12px;
});
  border-radius: 4px;
   cursor: pointer;
}
#calc-btn:hover {
  background: #45a049;
}
</style>

2025年5月10日 (六) 16:36的版本

/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
$(function () {
  // 只在条目页面生效,不影响首页/编辑页等
  if (mw.config.get("wgNamespaceNumber") === 0) {
    $('<a href="/index.php/首页" id="return-home-button">← 返回首页</a>')
      .appendTo('body');
  }
});

document.addEventListener("DOMContentLoaded", function () {
  function getNatureModifiers(nature) {
    const map = {
      adamant: [1.1, 1.0, 1.0, 0.9, 1.0], // +Atk -SpA
      modest: [0.9, 1.0, 1.0, 1.1, 1.0],  // -Atk +SpA
      jolly:  [1.0, 1.0, 1.0, 0.9, 1.1],  // -SpA +Spe
      bold:   [0.9, 1.1, 1.0, 1.0, 1.0],  // -Atk +Def
      calm:   [0.9, 1.0, 1.0, 1.0, 1.1],  // -Atk +SpD
      neutral: [1, 1, 1, 1, 1]
    };
    return map[nature] || map["neutral"];
  }

  function calcStats() {
    const level = parseInt(document.getElementsByName("level2")[0].value);
    const iv = parseInt(document.getElementsByName("geti")[0].value);
    const natureKey = document.getElementsByName("character")[0].value;
    const natures = getNatureModifiers(natureKey);
    const baseStats = document.querySelectorAll("._race2");
    const evs = document.getElementsByName("ev");
    const results = document.querySelectorAll(".result");

    let totalEV = 0;

    for (let i = 0; i < 6; i++) {
      const base = parseInt(baseStats[i].textContent || "0");
      const ev = parseInt(evs[i].value || "0");
      totalEV += ev;

      let stat = 0;
      if (i === 0) {
        stat = Math.floor(((base * 2 + iv + Math.floor(ev / 4)) * level) / 100 + level + 10);
      } else {
        stat = Math.floor(((((base * 2 + iv + Math.floor(ev / 4)) * level) / 100) + 5) * natures[i - 1]);
      }
      results[i].textContent = stat;
    }

    document.getElementById("ev-remaining").textContent = Math.max(510 - totalEV, 0);
  }

  document.getElementById("calc-btn").addEventListener("click", calcStats);
});
👥 当前在线人数:65