using UnityEngine;
using System.Collections;

public class HeartCigarette : Ritual {
    private const int DESIRED = 2;

    public override float validate()
    {
        return validate(person.slots);
    }

    public float validate(Slot[] slots)
    {
        int count = 0;
        int max = 0;

        Item item;

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

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

            if (max < count)
                max = count;
        }

        return ((float)max) / DESIRED;
    }

    }
