using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class AvailableActionsManager : MonoBehaviour {

	public Dictionary<string, bool> allowedRituals = new Dictionary<string, bool>(){
		{"SACRIFICE", true},
		{"FERTILITY", true},
		{"RAIN", true },
		{"FIRE", true },
		{"DIVINE", true },
	};

	static AvailableActionsManager _instance;

	static public AvailableActionsManager instance {
		// using lazy instantiation here... 
		get{
			return _instance;
		}
	}

	void Awake(){
		_instance = this;
	}
	
	// Update is called once per frame

	void Start(){
		Update ();
	}

	void Update () {
		CanUseSacrifice();
		CanUseFertility();
		CanUseRain();
		CanUseFire();
		CanUseDivine();
		// PrintDict();
	}

	void CanUseSacrifice(){
		if(AdeptFactory.instance.GetAliveAdepts() <= 2){
			allowedRituals["SACRIFICE"] = false;
		}
		else{
			allowedRituals["SACRIFICE"] = true;
		}
	}

	void CanUseFertility(){
		if(AdeptFactory.instance.GetAliveAdepts() >= 10 || 
			AdeptFactory.instance.GetAliveAdepts() < RitualManager.instance.fertRitual.difficulty){
			allowedRituals["FERTILITY"] = false;
		}
		else{
			allowedRituals["FERTILITY"] = true;
		}
	}

	void CanUseRain(){
		if(AdeptFactory.instance.GetAliveAdepts() < RitualManager.instance.rainRitual.difficulty){
			allowedRituals["RAIN"] = false;
		}
		else{
			allowedRituals["RAIN"] = true;
		}
	}

	void CanUseFire(){
		if(AdeptFactory.instance.GetAliveAdepts() < RitualManager.instance.fireRitual.difficulty){
			allowedRituals["FIRE"] = false;
		}
		else{
			allowedRituals["FIRE"] = true;
		}
	}

	void CanUseDivine(){
		if(AdeptFactory.instance.GetAliveAdepts() < RitualManager.instance.divineRitual.difficulty){
			allowedRituals["DIVINE"] = false;
		}
		else{
			allowedRituals["DIVINE"] = true;
		}
	}

	// DEBUG ONLY

	void PrintDict(){
		foreach(KeyValuePair<string,bool> entry in allowedRituals){
			Debug.Log(entry.Key.ToString() + "," + entry.Value.ToString());
		}
		Debug.Log("==================");
	}
}
