During an attack how is the % calculated?

If a fight occurs because one player has attacked the other, it will depend on the type and amount of units that collide, which side wins. The one who has taken the smaller losses in percentage is the winner of the fight.

The winner of the fight gets credited with part of the opponent's buildings as spoils of war. The maximum amount of enemy buildings the winner can get depends on the bashlevel of the opponent. The bashlevel may have different levels, depending on the configurations of the world you play.
Example: At a bashlevel of 33/33/25/15/5/0, the yield for the first and second attacks is 33% or less of the opponent's buildings. In the third attack, only 25% or less of the same player, 15% in the fourth, 5% in the fifth attack, and 0% in the sixth time, can be conquered.
The bash level prevents a player from not having any buildings left after an opponent's attack series. Battles fall out of the bash level after a certain amount of time (depending on the world), so that it may recover one level.

If the winner of the fight is victorious but unable to completely destroy his opponent's army, he will only get part of the spoils of war. For example: if the attacker only destroys half of the defending army, he will only get 50% of the buildings determined by the bash at the moment of the attack. E.g. Defendant has 1000 buildings, bash is 33, and Attacker destroys 50% of his defense, attacker will take away [ 33% x 1000 ] x 50%, or 165 buildings.