Attack and Defense
A subscript of 1 (ATK1) denotes the attacker's stat and 2 (DEF2) denotes the defender's stat.
note: Enemies seem to have a Hatk of 10 and Hdef of 0
note2: Hero Defense hasn't been rigorously tested, especially against other players.
Basic Damage:
Damage you will do/receive without taking hero or equipment into account.
Basic Damage = ATK12/(ATK1 + DEF2)
With equipment that modifies ATK/DEF of units, not hero stats, it modifies the ATK/DEF before any calculations.
"Raises DEF" = DEFup
"Raises DEF by %" = DEFper
"Raises ATK" = ATKup
"Raises ATK by %" = ATKper
ATK1 = (1+ATKper1/100)*ATK1 + ATKup1
DEF2 = (1+DEFper2/100)*DEF2 + DEFup2
With equipment that modifies damage (increases or reduces damage), it is taken into account after everything except number of units is calculated (next section).
Total Damage
Damage with Hero Stats (Hatk, Hdef):
(Basic Damage * (1+Hatk/100) / (1+Hdef/100) + "increases damage1" - "reduces damage2") * Number of attacking units1.