Just make a function which does the calculation, and call the calculation wherever it is needed. For the attack power and the stats of the Pokémon, make a parent function which collect these and give them to the calculation function. I might have made that a bit unclear so let me know if you want me to expand a bit more
Edit: I've decided to expand my answer regardless, seeing as my previous answer was rubbish.
First, you will want a parent class (We'll call it Stats) which collects the stats that the damage calculation needs. After this, you will need to build a child class (call it Damage) which extends the parent class, gathers each stat which should be saved inside of a variable, and does the calculation. After this, you can create an if statement which checks if a Pokémon has fainted or not by comparing the current HP stat to the damage done (yes, that means you should also collect the receiving Pokémon's HP stat too!).
There are many other variables to think about, such as how you will want to implement the chances of a status occurring, recoil damage, weather and item buffs... but as long as you have this fundamental working you can build upon it.