Craig_Sutter
Deity
Hello... I am finding it incredibly difficult to test whether the logic of this function is working as expected. It is supposed to give negative diplomacy in a couple of situations from the perspective of ePlayer1 to ePlayer2.
- ePlayer1 has three Earldoms while ePlayer2 has London (ePlayer2 should see a negative diplomatic modifier (red message) from ePlayer1.
- ePlayer1 has no Archdiocese while ePlayer2 has at least 1.
- a combination of the above 2.
In all cases, from ePlayer 2 perspective he should get a negative modifier in his relationship to ePlayer1... ePlayer1 should not get any such negative modifiers.
Question... is the code working as expected?
I also have a similar code that is far easier to test.
My question is, to save GetScenarioDiploModifier functions (as there are only three such), is there a way to amalgamate this and the first code? The text message for each is very similar so it would be nice to have them together. Somehow, I feel that the diplomatic modifier from the 2nd code could be easily brought as a value to be added to the 1st through some kind of subroutine, but I am uncertain how to do this.
Thank-you.
Regards, Craig
- ePlayer1 has three Earldoms while ePlayer2 has London (ePlayer2 should see a negative diplomatic modifier (red message) from ePlayer1.
- ePlayer1 has no Archdiocese while ePlayer2 has at least 1.
- a combination of the above 2.
In all cases, from ePlayer 2 perspective he should get a negative modifier in his relationship to ePlayer1... ePlayer1 should not get any such negative modifiers.
Question... is the code working as expected?
Code:
function VictoryCityB (ePlayer1, ePlayer2)
-- check diplomacy for ePlayer2 and ePlayer1
local pPlayer1 = Players[ePlayer1]
local pPlayer2 = Players[ePlayer2]
local isLondon = false
local iEarldom = GameInfoTypes.BUILDING_EARLDOM
local iArchdiocese = GameInfoTypes.BUILDING_ARCHDIOCESE
if pPlayer1:IsAlive () and pPlayer2:IsAlive () then
-- check cities owned for London
for pCity in pPlayer2:Cities() do
if pCity:GetName() == "London" then
isLondon = true
end
end
--vary diplomacy based on duchies owned and owning London
if (pPlayer1:CountNumBuildings(iEarldom) > 2) and isLondon == true then
return 90;
elseif (pPlayer1:CountNumBuildings(iArchdiocese) == 0 ) and (pPlayer2:CountNumBuildings(iArchdiocese) > 0 ) then
return 90;
elseif (pPlayer1:CountNumBuildings(iEarldom) > 2) and (pPlayer1:CountNumBuildings(iArchdiocese) == 0 ) and isLondon == true and (pPlayer2:CountNumBuildings(iArchdiocese) > 0 ) then
return 120;
else
return 0;
end
end
end
GameEvents.GetScenarioDiploModifier3.Add(VictoryCityB)
I also have a similar code that is far easier to test.
Code:
function VictoryCityA (ePlayer1, ePlayer2)
-- check diplomacy for ePlayer2
local pPlayer2 = Players[ePlayer2]
local isLondon = false
local iBuilding = GameInfoTypes.BUILDING_EARLDOM
if (pPlayer2:IsAlive ()) then
-- check cities owned for London
for pCity in pPlayer2:Cities() do
if pCity:GetName() == "London" then
isLondon = true
end
end
--vary diplomacy based on duchies owned and owning London
if (pPlayer2:CountNumBuildings(iBuilding) == 2) then
return 15;
elseif (pPlayer2:CountNumBuildings(iBuilding) == 1 ) and (isLondon == true) then
return 15;
elseif (pPlayer2:CountNumBuildings(iBuilding) == 2 ) and (isLondon == true) then
return 45;
elseif (pPlayer2:CountNumBuildings(iBuilding) == 3) then
return 45;
elseif (pPlayer2:CountNumBuildings(iBuilding) == 3 ) and (isLondon == true) then
return 75;
else
return 0;
end
end
end
GameEvents.GetScenarioDiploModifier2.Add(VictoryCityA)
My question is, to save GetScenarioDiploModifier functions (as there are only three such), is there a way to amalgamate this and the first code? The text message for each is very similar so it would be nice to have them together. Somehow, I feel that the diplomatic modifier from the 2nd code could be easily brought as a value to be added to the 1st through some kind of subroutine, but I am uncertain how to do this.
Thank-you.
Regards, Craig
