If the battle has numeric controls for blocking and other actions (assigned to 1,2,3...) the game would be more fun to try and optimize.
That being said, I'm so plugging my proper gaming mouse (that's normally used on my gaming desktop as the elder gods intended) into my laptop to do battle as soon as i get home...
// Map the keys '1', '2', '3' to array indices 0, 1, 2
const keyMap = {
'1': 0,
'2': 1,
'3': 2
};
// Check if the pressed key is 1, 2, or 3
if (event.key in keyMap) {
const targetIndex = keyMap[event.key];
// Dynamically fetch the buttons currently in the DOM
const buttons = document.getElementsByClassName('block-button');
// Ensure the button exists at that index before clicking
if (buttons[targetIndex]) {
buttons[targetIndex].click();
}
}
});