To answer this effectively, we need to determine which spells are worth casting.
The three spells to really consider are Armor of Agathys, Fire Shield, and Shadow of Moil.
Armor of Agathys deals 25 damage per hit, but is limited - it only deals 50 total damage in this case before the temp hp runs out. We can try some ways to increase that further though, mostly by reducing damage taken from the elementals on each hit.
Fire Shield deals 9 damage per hit, is not limited, and is not concentration. Over the 12 attacks by enemies in one combat, this adds up to 108 damage if all hit.
Shadow of Moil deals 9 damage per hit, is not limited, and is concentration. This has the same overall damage output that Fire Shield does.
With that in mind, the best version is simply a Fiend Warlock 7+10 with two Rods of the Pact Keeper and a Ring of Spell Storing (Catnap). You'll also take the Alert feat, making you go first in ~75% of combats. You'll take the Lucky Feat to minimize critical strikes while Armor of Agathys is up. You choose the damage type of Bludgeoning for resistance as your Fiend 10 feature.
This gives you access to 8 spells over your four combats, sothough you canstill can't quite cast both Fire Shield and Shadow of Moil for each onebecause of Rod logistics.
You deal 216 damageCombat 1
Precast Fire Shield
First round: If you go first, cast Shadow of Moil. If you do not go first, cast Armor of Agathys.
Second round: regain a spell slot with a Rod.
Third round: Cast Armor of Agathys
Catnap.
Combat 2
Precast Fire Shield
First round: If you go first, cast Shadow of Moil. If you do not go first and don't have temp hitpoints remaining from your previous cast of Armor of Agathys, cast it again.
Second round: Cast Armor of Agathys if possible.
Third round: Wait
Short Rest, change attunement to enemies each combatRods.
Combat 3
Precast Fire Shield
First round: If you go first, or 864 total damagecast Shadow of Moil. If you do not go first, cast Armor of Agathys.
Second round: Regain a spell slot with a Rod.
Third round: Wait
Combat 4
YouPrecast Fire Shield
First round: Wait
Second round: Wait
Third round: Wait
You bring an AC of 10 and crawl into each combat, resulting in a hit chance of 99.75% for your enemies.
[108] - Fire Shield is responsible for 9 damage per attack over 12 attacks each combat. Cast 4 times.
[108] - Shadow of Moil is responsible for 9 damage per attack over 12 attacks each combat. This has a 73.75% chance of happening for each of the first three combats.
[100] - Armor of Agathys is responsible for 25 damage per attack over four attacks that each deal 7 damage. It is also relatively unaffected by hit chance. This has a 26.25% chance of happening for each of the first three combats, and one guaranteed cast.
430.92: Fire Shield total damage 432 * 99.75%
238.35: Shadow of Moil total damage 324 * 73.75% * 99.75%
178.75: Armor of Agathys total damage 300 * 26.25% + 100
Overall damage dealt is 861848.8402 total damage over 12 rounds of combat, and DPR is 71or 70.8266 damage per round.