------------------------------------------------Variables------------------------------------------------

require( "package/quests/q_variables_define.lua" );
DebugOut( "generate infinite quests (file : package/quests/q_infinite_quests.lua)" );

--N.B: callbacks pour KillFX 
--Dans le cas d'un QuestElement qui ne possède qu'une seule action, le callback contenant le KillFX doit être
--le callback du QuestElement, pour éviter qu'à chaque rebouclage de l'action le FX soit tué puis relancé
----------------------------------------------
--Dans le cas d'un QuestElement qui possède plusieurs actions, le callback contenant le KillFX doit être
--le callback de l'action, pour que le FX soit bien tué entre chaque action
--(on a pas de pb de rebouclage du FX puisqu'on change d'action)

------------------------------------------------Knowledge------------------------------------------------

function F_laboratory_learning_retrieve( sOwnerName )
PlayInspectFX( sOwnerName )
return true
end

function F_laboratory_learning_stop( sOwnerName )
KillInspectFX( sOwnerName )
return true
end

function F_laboratory_learning_in_progress( sOwnerName )

return true
end

Quest
{
  name = "Q_laboratory",
  description = "Q_laboratory_desc",
  primary_quest = false,
  
  display_in_tome = false,
  
  Quest_Element
  {
  
    Check
    {
      value_type = "knowledge",
      level = 0 * G_check_factor,
    },
  
    name = "Q_laboratory_learning",
    interaction = "LD_knowledge_training",

	max_users = 3,
    loop = true,
	
	percentage = false,
	training = true,
    
    Inspect
    {
	  stay_where_dropped = false,
      interaction = "LD_knowledge_training",
      label = "learning",
      XpImproved = Knowledge,
      XpValue    = G_xp_standard_gain_per_infinite_action,
      fixTime = 5,
      fix_factor = 10,
      ratio_bonus_feerie = G_faerie_standard_gain_per_infinite_action,
      callback_done = "F_laboratory_learning_stop",
      callback_cancel = "F_laboratory_learning_stop",
      callback_retrieve_inprogress = "F_laboratory_learning_retrieve",
    },
  },
}

------------------------------------------------------------------------------------------------

------------------------------------------------Exploration------------------------------------------------
function F_exploration_training_retrieve( sOwnerName )
PlayInspectFX( sOwnerName )
return true
end

function F_exploration_training_stop( sOwnerName )
KillInspectFX( sOwnerName )
return true
end

function F_exploration_training_in_progress( sOwnerName )

return true
end

Quest
{
  name = "Q_telescope",
  description = "Q_telescope_desc",
  primary_quest = false,
  
  display_in_tome = false,
  
  Quest_Element
  {
	
	Check
    {
      value_type = "exploration",
      level = 0 * G_check_factor,
    },
  
    name = "Q_exploration_training",
    interaction = "LD_exploration_training",
	
	max_users = 2,
    loop = true,
	
	percentage = false,
	training = true,
	
    Inspect
    {
	  stay_where_dropped = false,
      interaction = "LD_exploration_training",
      label = "exploring",
      XpImproved = Exploration,
      XpValue    = G_xp_standard_gain_per_infinite_action,
      fixTime = 5,
      fix_factor = 10,
      ratio_bonus_feerie = G_faerie_standard_gain_per_infinite_action,
	  callback_done = "F_exploration_training_stop",
	  callback_cancel = "F_exploration_training_stop",
	  callback_retrieve_inprogress = "F_exploration_training_retrieve",
	  callback_inprogress = "F_exploration_training_in_progress",
    },
  },
}

------------------------------------------------------------------------------------------------

------------------------------------------------Nature------------------------------------------------
function F_nature_training_collecting_begin( sOwnerName )
PlayGatherSound( sOwnerName );
return true
end

function F_nature_training_collecting_retrieve( sOwnerName )
PlayGatherFX( sOwnerName );
return true
end

function F_nature_training_collecting_stop( sOwnerName )
KillGatherSound( sOwnerName );
KillGatherFX( sOwnerName );
return true
end


function F_nature_training_dropping_begin( sOwnerName )
PlayDropAppleSound( sOwnerName );
return true
end

function F_nature_training_dropping_stop( sOwnerName )
KillDropAppleSound( sOwnerName );
return true
end

function F_nature_training_condition_begin()
	bIsFoodStockFull = IsFoodStockFull()
	if( bIsFoodStockFull ) then
		DisplayInformation( "food_stock_full", "backgrounds/dialog/vignette_fee", "", 0, "", false );
	end
	return not bIsFoodStockFull;
end

function F_nature_training_condition_end()
	bIsFoodStockFull = IsFoodStockFull()
	if( bIsFoodStockFull ) then
		DisplayInformation( "food_stock_full", "backgrounds/dialog/vignette_fee", "", 0, "", false );
	end
	return bIsFoodStockFull;
end

Quest
{
  name = "Q_fruit_basket",
  description = "Q_fruit_basket_desc",
  primary_quest = false,
  prerequisites  = {"Q_hermit_fairie"},
  
  display_in_tome = false,
  
  Quest_Element
  {
  
  	Check
    {
      value_type = "nature",
      level = 0 * G_check_factor,
    },
  
    name = G_nature_training,
    interaction = "LD_nature_training",
    stock = "LD_reservoir",
	max_users = 4,
	
    loop = true,
	
	percentage = false,
	training = true,
	
	must_be_seen_to_be_completed = false,
    must_be_set_completed = false,
	must_notify_all_users = true,
	
	condition_begin = "F_nature_training_condition_begin",
	condition_end = "F_nature_training_condition_end",
	
    Gather
    {
      label = "collecting",
      collectTime = 5,
      gather_factor = G_food_gather_factor,
      source = "LD_nature_training",
      XpImproved = Nature,
      XpValue = 4 * G_xp_standard_gain_per_infinite_action,
      ratio_bonus_feerie = 3 * G_faerie_standard_gain_per_infinite_action,
	  callback_inprogress = "F_nature_training_collecting_begin",
	  callback_done = "F_nature_training_collecting_stop",
	  callback_cancel = "F_nature_training_collecting_stop",
	  callback_retrieve_inprogress = "F_nature_training_collecting_retrieve",
    },
    
    Deposite
    {
      label = "dropping",
      stock = "id_stock_nourriture_drop",
	  callback_inprogress = "F_nature_training_dropping_begin",
	  callback_done = "F_nature_training_dropping_stop",
	  callback_cancel = "F_nature_training_dropping_stop",
	  --callback_retrieve_inprogress = "F_nature_training_dropping_retrieve",
    },
  },
}

------------------------------------------------------------------------------------------------

------------------------------------------------Music------------------------------------------------
function F_music_training_retrieve( sOwnerName )
	PlayMusicFX( sOwnerName )
	return true
end

function F_music_training_inprogress( sOwnerName)
	PlayMusicSound( sOwnerName )
	return true
end

function F_music_training_stop( sOwnerName )
	KillMusicFX( sOwnerName )
	KillMusicSound( sOwnerName )
	return true
end

Quest
{
  name = "Q_theater",
  description = "Q_theater_desc",
  primary_quest = false,
  
  display_in_tome = false,
  
  
  
  Quest_Element
  {
	prerequisites = { "Q_legendary_melody_muse_playing" },
  
  	Check
    {
      value_type = "music",
      level = 0 * G_check_factor,
    },
	
    name = "Q_theater_playing",
    interaction = "LD_music_training",

	max_users = 3,
    loop = true,
	
	percentage = false,
	training = true,

    Musique
    {
	  stay_where_dropped = false,
      interaction = "LD_music_training",
      label = "playing",    
      XpImproved = Music,
      XpValue    = G_xp_standard_gain_per_infinite_action,
      fixTime = 5,
      fix_factor = 10,
      ratio_bonus_feerie = G_faerie_standard_gain_per_infinite_action,
	  callback_done = "F_music_training_stop",
	  callback_cancel = "F_music_training_stop",
	  callback_retrieve_inprogress = "F_music_training_retrieve",
	  callback_inprogress = "F_music_training_inprogress"
    },
  },
}

------------------------------------------------------------------------------------------------

------------------------------------ Eat -------------------------------------------------------
function F_eat_begin_condition_1()
	check = true
	if( GetFilledPercent( "LD_reservoir" ) == 0 ) then
		check = false
	end
	return check 
end

function F_eat_begin_condition_2()
	check = true
	if( GetFilledPercent( "LD_mill_stock" ) == 0 ) then
		check = false
	end
	return check 
end

Quest
{
  name = "Q_eat",
  description = "Q_eat_desc",
  display_in_tome = false,
  
  Quest_Element
  {  
    name = "Q_eating",
    interaction = "LD_reservoir",
    max_users = 200,
	
    percentage = false,
	
    must_be_seen_to_be_completed = false,
    must_be_set_completed = false,
	
	include_in_labrador_intentions = false,
	
	condition_begin = "F_eat_begin_condition_1",
	
	emoticone = "emoticon_hungry",
	
    Gather
    {
      label = "taking_food",
      collectTime = G_feed_collectTime,
      gather_factor = G_feed_gather_factor,
      source = "LD_reservoir",
	  for_eating = true,
    },
    
    Eat
    {
      label = "eating",
	  eat_factor = G_feed_eat_factor,
    },
  },
  
  Quest_Element
  {  
    name = "Q_eating2",
    interaction = "LD_mill_stock",
    max_users = 200,
	
    percentage = false,
	
    must_be_seen_to_be_completed = false,
    must_be_set_completed = false,
	
	condition_begin = "F_eat_begin_condition_2",
	
	emoticone = "emoticon_hungry",
	
	include_in_labrador_intentions = false,
	
    Gather
    {
      label = "taking_food",
      collectTime = G_feed_collectTime,
      gather_factor = G_feed_gather_factor,
      source = "LD_mill_stock",
	  for_eating = true,
    },
    
    Eat
    {
      label = "eating",
	  eat_factor = G_feed_eat_factor,
    },
  },
}

-----------------------------------------------------------------------------
