MediaWiki:Gadget-stat-calc.js:修订间差异
跳转到导航
跳转到搜索
无编辑摘要 |
无编辑摘要 |
||
(未显示同一用户的1个中间版本) | |||
第3行: | 第3行: | ||
if (!tag.length) return; | if (!tag.length) return; | ||
// 从页面加载模板 HTML | |||
$.get('/index.php?title=MediaWiki:StatCalcTemplate&action=raw', function (html) { | |||
tag.replaceWith(html); | |||
initStatCalc(); // 计算逻辑 | |||
}); | |||
}); | |||
function initStatCalc() { | |||
function getNatureModifiers(nature) { | function getNatureModifiers(nature) { | ||
const map = { | const map = { | ||
第67行: | 第42行: | ||
stat = Math.floor(((base * 2 + iv + Math.floor(ev / 4)) * level) / 100 + level + 10); | stat = Math.floor(((base * 2 + iv + Math.floor(ev / 4)) * level) / 100 + level + 10); | ||
} else { | } else { | ||
stat = Math.floor(((((base * 2 + iv + Math.floor(ev / 4)) * level) / 100) + 5) | stat = Math.floor(((((base * 2 + iv + Math.floor(ev / 4)) * level) / 100) + 5) * modifiers[i - 1]); | ||
} | |||
results[i].textContent = stat; | |||
} | |||
document.getElementById("ev-remaining").textContent = Math.max(510 - totalEV, 0); | |||
}); | |||
} |
2025年5月11日 (日) 05:22的最新版本
mw.hook('wikipage.content').add(function ($content) {
const tag = $content.find('stat-calc, p:has(stat-calc), .stat-calc').first();
if (!tag.length) return;
// 从页面加载模板 HTML
$.get('/index.php?title=MediaWiki:StatCalcTemplate&action=raw', function (html) {
tag.replaceWith(html);
initStatCalc(); // 计算逻辑
});
});
function initStatCalc() {
function getNatureModifiers(nature) {
const map = {
adamant: [1.1, 1.0, 1.0, 0.9, 1.0],
modest: [0.9, 1.0, 1.0, 1.1, 1.0],
jolly: [1.0, 1.0, 1.0, 0.9, 1.1],
bold: [0.9, 1.1, 1.0, 1.0, 1.0],
calm: [0.9, 1.0, 1.0, 1.0, 1.1],
neutral: [1.0, 1.0, 1.0, 1.0, 1.0]
};
return map[nature] || map.neutral;
}
document.getElementById("calc-btn").addEventListener("click", function () {
const level = parseInt(document.getElementsByName("level2")[0].value);
const iv = parseInt(document.getElementsByName("geti")[0].value);
const evs = document.getElementsByName("ev");
const bases = document.querySelectorAll("._race2");
const results = document.querySelectorAll(".result");
const nature = document.getElementsByName("character")[0].value;
const modifiers = getNatureModifiers(nature);
let totalEV = 0;
for (let i = 0; i < 6; i++) {
const base = parseInt(bases[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) * modifiers[i - 1]);
}
results[i].textContent = stat;
}
document.getElementById("ev-remaining").textContent = Math.max(510 - totalEV, 0);
});
}
👥 当前在线人数:75