// Update is called once per frame
    void Update()
    {
        // trimming to reduced list
        afflictions = player.afflictions;
        currentSize = afflictions.Count;
        storedAfflictions.Clear();
        for (int i = 0; i < afflictions.Count; i++)
        {
            string name = afflictions[i].AfflictionName;
            if (!storedAfflictions.ContainsKey(name))
            {
                storedAfflictions.Add(name, afflictions[i]);
                stacks[afflictions[i]] = 1;
            }
            else
            {
                storedAfflictions.Remove(name);
                storedAfflictions.Add(name, afflictions[i]);
                stacks[afflictions[i]] += 1;
            }
        }
        // storedAfflictions => objects
        int l = 0;

        if (currentSize != previousSize)         //clear list
        {
            foreach (GameObject obj in storedAfflictionsObjects)
            {
                Image          img = storedAfflictionsObjects[l].GetComponent <Image>();
                AfflictionItem af  = storedAfflictionsObjects[l].GetComponent <AfflictionItem>();
                af = null;
                Text stack = storedAfflictionsObjects[l].transform.GetChild(0).GetComponent <Text>();
                stack.text = "";
                img.sprite = null;
                img.color  = new Color(0, 0, 0, 0);
                l++;
            }
        }
        l = 0;
        foreach (KeyValuePair <string, Affliction> pair in storedAfflictions)
        {
            AfflictionItem af = storedAfflictionsObjects[l].GetComponent <AfflictionItem>();
            af.affliction = pair.Value;
            Image img   = storedAfflictionsObjects[l].GetComponent <Image>();
            Text  stack = af.transform.GetChild(0).GetComponent <Text>();
            stack.text = stacks[af.affliction].ToString();
            img.color  = Color.white;
            img.sprite = af.affliction.Icon;
            l++;
        }
        previousSize = currentSize;
    }
    private void OnHoverBuff(PointerEventData data)
    {
        AfflictionItem item = data.pointerCurrentRaycast.gameObject.GetComponent <AfflictionItem>();

        if (item != null && item.affliction != null)
        {
            toolTip.SetActive(true);
            toolTip.transform.position = data.pointerCurrentRaycast.gameObject.transform.position - new Vector3(150, -75);
            Text txt   = toolTip.transform.GetChild(0).GetComponent <Text>();
            Text stats = toolTip.transform.GetChild(1).GetComponent <Text>();
            txt.text = item.affliction.AfflictionName;
            foreach (Stat stat in item.affliction.Stats)
            {
                string value = Stat.GetStatString(stat);
                stats.text += stat.Name + ": " + value + "\n";
            }
        }
    }