It depends on how complicated you want it to be. Since your game is text-based, i think is better just to post a hardcoded result instead of relying on the player's choiced in-battle. Something like: "You fighted that ugly spider, and you won!" But if you want it to be variable, then this algorithm can help you:
1.- Select a choice to attack (Punch or Kick for example).
2.- Substract the enemy life for the damage received.
3.- Enemy attack you.
4.- Substract your life by the damage received.
5.- Go to first step.
And so on.
Also, no code here because understanding your tools and the logic is part of the task. Every App/Game is a task with unique challenges, so is up to you to find a solution for those problems instead of relying on copy-paste.