MediaWiki:WildCreatureStats.js
ナビゲーションに移動
検索に移動
注意: 保存後、変更を確認するにはブラウザーのキャッシュを消去する必要がある場合があります。
- Firefox / Safari: Shift を押しながら 再読み込み をクリックするか、Ctrl-F5 または Ctrl-R を押してください (Mac では ⌘-R)
- Google Chrome: Ctrl-Shift-R を押してください (Mac では ⌘-Shift-R)
- Internet Explorer / Microsoft Edge: Ctrl を押しながら 最新の情報に更新 をクリックするか、Ctrl-F5 を押してください
- Opera: Ctrl-F5を押してください
arkUsingArticles(['en:MediaWiki:DataFetch.js'], function() {
var wildStatCalcDiv = null;
var stats = null;
var wildCreatureStats = null;
var percentiles = null;
var wildStatCalcStats = {
'health': '体力',
'stamina': 'スタミナ',
'oxygen': '酸素量',
'food': '食料',
'weight': '重量',
'damage': '近接攻撃力'
};
var CACHE_EXPIRY_TIME = 72 * 60 * 60;
var DATA_PAGE_NAME = 'Data:Wild creature stat values';
var DATA_CACHE_ID = 1; // bump if stat data changes and you need it refreshed within the next hour
if (wildStatCalcDiv = document.getElementById('wildStatCalc')) {
// if a stat has x levelups, the stat is in the top percentiles[x] %. For 33 or more level, the probability is less than 0.01 %
percentiles = Array(100.00, 100.00, 100.00, 100.00, 99.99, 99.97, 99.89, 99.67, 99.17, 98.13, 96.23, 93.09, 88.39, 81.93,
73.78, 64.28, 53.98, 43.58, 33.76, 25.06, 17.81, 12.11, 7.88, 4.91, 2.92, 1.67, 0.91, 0.48, 0.24, 0.12,
0.05, 0.02, 0.01);
// TODO: these notes apply to data, move it into docs when we get an extension with formatting capabilities
// NOTE: the increase is always given as percentage of the base-stat
// NOTE: in this tool damage1 is (in most cases) 100 to represent 100% (as it is seen ingame)
// NOTE: if a creature don't have oxygen (aquatics etc.), just leave these parameter out
arkLoadDataPages([ DATA_PAGE_NAME ], DATA_CACHE_ID, CACHE_EXPIRY_TIME).then(function (results) {
wildCreatureStats = results[DATA_PAGE_NAME];
changeCreature(wildStatCalcDiv.innerHTML);
});
}
function changeCreature(creature) {
if (wildCreatureStats[creature] == null)
creature = Object.keys(wildCreatureStats)[0];
stats = wildCreatureStats[creature];
var tableRows = '';
for (var id in wildStatCalcStats) {
if (stats[id + '1']) {
var unit = '';
if (id === 'damage')
unit = ' [%]';
tableRows += '<tr><td><a href="/' + wildStatCalcStats[id] + '">' + wildStatCalcStats[id] + unit + '</a></td><td><input type="number" min="' + stats[id + '1'] + '" max="100000" maxlength="6" step="0.1" value="' + stats[id + '1'] + '" id="wildStatCalc' + id + 'input" style="width:5em"></td><td id="wildStatCalc' + id + '"></td></tr>';
}
}
tableRows += '<tr><td><a href="/Speed">速度 [%]</a></td><td title="野生生物の速度は常に100%です">100</td><td id="wildStatCalcSpeed"></td></tr>';
var creatureSelect = '<select id="wildStatCalcSwitch">';
for (var c in wildCreatureStats) {
creatureSelect += '<option' + (c === creature ? ' selected' : '') + '>' + c + '</option>';
}
creatureSelect += '</select>';
wildStatCalcDiv.innerHTML = '<table class="wikitable">' +
'<tr><th colspan="3">' + creatureSelect + ' レベル <input type="number" min="1" max="100000" maxlength="6" value="1" id="wildStatCalcLevelInput" style="width:5em"></th></tr>' +
'<tr><th>ステータス</th><th>値</th><th>レベルアップ</th></tr>' +
tableRows +
'</table>';
for (var id in wildStatCalcStats) {
if (stats[id + '1']) {
document.getElementById('wildStatCalc' + id + 'input').addEventListener('input', calcNatStats);
}
}
var selectElement = document.getElementById('wildStatCalcSwitch');
selectElement.addEventListener('change', function() {
changeCreature(selectElement.value);
});
document.getElementById('wildStatCalcLevelInput').addEventListener('input', calcNatStats);
calcNatStats();
}
function calcNatStats() {
// calculate according level
if (stats) {
var totallevel = 1; // 1 is first level
var levels = [];
var stat = 0;
var levelEl = null;
var percentile = '';
var determinedStatsNr = 0;
for (var id in wildStatCalcStats) {
if (stats[id + '1']) {
stat = document.getElementById('wildStatCalc' + id + 'input').value;
if (stats[id + '1'] && stats[id + 'Inc'] && stat >= stats[id + '1']) {
var level = Math.round((stat - stats[id + '1']) / (stats[id + 'Inc'] * stats[id + '1']));
levels[id] = level;
levelEl = document.getElementById('wildStatCalc' + id);
levelEl.innerHTML = level;
if (level > 32)
percentile = 0.01;
else
percentile = percentiles[level];
levelEl.title = 'This level is in the top ' + percentile + '% compared to all wild level 120 creatures.';
totallevel += level;
determinedStatsNr++;
}
}
}
var levelInput = document.getElementById('wildStatCalcLevelInput').value;
var speedPrefix = '';
if (determinedStatsNr < 6)
speedPrefix = '~';
if (determinedStatsNr !== 7)
document.getElementById('wildStatCalcSpeed').innerHTML = speedPrefix + Math.round((levelInput - totallevel) / (7 - determinedStatsNr));
var hue = 0;
for (var id in wildStatCalcStats) {
if (stats[id + '1']) {
hue = 0;
if (totallevel > 1) {
hue = Math.round(120 * levels[id] / 28);
}
if (hue > 120)
hue = 120;
document.getElementById('wildStatCalc' + id).parentElement.style.backgroundColor = 'hsl(' + hue + ', 100%, 85%)';
}
}
}
}
});