-- LocTailor

LocTailor = Location:new("LocTailor")

----------------------------------------------------------------------------------------------------
function LocTailor_UPDATE()
	return 0
end

----------------------------------------------------------------------------------------------------
function LocTailor_INIT()
    LocTailor:init()
end

----------------------------------------------------------------------------------------------------
LocTailor:setSceneHandler(1,
    function(aScene, aEvent)
        if aEvent == "capture" then
            aScene:captureObjects({'paper', 'hall_tree', 'jacket', 'trousers'})

        elseif aEvent == "generic_init" then
            aScene:setWinTerms({"ho_collected", "activate_lamp"})
            aScene:setHidsParams({"paper"}, {inventory = true})
            aScene:setHidsParams({"hall_tree"}, {active = false})

        elseif aEvent == "start" then
            aScene:setRemark('ids_remark_loctailor_1')
            aScene:setTask("ids_challenge_loctailor_1")      
            aScene:attachHids(aScene:getHidList())
            aScene:attachInteract("lamp", "paper")

        elseif aEvent == "found_jacket" then
            aScene:setHidsParams({"hall_tree"}, {active = true})

        elseif aEvent == "activate_lamp" then
            aScene:onChallengeComplete()
            aScene:detachInteract("lamp")
            aScene:setInteractParams("lamp", {visible = false})
            aScene:setTask("ids_collect_ho")

        end
    end)

----------------------------------------------------------------------------------------------------
LocTailor:setSceneHandler(2,
    function(aScene, aEvent)
        if aEvent == "capture" then
            aScene:captureObjects({'rope', 'scissors'})
        elseif aEvent == "generic_init" then
            
            aScene:setWinTerms({"ho_collected", "activate_curtain"})
            aScene:setHidsParams({"scissors"}, {inventory = true})
            aScene:setHidsParams({"rope"}, {active = false, visible = false})
            aScene:setHidsParams({"ribbon"}, {active = false})

        elseif aEvent == "start" then
        
            aScene:setRemark('ids_remark_loctailor_2')
            aScene:setTask("ids_challenge_loctailor_2")      
            aScene:attachHids(aScene:getHidList())
            aScene:attachInteract("curtain", "scissors")

        elseif aEvent == "activate_curtain" then
            aScene:setHidsParams({"rope"}, {active = true, visible = true})
            aScene:setHidsParams({"ribbon"}, {active = true})
            ho:click('hid_2_rope')
            aScene:onChallengeComplete()
            aScene:setTask("ids_collect_ho")

        end
    end)

----------------------------------------------------------------------------------------------------
LocTailor:setSceneHandler(3,
    function(aScene, aEvent)
    
        -- face show (cup_tailor -> mirror)
    
        if aEvent == "capture" then
            aScene:captureObjects({'face', 'cup_tailor'})

        elseif aEvent == "generic_init" then
            
            aScene:setWinTerms({"ho_collected", "activate_mirror"})
            aScene:setHidsParams({"cup_tailor"}, {inventory = true})
            aScene:setHidsParams({"face"}, {active = false, visible = false})

        elseif aEvent == "start" then
        
            aScene:setRemark('ids_remark_loctailor_3')
            aScene:setTask("ids_challenge_loctailor_3")
            aScene:attachHids(aScene:getHidList())
            aScene:attachInteract("mirror", "cup_tailor")

        elseif aEvent == "activate_mirror" then
            aScene:setHidsParams({"face"}, {active = true, visible = true})
            aScene:onChallengeComplete()
            aScene:setTask("ids_collect_ho")

        end
    end)

----------------------------------------------------------------------------------------------------
LocTailor:setSceneHandler(4,
    function (aScene, aEvent)
        if aEvent == "capture" then
            aScene:captureObjects({'dummy_head', 'dummy_arms'})

        elseif aEvent == "generic_init" then
            
            aScene:setWinTerms({"ho_collected", "activate_dummy_tailor"})

        elseif aEvent == "start" then
			aScene:setRemark('ids_remark_loctailor_4')
            aScene:setTask('ids_challenge_loctailor_4')
            aScene:attachHids(aScene:getHidList({except = {'dummy_parts'}}))
            aScene:addItemMix('dummy_parts', {'dummy_head', 'dummy_arms'})

        elseif aEvent == "found_dummy_parts" then
            aScene:attachInteract('dummy_tailor', 'dummy_parts')

        elseif aEvent == "activate_dummy_tailor" then
            aScene:onChallengeComplete()
            aScene:setTask("ids_collect_ho")

        end
    end)

----------------------------------------------------------------------------------------------------
LocTailor:setSceneHandler(5,
    function(aScene, aEvent)
        if aEvent == "capture" then
            aScene:captureObjects({'robber_mask'})

        elseif aEvent == "generic_init" then
            aScene:setWinTerms({"ho_collected", "activate_sewing_machine"})
            aScene:setHidsParams({"robber_mask"}, {active = false, visible = false})

        elseif aEvent == "start" then
            aScene:setRemark('ids_remark_loctailor_5')
            aScene:setTask("ids_challenge_loctailor_5")
            aScene:attachHids(aScene:getHidList({except = {'fabric_threads'}}))
            aScene:addItemMix('fabric_threads', {'black_threads', 'black_fabric'})

        elseif aEvent == "found_fabric_threads" then
            aScene:attachInteract("sewing_machine", "fabric_threads")

        elseif aEvent == "activate_sewing_machine" then
            aScene:setHidsParams({"robber_mask"}, {active = true, visible = true})
            ho:click('hid_5_robber_mask')
            aScene:onChallengeComplete()
            aScene:setTask("ids_collect_ho")

        end
    end)
