2024-06-28 22:00:49 +00:00
|
|
|
window.onload = function () {
|
|
|
|
document.getElementById('mentalAttackForm').addEventListener('submit', function (event) {
|
|
|
|
event.preventDefault(); // Prevent the form from submitting the normal way
|
|
|
|
|
|
|
|
const ams = parseInt(document.getElementById('ams').value, 10);
|
|
|
|
const dms = parseInt(document.getElementById('dms').value, 10);
|
|
|
|
const modifier = parseInt(document.getElementById('modifier').value, 0);
|
2024-07-01 15:03:40 +00:00
|
|
|
const queryParams = new URLSearchParams({
|
|
|
|
ams: ams,
|
|
|
|
dms: dms,
|
|
|
|
modifier: modifier
|
|
|
|
});
|
2024-06-28 22:00:49 +00:00
|
|
|
|
2024-07-01 15:03:40 +00:00
|
|
|
fetch(`${window.BASE_URL}/gameplay/attack/mental?${queryParams}`)
|
2024-06-28 22:00:49 +00:00
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
|
|
|
const resultsDiv = document.getElementById('results');
|
|
|
|
let html = '';
|
|
|
|
|
|
|
|
if (data['needed']) {
|
|
|
|
html += `<p><b>Needed: </b>${data['needed']}      `;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data['original-roll']) {
|
|
|
|
html += `<b>Original Roll: </b>${data['original-roll']}</p>`;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data['modifier']) {
|
|
|
|
html += `<p><b>Modifier: </b>${data['modifier']}      `;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data['adjusted-roll']) {
|
|
|
|
html += `<b>Adjusted Roll: </b> ${data['adjusted-roll']}</p>`;
|
|
|
|
}
|
|
|
|
|
|
|
|
html += `<br/>`;
|
|
|
|
|
|
|
|
if (data['outcome']) {
|
|
|
|
let outcomeText = data['outcome'];
|
|
|
|
html += `<p><h2>${outcomeText}</h2></p>`;
|
|
|
|
// adding img tag
|
|
|
|
let outcomeImage = 'img/' + outcomeText.replace(' ', '%20') + '.png';
|
2024-06-28 22:26:42 +00:00
|
|
|
html += `<img src="${outcomeImage}" width="350px" height="350px"/>`
|
2024-06-28 22:00:49 +00:00
|
|
|
|
|
|
|
resultsDiv.innerHTML = html;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|