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

/*??????????????*/

public class HistoryRecorder : MonoBehaviour
{
    private List<float> realTimeReward = new List<float> ();
    private List<float> EPTotalRewards = new List<float> ();
    private List<int> EPTotalShootCount = new List<int> ();

    private int realTimeWKeyCount = 0;
    private int realTimeAKeyCount = 0;
    private int realTimeSKeyCount = 0;
    private int realTimeDKeyCount = 0;
    private int realTimeShootCount = 0;


    // add Record History -----------------------------
    public void addRealTimeReward(float reward)
    {
        realTimeReward.Add(reward);
    }
    public void addEPTotalRewards(float EPTotalReward)
    {
        EPTotalRewards.Add(EPTotalReward);
    }
    public void addEPTotalShootCount(int TotalShootCount)
    {
        EPTotalShootCount.Add(TotalShootCount);
    }
    public void realTimeKeyCounter(int vertical,  int horizontal, int shoot)
    {
        if (vertical == 1)
        {
            realTimeWKeyCount += 1;
        }
        else if (vertical == -1)
        {
            realTimeSKeyCount += 1;
        }
        if (horizontal == 1)
        {
            realTimeDKeyCount += 1;
        }
        else if (horizontal == -1)
        {
            realTimeAKeyCount += 1;
        }
        if (shoot == 1)
        {
            realTimeShootCount += 1;
        }
    }

    // math job---------------------------------------
    // delete RealTimeReward item
    public void resetRealTimeReward()
    {
        realTimeReward.Clear();
    }
    // set all realTimeKeyCount to 0
    public void resetrealTimeKeyCounter()
    {
        realTimeAKeyCount = 0;
        realTimeDKeyCount = 0;
        realTimeWKeyCount = 0;
        realTimeSKeyCount = 0;
        realTimeShootCount = 0;
    }
    // calc RealTimeReward's Average and Add to EPTotalRewards
    public void EPTotalRewardsUpdate()
    {
        float EPSumRealTimeReward = getSumRealTimeReward();
        resetRealTimeReward();
        addEPTotalRewards(EPSumRealTimeReward);
    }

    // get Record History -----------------------------
    // get EPTotalReward List
    public List<float> getEPTotalReward()
    {
        return (EPTotalRewards);
    }
    // get EPTotalShootCount List
    public List<int> getEPTotalShootCount()
    {
        return (EPTotalShootCount);
    }
    // get RealTimeReward's Mean
    public float getMeanRealTimeReward()
    {
        return (realTimeReward.Average());
    }
    // get RealTimeReward's Sum
    public float getSumRealTimeReward()
    {
        return realTimeReward.Sum();
    }
    // get LastEPTotalReward last item
    public float getLastEPTotalReward()
    {
        return (EPTotalRewards.Last());
    }
    //get KeyCount
    public (int w,int s,int a,int d,int shoot) getKeyCount()
    {
        return (realTimeWKeyCount, realTimeSKeyCount, realTimeAKeyCount, realTimeDKeyCount, realTimeShootCount);
    }


}
