This happened against my friend on XY, I had my Staraptor out and he had his Chestnaught, so I naturally picked brave bird and he decided to use Spiky Shield. I decided to switch out before taking any more damage from that shield. Switched to Mega Alakazam, used Psychic, it barely lived. CCesnaught used Pin Missiles, Mega Zam barely lives as well. My stupidity made me switch back to Staraptor where he had a Wood Hammer waiting for me, so it took quite a bit of damage from that. I tried to clutch with Brave bird but he set up Spiky Shield and made Staraptor faint. So I went back to mega zam, and I was being stupid and expected another Spiky Shield (I didn't know Spiky shield failed against special attacks at the time) so I stalled the turn with Calm Mind, and my friend just ended it with Pin Missiles. That's the story of my unluckiest battle, which is why predicting Pokemon is very difficult to do.