require 'TimedActions/ISReadABook.lua'
require 'TimedActions/ISReadWorldMap.lua'

Kinkocalypse = Kinkocalypse or {}
Kinkocalypse.ISReadABookOrigStart = ISReadABook.start;
Kinkocalypse.ISReadWorldMapOrigIsValid = ISReadWorldMap.isValid;

Kinkocalypse.IsBlindFoldEquipped = function(player)
	local wornItem = player:getWornItem("RestraintsHead")
	return wornItem ~= nil and Kinkocalypse.IsHasTag(wornItem, "SteelBlindFold")
end

Kinkocalypse.IsCanRead = function()
	local player = getPlayer()
	if Kinkocalypse.IsBlindFoldEquipped(player) == true or Kinkocalypse.IsPunishmentActive("Blinded") == true then
		return false
	else return true end
end

ISReadABook.start = function(self)
	if Kinkocalypse.ControllCenterIsOn() == true and Kinkocalypse.IsPunishmentActive("NoRead") then
		Kinkocalypse.AddPunishmentScore(20, getText("UI_Kincalypse_ViolateNoReadRule"))
		Kinkocalypse.AddPunishment("NoRead", 60 + ZombRand(120))
		Kinkocalypse.AddPunishment("Blinded", 120)
	end

	if Kinkocalypse.IsCanRead() == false then
		Kinkocalypse.Say(getText("UI_Kincalypse_CantSeeAnthing"))
		self:forceStop()
	else
		Kinkocalypse.ISReadABookOrigStart(self)	
	end	
end

ISReadWorldMap.isValid = function()
	if Kinkocalypse.IsCanRead() == false then
		Kinkocalypse.Say(getText("UI_Kincalypse_CantSeeAnthing"))
		return false
	end	
	return Kinkocalypse.ISReadWorldMapOrigIsValid(self)
end

Kinkocalypse.CheckBlindFold = function()
	local player = getPlayer()
	local playerNum = player:getPlayerNum()
	local nightVision = false

	if Kinkocalypse.IsPunishmentActive("Blinded") == true or Kinkocalypse.IsBlindFoldEquipped(player) then
		nightVision = true
		else
		nightVision = false
	end
end
