Dungeon Game - How to calculate damage based on XP and weapon?

I’m coding the “roguelike dungeon crawler game” challenge (https://www.freecodecamp.com/challenges/build-a-roguelike-dungeon-crawler-game), I’ve already done the “hard” part which is generating a board and letting the player move around it. My problem is I don’t know the “math” behind attacking opponents (XP, level, weapon etc). If anyone who’s done it before can help me out I’d appreciate it as I don’t want to look into someone else’s code.


I’m also working on my roguelike (though I’m not really far into it).
You aren’t really using the XP to calculate damage, you use your character’s level. What you should do is to increase your character’s damage by, let’s say, 20% or so whenever he reaches a certain amount of XP. So once he gains 50 XP, he levels up, increasing his damage and health, then he has to reach 200 XP for the next level, and so on.
Now weapons should be a straight upgrade to the character’s damage output.
Let’s say your character starts barehanded, having the damage output of 3. Then he finds a stick, which should have it’s own damage of something like 7, which overrides your character’s base attack power. So now he has a base damage output of 7, because he wields the stick, and you apply your level bonuses to that.

I hope that helped out, but if I wasn’t clear on something, feel free to ask.