using System.Collections;
using System.Collections.Generic;
using Assets._game.scripts;
using UnityEngine;
using UnityEngine.UI;

public class UIPlayerReportItem : MonoBehaviour
{

    public Text NameLabel;
    public Text RankLabel;
    public Text ProjectilesFiredLabel;
    public Text ProjectilesHitLabel;
    public Text HitRatioLabel;
    public Text KillsLabel;
    public Text DamageDealtLabel;
    public Text DamageTakenLabel;
    public Text TimeAliveLabel;
    public Image PlayerImage;

    public void Init(GamePlayerStatistics  playerStatistics)
    {
        Debug.Log("playerstats data " + playerStatistics.playerData);
        Debug.Log("playerstats data " + playerStatistics.playerId);
        NameLabel.text = string.Format("{0}-{1}", playerStatistics.playerData.Name, playerStatistics.playerId);
        RankLabel.text = string.Format("Rank: {0}", playerStatistics.rank);
        ProjectilesFiredLabel.text = string.Format("Projectiles fired: {0}", playerStatistics.projectilesFired);
        ProjectilesHitLabel.text = string.Format("Projectiles hit: {0}", playerStatistics.projectilesHits);
        var fired = playerStatistics.projectilesFired;
        if (fired == 0)
        {
            fired = 1;
        }
        HitRatioLabel.text = string.Format("Hit ratio: {0:0}%", playerStatistics.projectilesHits / (float)fired * 100f);
        KillsLabel.text = string.Format("Kills: {0}", playerStatistics.kills);
        DamageDealtLabel.text = string.Format("Damage dealt: {0}", playerStatistics.damageGiven);
        DamageTakenLabel.text = string.Format("DamageTaken: {0}", playerStatistics.damageTaken);
        TimeAliveLabel.text = string.Format("Time alive: {0: 0.0}s", playerStatistics.timeAlive);
        PlayerImage.sprite = playerStatistics.playerData.Sprite;
    }
}
