require "utils.utils"

local event = require 'utils.event'

local function on_marked_for_deconstruction(event)
	local player = game.players[event.player_index]
	local playtime = player.online_time
	if global.player_totals then
		if global.player_totals[player.name] then
			playtime = player.online_time + global.player_totals[player.name][1]
		end
	end 
	if playtime < 1296000 then
		event.entity.cancel_deconstruction(game.players[event.player_index].force.name)	
		player.print("Not enough total playtime to use the deconstruction planner yet.")
	end
end

event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction)