Are 耳光 and 巴掌 the same? There is this sentence in this story 沙漠里的朋友: 今天我的好朋友打了我一巴掌.

Here, can I replace 巴掌 with 耳光?
耳光
ABC

N.
box on the ears; slap on the face

巴掌

N.
palm of the hand

While they are inherently different, 打…巴掌 and 打…耳光 are roughly the same.
Consider these two example sentences from A Chinese-English Dictionary

打他一巴掌
dǎ tā yī bāzhang
give him a slap



打耳光
dǎ ěrguāng
slap sb.'s face; box sb.'s ears

The only difference might be is that 耳光 could alude to a specific hit/slap/punch to the ears.