Here's why:
* Born in 1981: Luna was born in 1981, the same year as Harry Potter.
* Battle of Hogwarts in 1998: The Battle of Hogwarts took place in 1998.
* Age of 17: This would make Luna 17 years old during the battle.
The legal age for attending Hogwarts and fighting in a war is not explicitly stated in the books. However, given that many students, including Harry, fought in the battle, it's safe to assume that 17-year-olds were considered adults in the wizarding world.