When the cards of the first and second player are equal ( == ), the battle start. When you start a battle, you got to remember that it is alway going the cards of the FIRST PLAYER that is going to be add in the deck of the winner, no matter which player wins the battle. Then, for the first player you take the first card (the one that start the battle), + the 3 next, then the next one is going to decide who wins the battle and this card is going to be add in the winner's deck too. In one single battle, 10 cards are going to move into the winner's deck and you got to be sure to follow the right orders (cards of first player then the cards of the second player)
First player: (10H<--start the battle) (1H 2H 3H)<-- card for win 4H <--card that fight 5H (other card)
Second player: 10D 1D 2D 3D 5D 6D
In this case, the winnin pack going to be 10H 1H 2H 3H 4H 10D 1D 2D 3D 5D.
The second player win's the battle (5D > 4H)
The result is going to be only 5H for first player and 6D 10H 1H 2H 3H 4H 10D 1D 2D 3D 5D for the second player.
So, important, you have to remember (it is the same for a single fight), that when a player wins a fight or a battle, you got to alway put the card of the first player in the winner's deck and at the end of the list ( or arrays). This is wrriten in rules.
Good luck to you all, hope i help.
Like i said, if the problem is persitent show your code and im going to check what is wrong.