-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathaverage.js
More file actions
26 lines (22 loc) · 707 Bytes
/
average.js
File metadata and controls
26 lines (22 loc) · 707 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
settings.register({
name: 'Disable deck average counter',
key: 'underscript.disable.deck.average',
refresh: onPage('Decks'),
});
// Calculate average
onPage('Decks', () => {
eventManager.on('jQuery', () => {
const avg = $('<span>').hover(hover.show('Average gold cost'));
$('#classInfo span').text('Passive').after(' ', avg);
function round(amt, dec = 2) {
return Number.parseFloat(amt).toFixed(dec)
}
function count() {
let val = 0;
const list = decks[classe];
list.forEach(({cost}) => val += cost);
avg.text(`(${round(list.length ? val / list.length : val)})`);
}
eventManager.on('Deck:Soul Deck:Change Deck:Loaded', count);
});
});