Some questions about Game Development

I have long wanted to build a browser/text based mmo and I have recently found bubble is able to help me out greatly in the process. I have made some great progress toward what I want to do, and im learning a lot about how bubble works along the way.

I do have some questions about some features id like to implement and im hoping someone can give me some ideas about how to accomplish these goals or perhaps link me to some related documentation.

Id like to create an attack system, where one user can attack another user… Below is a basic layout of how I would like the battle to flow. But im not sure how exactly to do it.

Player 1 is attacking Player 2, attacks should take place one after another, on the same page until completion. The attacks are automatic once initiated. Each players health and defence would be combined to give their max health, when this combined number reaches 0 that player loses.

Player 1 Initiates the attack and does x damage.
Player 2 attacks back and does x damage.
Player 1 attacks again and does x damage.
Player 2 Looses.
Player 1 gains x experience, and x% of player 2s money.

Im not sure how to go about automating this system in the way mentioned above. Basically the outcome is already known to the system as soon as the battle starts, but the displays of whos attacking and how much damage is there to show the users how the numbers add up.

Ideally id like for the winner to gain a set amount of experience, a % of the losers money, and to be able to tally total wins and losses for both users.

A bonus would be for there to be an attack log that will shows both users the basic details of the attack. So if an online player attacks someone who is offline, they offline player can review the information when they login.

Im sorry if this is vague, or sounds silly, but its something I really want to do. And any help or direction would be most appreciated. I can provide more details and info as needed if it will help.