Define a chance of the attack hitting the target. This can be modified by the attacker's & defender's fighting skill levels.
Define the minimum and maximum damage the attacker's weapon can inflict. This can be modified by the attacker's strength and the defender's armour.
Then use the SmileBASIC random number function to pick numbers within those ranges.
Honestly, it's just my idea of how a battle could work. Others will have different ideas. The key for Random_Battle is in the screenshot. The code seems to work for me, but there could be mistakes or bugs in it. Modify the player & weapon data and attack & defense formulas and observe the results.