A note: @Reinier, besides having an awesome palindromic username, also solved this puzzle first (my solve was still independent). I like my explanation better (but of course I'm biased), but if you upvote my answer, don't forget to upvote Reinier's as well.
So, it's somewhat apparent that we need to find
the optimal strategy (for us) in the worst-case scenario (our friend tries to get as many coins as he can).
Here's my basic strategy:
The maximum number of bags that may be filled is 25. This is because the game ends when one person gains 13 bags. Consequently, if we divide all the coins equally among the bags, then the worst we can get is 12/25 of the loot. Of course, we can't quite divide them equally, so we will fill 6 of them with 80 coins, and 19 of them with 81 coins.
When we present each bag to our friend,
The best-case scenario for him/her is to gather 13 of the 19 81-coin bags. This leaves us with $81 * 6 + 80 *6 = 966$ coins to his $31 * 81 = 1,053$.
Essentially, the friend's strategy is to
keep any bag with more than 80 coins, and give us any bag with 80 coins or less.
There is, of course, a slight work-around that can get us a liiiitle bit more.
If we present a continual stream of
80-coin bags, then the friend's best bet is to give us the first 12 bags, but then give himself the rest of the bags. This improves things a little bit - our friend only gets $1,040$ coins, and we get $979$.
What if we present a continual stream of
79-coin bags? The best our friend can get is $1,027$, and we get $998$ That's even better!
What if we present a continual stream of
78-coin bags? The best our friend can get is $1,014$, and we get $1,005$ That's even better!
What if we present a continual stream of
77-coin bags? The best our friend can get is $1,024$, and this is if he gives us all 13 of the 77-coin bags. Previously, he ended up giving himself all of the bags, so it looks like the highest point we can reach is with 78-coin bags.
So, the altered strategy of our friend is to
keep any bag with more than 77 coins. $13*78$ coins gives him a majority of the coins, while $13*77$ coins gives him a minority of the coins.
We can infer that we can do no better than
78-coin bags
because
Every bag must be above, below, or at 78 coins. If we present to our friend bags with less than 78 coins, he gives them to us, and we're playing a non-optimal strategy. If we present him with more, he goes ahead and takes it, increasing his potential winnings.