I think War and Port Battles are two different things, the PB being a part of War, not the primary result of it's declaration.
I would suggest that War be balanced as close to RL and Historical as possible. First and foremost no Nation can attack another Nation without a declaration of war. Everyone is basically marked white on the Open Waters. Only Pirates can attack ships marked white without incurring a loss: (By becoming Pirate). The Admiralty are the only ones capable of declaring a war and this would mean the Admiralty being financially responsible for those wars. This is to say that they must compensate for the loss of vessels during the war. But how? Historically they used tonnage to measure their fleets but we've already got a measure in BR. The Admiralty would then assign a value to each BR they are willing to pay out for it's loss. This money would then be the cost of the war. It is a massive amount of money and would keep the various Nations from randomly declaring wars for no reason.
But how do they recoup this loss? By issuing Letters of Marque to players who buy the BR cost of the ships they are willing to donate to the fight. The player is then free to engage or be engaged by any opposing player marked for war of that enemy nation. A war is tracked by the BR losses suffered by both nations. No merchant vessels can count for war losses and they may not participate in any way. A pirate who sinks a war vessel does affect the BR score, though a Nation win does not count for the other Nation's BR loss; they simply risked a war vessel to sink a pirate. It is also assumed that warships will be larger and outside the purview of Pirates. If a Player loses his ship for whatever reason he can obtain a new ship, pay the BR fee to re-enter the war and go fight, up until the BR limit has been fully paid for. This ensures that only those willing to participate in a war are included and reduces the chances of being trolled or ganked. (outside of war of course, since ganging up on someone during a war is just good policy). Battle timers are still included to limit late entries but the only BR limit is set at the outset of the war.
Once the BR limit has been reached both Nations' Navies revert to white and the fighting ends with a clear victor and loser. The money spent on the war goes into the grey Abyss of Davy Jones' Locker since War is Hell.
Now what is the purpose of the war? How about for a port? Now we have both purpose and battlefield. Should the attacker win they would gain ownership of the port while should they lose they obtain nothing but experience and a vast loss of money. This would also keep more than one port from changing hands at a time, provide a cost for seeking ownership of a port and give a time delay before a new port could be targeted. This also keeps them from fighting over nothing, which isn't realistic. War is now meaningful. If players aren't successful they can't afford to be Admirals, Admirals must know what they are doing before declaring a war to avoid a very expensive mistake, players must grind, trade or craft to afford their Letters of Marque, giving us Economy.
The coding would be fairly simple, a War screen anyone can interact with. It would list the War, who it was with and the BR value of their Resolve. A player would then use a drop down listing their owned vessels they want to have marked, the cost would populate and they would pay. That ship would then be marked. This same screen would track the BR loss of their own Nation. One Nation would not know the BR Resolve of the other and vice versa. A player would only be able to add one ship at a time to the war and would have to lose that ship before adding another. 7th Rate ships may not participate, they must go stand in the corner with the Merchants. These corner dwellers may be sunk but do not count towards the BR Resolve.
This would solve every conundrum you seem to be having without having to write code for the next eighty years. The Port battles would be battles on the open water for control of the port, which makes sense as there were not a lot of line troops around to provide land battles, and it's not a focus of this game in the first place. You already have guns by the ports themselves in case an attacker engages too close to port and pays the price yet there is no need to create a mechanic for forts that didn't really exist during the time we are supposed to be playing in. Usually ports had a single fort controlling the entrance to the port, not little batteries or zones of control. It was a battle of wills.
Since the Admiralty controls the declarations they can determine if they want a long or short war, based on how much they are willing to pay. The object is to have players pay the full amount of the Resolve because we all want to participate but should the fighting die out or too much time pass, the Admiralty can sue for peace and pay the remaining fees.