using UnityEngine;
using System.Collections.Generic;

public class Person : Ritual
{
    public Slot[] slots;
    public List<Ritual> rituals = new List<Ritual>();

    public string name;

    public Person(string name, int slots)
    {
        this.name = name;
        this.slots = new Slot[slots];
        Slot slot;
        for (int i = 0; i < slots; ++i)
        {
            slot = new Slot();
            slot.person = this;
            slot.index = i;
            this.slots[i] = slot;
        }
    }

    // Use this for initialization
    void Start()
    {
        this.person = this;
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            //print(checkRituals());
        }
    }

    public float checkRituals()
    {
        if (rituals.Count == 0)
            return 1f;

        float avg = 0f;
        foreach (Ritual ritual in rituals)
        {
            avg += ritual.validate();
        }

        return avg / rituals.Count;
    }

    public override float validate()
    {
        int count = 0;
        foreach (Slot slot in slots)
        {
            if (slot.item != null)
                ++count;
        }
        return (float)count / slots.Length;
    }
}
