If it depends on something, it's probably related to the soldier, which would be logical. And the units don't necessarily have to stand in front of him; they can be on the side – in my opinion, this is one of the main advantages, because at the moment the dragons take their turn, the enemy troops can be leaning against the wall.
It doesn't depend on the "soldier" – because the ability works similarly to "acidic" breath, and the number of affected units depends not on a straight line (as in the case of "acidic" breath), but on the "Luck" parameter (the higher this parameter, the more units the "prism" breath will affect – but no more than 5; the trajectory of the damage is determined randomly – this line can also be broken).
However, I haven't checked these calculations for a while... :)