How to make a weapon that becomes more powerful based on battles escaped from/won?

Hello. In my game I am trying to make a set of two weapons: the "Brave Knife" and the "Chicken Knife." The Brave Knife becomes more powerful the more battles you win, and the Chicken Knife becomes more powerful the more battles you run from. I've found a video on how to create a chicken knife using Yanfly's Equip Core, but I have no clue on how to create a "Brave Knife" weapon. Here is the video.



In the video, it explains that all you need to do to make a chicken knife is to put this code into the notebox of the weapon you want to be the chicken knife and make that weapon's attack be 0.

Code:
<Custom Parameters>
atk = $gameSystem.escapeCount();
</Custom Parameters>

However, what if I want to make it so the parameter is based on battles won instead of battles escaped from? Of course, the Brave Knife would be far superior to the Chicken Knife due to the fact that people tend to fight, and therefore win, more battles then battles that they run away from, so to counter that I'll just chance a few things in the code.

Code:
<Custom Parameters>
atk = ((battles won code) / 5);
</Custom Parameters>

Can someone please help me with this? Thanks.
Hi!
I believe it is $gameSystem.battleCount() - This will return all the times you have battled. But don't know if it still counts if you escape or lose.
So I think it's best if you use a variable. Every time you win a fight, you add + 1 to this variable.
Ok, great, but how do I set up a variable for when you win? 99% of my battles in my game are random, so how exactly do I set that up? I know I can make every enemy immortal in the beginning and then do some stuff when they get to 0 HP before killing them by removing the immortal status, but that only counts for enemies killed, not overall battles won. How do I do this? Thanks.

Edit: Ok I figured it out. "Win Count" is one of the things you can set for variables when calculating for them. Thanks for the help!

Edit 2: Ok, so how do I do custom parameters using a variable? What is the code needed? Thanks.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-a-weapon-that-becomes-more-powerful-based-on-battles-escaped-from-won.129135/