This keeps bugging me. I don't understand how the strongest units that you can use are chosen.
I have 500+ allies, which means I can use 1500 units. I have more than 1500 units, which means that some units will not be used, so the question is how the strongest 1500 units are chosen.

Option 1:
Units are chosen by sum of attack and defense. This would make sense, but it can cause some strange effects. Assume my 1500th unit has 150 attack and 50 defense totaling 200 a/d. I then buy a unit with 100 attack and 120 defense. As this unit has 220 total a/d it would replace my 150/50 unit. But that would result in my total attack being reduced by 50 and my defense to be increased by 70.
Could it be true that purchasing a unit could cause a reduction in either attack or defense?

Option 2:
Depending on whether you are attacking or are being attacked, units are chosen by strongest attack or strongest defense. This could make sense as well, because when you see the top 45 units after a PVP attack, you see your 45 strongest by attack, and your opponents 45 strongest by defense.
This means that your total attack is the sum of the 1500 units with highest attack, and your defense is the sum of the 1500 units with highest defense (plus bonuses).
This way, a new unit would never cause a reduction in either attack or defense, but on the other hand, there will be different "1500 strongest units" depending on whether you are attacking or defending yourself. If this is true, you should have more than 1500 units to make sure you have one subset that gives very high attack, and another subset that gives high defense.

Any ideas?