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

public class Progress {
    public class Defeat
    {
        public string Name
        {
            get;
            private set;
        }

        public int Points
        {
            get;
            private set;
        }

        public Defeat(string name, int points)
        {
            Name = name;
            Points = points;
        }
    }

    static List<string> defeatedLevels = new List<string>();
    static List<int> rewardedPoints = new List<int>();

    public static void MarkAsDefeated(string name, int points)
    {
        defeatedLevels.Add(name);
        rewardedPoints.Add(points);
    }

    public static bool IsDefeated(string name)
    {
        return defeatedLevels.Contains(name);
    }

    public static Defeat LatestDefeat()
    {
        if (defeatedLevels.Count == 0)
        {
            return null;
        }

        return new Defeat(defeatedLevels[defeatedLevels.Count - 1], rewardedPoints[rewardedPoints.Count - 1]);
    }

    public static int TotalPoints()
    {
        return rewardedPoints.Sum();
    }
}
