MediaWiki:Common.js:修订间差异

来自赛尔号精灵图鉴
跳转到导航 跳转到搜索
无编辑摘要
标签已被回退
无编辑摘要
标签手工回退
第6行: 第6行:
       .appendTo('body');
       .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);
});
});

2025年5月11日 (日) 01:11的版本

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