-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
113 lines (92 loc) · 3.77 KB
/
script.js
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
document.addEventListener('DOMContentLoaded', function() {
let selectedEngagement = 0;
const activeBoosts = new Set();
const engagementSelect = document.getElementById('engagement-select');
engagementSelect.value = selectedEngagement;
engagementSelect.addEventListener('change', function() {
selectedEngagement = parseFloat(this.value);
});
document.getElementById('hero-drink-button').addEventListener('click', function() {
toggleBoost('hero-drink');
});
document.getElementById('hero-boost-button').addEventListener('click', function() {
toggleBoost('hero-boost');
});
document.getElementById('hero-voice-button').addEventListener('click', function() {
toggleBoost('hero-voice');
});
document.getElementById('team-boost-button').addEventListener('click', function() {
toggleBoost('team-boost');
});
document.getElementById('kosa-button').addEventListener('click', function() {
toggleBoost('kosa');
});
document.getElementById('playstyle-button').addEventListener('click', function() {
toggleBoost('playstyle');
});
document.getElementById('ovr-form').addEventListener('submit', function(event) {
event.preventDefault();
const currentOVR = parseFloat(document.getElementById('current-ovr').value);
const trainedOVR = parseFloat(document.getElementById('trained-ovr').value);
const trainedSkill = parseFloat(document.getElementById('trained-skill').value);
if (isNaN(currentOVR) || isNaN(trainedOVR) || isNaN(trainedSkill)) {
displayResult('Proszę wprowadzić poprawne wartości liczbowej.');
return;
}
if (trainedOVR > currentOVR) {
displayResult('Wytrenowany OVR nie może być większy od obecnego OVR.');
return;
}
if (selectedEngagement === null) {
displayResult('Proszę wybrać zaangażowanie.');
return;
}
let baseResult = calculateOVR(currentOVR, trainedOVR, selectedEngagement);
let finalResult = baseResult;
let boostTotal = 0;
if (activeBoosts.has('playstyle')) {
boostTotal += (trainedSkill * 0.33) / 8;
}
if (activeBoosts.has('hero-drink')) {
boostTotal += trainedOVR * 0.33;
}
if (activeBoosts.has('hero-boost')) {
boostTotal += trainedOVR * 0.33;
}
if (activeBoosts.has('hero-voice')) {
boostTotal += trainedOVR * 0.33;
}
if (activeBoosts.has('team-boost')) {
boostTotal += trainedOVR * 0.12;
}
if (activeBoosts.has('kosa')) {
boostTotal += trainedOVR * 0.2;
}
finalResult += boostTotal;
const roundedResult = Math.round(finalResult);
displayResult(`Wynik OVR: <span class="rounded-result">${formatNumber(roundedResult)}</span>`);
});
function calculateOVR(current, trainedOVR, engagement) {
return current + (trainedOVR * engagement);
}
function displayResult(message) {
const resultDiv = document.getElementById('result');
resultDiv.innerHTML = message;
resultDiv.style.display = 'block';
}
function toggleBoost(boostType) {
const button = document.getElementById(`${boostType}-button`);
if (activeBoosts.has(boostType)) {
activeBoosts.delete(boostType);
button.classList.remove('active');
button.classList.add('inactive');
} else {
activeBoosts.add(boostType);
button.classList.add('active');
button.classList.remove('inactive');
}
}
function formatNumber(number) {
return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
}
});