Basically.. There's a field in user_characters called T and another field called H.. they both contain numeral values.. there is also another field called DefWun which contains a numeral value which has to be checked before each attack action.. T damage value is 1.. and H damage value is 3.. the field DefWun contains the amount of weapons a character contains for their T/H fields.. they will only be counted torwards the attack damage if there is enough DefWun to match every unit in T/H..
So lets say T/H and DefWun are equal or DefWun has more units/value then T/H combined.. then every attack unit will be added up.. meaning total number of T x 1 and total number of H x 3 for both victim and attacker.. then it will be divided by 1.5... the person with the higher value will "win" and the person with the lower value will "lose".. (If A has 8000 T units.. then user A will be at 8000 T / 1.5 = 5333.. now user B has a lower value. maybe 3000 T units.. so 3000 T / 1.5 = 2000.. meaning user B will lose 5333 units.. and user A will lose 2000 ).. T will always be counted first in lost units aswell as attacking units.. If there isn't enough guns to cover the total units they have, T units are counted first then what's left over goes to H units.
After that step.. the person who won the attack will gain 1/4 of what they killed added to their T/H (depending on which units they killed) So "You killed x amount.. and gained x amount) and will lose any of their units in the attack that have died.. the victim (loser) will lose whatever defense have been killed.. if the amount of T/H they have is already 0 then message will display "No more T left to attack"..
I'm not good at adding up values.. or doing any of those type of querys/values.. so I need help converting the above code to match the description I just added here in this post. Any help would be appreciated.