All right, simple enough. A treaty cannot by definition occur during a turn change, so it'll make modifying the database rather trivial.
Each region has an encounter setting matrix that defines what happens if people, or troops are encountered by each realm at the turn change. This is modified by the various treaty types during each round before the turn. The matrix is actually multiple nested cells of arrays.
So for instance lets have three realms. With only three regions. I'll use matlab notation as its what I'm most familiar with. {region ID; owner ID}{1,nobles(1);troops(2)}(1:3,1:3)
So we're in region 1 owned by realm 1 and we want to know if we should arrest a noble from realm 2 So we go If {1,:}{1,1}(1,2}==1 then Arrest End If its combat for the same then it's just {1,:}{1,1}(1,2)==1 Then Blligerancy=1
You can use this then to set the belligerancy of any troops who would then enter into combat. You could even have it check who should be attacking and defending when setting that boolean.
To change a treaty you can then go through and look for regions that are owned by 1. If {x,2}==realm ID then {x,1}{1,:}(1,2)=1 {x,1}{1,:}(2,1)=1
Lets say that 3 has a defense treaty with 1. When 2 declares on 1 the code can check to see if there is a defense treaty between 1 and any other realm. If a region changes hands at the turn change it simiply copies the encounter matrix of any already owned region by the conquering realm, no need to recalculate it.
Any similar scheme would work. It's just a matter of doing encounters on a region by region basis.
[/code]