fortifyVillageQuestDone = false

------------------------------------------------------------------------------------------------------------------------------------
function createFortifyVillageQuest()

    StartSimpleJob("controlFortifyTowers")

    GUIQuestTools.StartQuestInformation("Tower", "Baut mindestens acht Türme aus!", 1, 1)

    end
------------------------------------------------------------------------------------------------------------------------------------
function controlFortifyTowers()

    local towers = countTowers()

    GUIQuestTools.UpdateQuestInformationString(towers .. "/" .. 8)

    if towers >= 8 then

        endChapterOne()

        GUIQuestTools.DisableQuestInformation()

        fortifyVillageQuestDone = true

        return true

        end

    end
------------------------------------------------------------------------------------------------------------------------------------
function countTowers()

    local result = 0

	local T2Buildings = {Logic.GetPlayerEntitiesInArea(	1,
								Entities.PB_Tower2,
								GetPosition("player1").X,
								GetPosition("player1").Y,
								10000,
								8) }
	local T3Buildings = {Logic.GetPlayerEntitiesInArea(	1,
								Entities.PB_Tower3,
								GetPosition("player1").X,
								GetPosition("player1").Y,
								10000,
								8) }
	
	local i

	for i=2, T2Buildings[1]+1 do

		if Logic.IsConstructionComplete(T2Buildings[i]) == 1 then
			result = result +1
    		end

	    end
		
		for i=2, T3Buildings[1]+1 do

		if Logic.IsConstructionComplete(T3Buildings[i]) == 1 then
			result = result +1
    		end

	    end


    return result

    end