Need help LUA: count number of city captured

Cat-du-fromage

Warlord
Joined
Nov 17, 2018
Messages
183
Hi,
i have some issue trying to count the number of cities captured by a civilization using city:GetOriginalOwner()

But for some reason it count all the cities regardless if they were capture or not...

Code:
function NumConquest()
    local player = Players[Game.GetActivePlayer()]
    local isConquest = 0
        for city in player:Cities() do
            if player:GetCivilizationType() == civilizationID then
            if city:GetOriginalOwner() ~= civilizationID or city:IsPuppet() then
                isConquest = isConquest+1
            end
        end
        end
    return isConquest
end
Did someone see the error?
 
A city's original owner (a player ID) will rarely be equal to civilizationID - which is either undefined (nil) or, assuming the first if within the loop is returning true, the ID of the player's civilization (the code probably only works if playing as America)
 
Top Bottom