using UnityEngine;
using System.Collections.Generic;

[System.Serializable]
public class PlayerStats {

    // Attributes.
    private Inventory inventory;

    // Default attributes 
    private int level = 1;
    private int health = 50;
    private int strength = 10;
    private int constitution = 10;
    private int magic = 10;
    private int exp = 0;
    private int maxHealth = 50;
    private int maxMagic = 10;
    private bool dead = false;

    // Position, scene and floor info. 
    // Dirty 'cause the serializable data issue.
    public float posx, posy, posz;
    public string floor;
    public string scene;

    // Door of the scene used.
    public int auxExit = 0;

    // Empty constructor. Creates empty Inventory.
    public PlayerStats() { 
        this.inventory =  new Inventory(new List<int>());
    }

    // Get some experience!
    public void addExperience(int exp) { 
        this.exp += exp; 
    }

    // Get some damage!
    // If the player is dead, is time to go to the game over screen.
    public void receiveDamage(int damage) { 
        this.health -= damage;
        if (health < 0) this.dead = true;
    }

    // Get some heal!
    public void heal(int v) {
        this.health += v;
        if (health < maxHealth) this.health = maxHealth;
    }


    // Checks if the inventory contains an item.
    public bool containsItem(int id) {
        return this.inventory.containsItem(id);
    }

    // Add a new item to the inventory.
    public void addItem(int id) {
        this.inventory.addItem(id);
    }

    // TOSTRING
    public override string ToString() {
        return "Level: " + this.level + "    Health: " + this.health
            + "    Magic: " + this.magic + "    Exp: " + this.exp
            + "    Inventory: " + this.inventory.ToString();

    }

    // Setters.
    public bool isDead() { return this.dead; }
    public void setLevel(int v) { this.level = v; }
    public void setHealth(int v) { this.health = v; }
    public void setMagic(int v) { this.magic = v; }
    public void setExp(int v) { this.exp = v; }
    public void setMaxMagic(int v) { this.maxMagic = v; }
    public void setMaxHealth(int v) { this.maxHealth = v; }
    public void setStrength(int v) { this.strength = v; }
    public void setConstitution(int v) { this.constitution = v; }
    
    // Getters.
    public int getLevel() { return this.level; }
    public int getHealth() { return this.health; }
    public int getMagic() { return this.magic; }
    public int getExp() { return this.exp; }
    public int getMaxMagic() { return this.maxMagic; }
    public int getMaxHealth() { return this.maxHealth; }
    public int getConstitution() { return this.constitution; }
    public int getStrength() { return this.strength; }
    public Inventory getInventory() { return this.inventory; }
}
