Fix calculate damage algorithm