I wrote a fairly simply battle system for web based RPG.
Doesn't use loop's for control flow but instead waits for button clicks, then runs the npc turn.
Also has some handy multiplier functions RNG.
Also has special stat meter functionality built in for magic and special moves.
https://codepen.io/abstracted/pen/oqOrwE