-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathaverage.js
More file actions
27 lines (23 loc) · 800 Bytes
/
average.js
File metadata and controls
27 lines (23 loc) · 800 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
settings.register({
name: 'Disable deck average counter',
key: 'underscript.disable.deck.average',
refresh: onPage('Decks'),
page: 'Library',
});
// Calculate average
onPage('Decks', () => {
eventManager.on(':loaded', () => {
const avg = $('<span>').hover(hover.show('Average gold cost'));
$('#soulInfo span').after('<span>Passive</span> ', avg).remove();
function round(amt, dec = 2) {
return Number.parseFloat(amt).toFixed(dec);
}
function count() {
let val = 0;
const list = global('decks')[global('soul')];
list.forEach(({ cost }) => val += cost); // eslint-disable-line no-return-assign
avg.text(`(${round(list.length ? val / list.length : val)})`);
}
eventManager.on('Deck:Soul Deck:Change Deck:Loaded', count);
});
});