17:

For the rest of the evening it was as though Luna and Ginny were in competition with each other for Draco's attention and affections. It was silly, both of the girls loved each other, and both knew that they wouldn't want Draco without the other, but they couldn't resist the need for finding themselves more lusted after, more wanted, more loved.
And Draco couldn't say he minded.

They took turns dancing with him and, in between, they barely acknowledged each other. There was an iciness in their eyes and a chill in their voices.

After the ball was over, clinging onto Draco, the three made their way to the astronomy tower. By the moves they were doing, Draco could tell that Ginny and Luna were fighting for him- he wondered what had changed between them, had there been in a fight? Whatever it was... it ended up being the most passionate night of his life.
And suddenly it hit him: he was actually starting to care about Ginny and Luna. But in six months he would be leaving Hogwarts forever and then would go back to how things were- and they would forget about him.

In the wizarding world, although same sex marriages were perfectly legal, they were rare, and highly frowned upon by the middle- upper class society.
Ginny realized that although she did love Luna, and although things were great with her, she would not have the strength to stay with Luna and "come out". Eventually, Ginny would want to get married and have children, and that couldn't happen with Luna.
It was the night of the ball, upon seeing Draco from afar, that she realized that the only person she cared about as much as Luna, was Draco.

Luna had no problem with getting married to Ginny, no problem adopting a wizard, or even a muggle, if Ginny wanted it. But she also wanted Draco; she could have Ginny anytime, but Draco was leaving Hogwarts in six months and then she would have another year of sneaking around with Ginny before she graduated.
And since Luna knew that Ginny didn't have the courage to "come out" she wasn't about to let Ginny take Draco from her.

Draco had to do something; his relationship with Ginny and Luna was to remain physical at all times and nothing more. He wasn't about to jeopardise himself by putting himself in a vulnerable position.