using UnityEngine;
using System.Collections;

public class CoffeeCigartteToilet : Ritual {
    private const int DESIRED = 3;

    public override float validate()
    {
        int count = 0;
        int max = 0;

        Item item;

        for (int i = 0; i < person.slots.Length; ++i)
        {
            item = person.slots[i].item;
            if (item != null)
            {
                if (item.gameObject.GetComponent<Coffee>() != null)
                {
                    count = 1;
                }
                else if ((count == 1 && item.gameObject.GetComponent<Cigarette>() != null) ||
                         (count == 2 && item.gameObject.GetComponent<Toilet>() != null))
                {
                    count++;

                    if (count == DESIRED)
                        return 1f;
                }
                else
                {
                    count = 0;
                }
            }

            if (max < count)
                max = count;
        }
        
        return (float)max / DESIRED;
    }
}
