In Super Auto Pets, players build teams of animals that face off in battles to the death unconsciousness. Each animal has an Attack and Health value, and combat occurs in iterations of the following process:
The front animals of each team deal damage to each other equal to their Attack at the same time.
Both animals lose Health points equal to the damage taken. Health points are never restored in battle.
Animals with 0 Health or less faint and are removed from the battle.
As an example consider two teams A and B, which will be represented by a list of tuples (Attack, Health).
A: [(2, 3), (2, 2), (3, 1)] B: [(1, 3), (3, 4), (1, 2)]
To illustrate the battle, the teams will be displayed so that the front animals are facing each other. I will also label each animal for convenience. A battle between these teams would go as follows:
Pig Beaver FishA Duck FishB Otter
Step 0: (3, 1) (2, 2) (2, 3) -> <- (1, 3) (3, 4) (1, 2)
A and B line up opposite each other, with their first animals ready to attack . The arrows show the direction each team is facing.
Step 1: (3, 1) (2, 2) (2, 2) | (1, 1) (3, 4) (1, 2)
FishA and Duck attack each other, with FishA dealing 2 damage, and Duck dealing 1. Both are still conscious, so they will attack again next step.
Step 2: (3, 1) (2, 2) (2, 1) | (3, 4) (1, 2)
This time FishA leaves Duck with -1 HP, so Duck faints, but FishA survives its attack. Next for B is FishB, but FishA is still alive.
Step 3: (3, 1) (2, 2) | (3, 2) (1, 2)
FishB knocks out FishA and survives FishA's attack with 2 HP. Now Beaver gets to attack
Step 4: (3, 1) | (1, 2)
Beaver and FishB both drop to 0 HP and faint, leaving only Pig and Otter
Step 5: |
Otter and Pig knock each other out, leaving no more pets.
Since neither A or B was resilient enough to survive the battle, the result is a draw. If A had any pets left when B's Otter fainted, A would have won (and similar for B in the opposite case).
The Challenge
Your challenge is to write a program or function which takes two teams of pets and outputs the result of their battle. The teams may be empty, and do not have to have the same number of pets.
Your input format may consist of any structure(s) describing the order of each team and the Health and Attack of each animal in that order. Above I have used a list of tuples, each list representing a team in order, and each tuple representing one animal. However, you do not have to conform to this format as long as your input contains the necessary data.
Your solution should output one of three distinct values (which you should specify!) corresponding to a win by the first team, a win by the second team, or a draw. To fulfill this, you also must specify which parts of your input correspond to which team
Standard I/O rules apply, and this is Code Golf, so shortest answer wins.
Examples
The examples take input in the first method described, and output either "A wins!", "B wins!", or "Draw!". I have created a reference implementation in Python 3 on TIO.
A: [(1, 3), (3, 1), (3, 2), (2, 2), (6, 5), (5, 7)]
B: [(3, 1), (1, 1), (1, 2), (1, 2), (4, 3)]
Result: A wins!
A: [(2, 2)]
B: [(2, 2)]
Result: Draw!
A: []
B: [(1, 1)]
Result: B wins!
A: [(1, 3), (3, 1)]
B: [(3, 1), (1, 1), (1, 2), (1, 2), (4, 3)]
Result: B wins!