If I have a mixed group of troops, is it the highest or lowest value in attack/defence which matter? Is attack bonus for invading troops and defence bonus for defence troops (sounds logical

) or attack bonus when dealing damage and defence bonus when receiving damage?