package rpgEngine.Data.Abstract.Party;

import java.util.ArrayList;
import java.util.List;

import rpgEngine.Data.Abstract.CharacterStats;
import rpgEngine.Data.Abstract.Item;
import rpgEngine.Data.Abstract.World.CharacterAvatar;
import rpgEngine.Data.Raw.Graphics.CharacterSet;
import rpgEngine.Resources.LevelRequirementPool;

public class HumanPlayer extends CharacterStats implements CharacterAvatar {
	private CharacterSet charSet;
	private Integer heroID;
	private String name;
	private Integer level;
	private Integer experience;
	private Integer experienceToNextLevel;
	private Integer characterSetPosition;
	private List<Skill> skills;
	private Item weapon;
	private Item helmet;
	private Item armor;
	private Item accessory;
	
	public HumanPlayer() {
		this(-1,0,0,0,0,0,0,null,"",1);
	}
	
	public HumanPlayer(Integer i, Integer hp, Integer mp, Integer atk, Integer def, Integer skl, Integer bar, CharacterSet c, String n, Integer l) {
		super(hp,mp,atk,def,skl,bar);
		
		heroID = i;
		charSet = c;
		name = n;
		level = l;
		
		experience = LevelRequirementPool.getInstance().getPoolItem(level);
		experienceToNextLevel = LevelRequirementPool.getInstance().getPoolItem(level+1);

		characterSetPosition = CharacterSet.IMAGES_DOWN_0;
		
		skills = new ArrayList<Skill>();
		
		weapon = null;
		helmet = null;
		armor = null;
		accessory = null;
	}

	public CharacterSet getCharSet() {
		return charSet;
	}

	public void setCharSet(CharacterSet charSet) {
		this.charSet = charSet;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getLevel() {
		return level;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}

	@Override
	public CharacterSet getCharacterSet() {
		return getCharSet();
	}

	@Override
	public Integer getCharacterPosition() {
		return characterSetPosition;
	}
	
	@Override
	public void setCharacterPosition(Integer p) {
		characterSetPosition = p;
	}

	public Integer getExperience() {
		return experience;
	}

	public void setExperience(Integer experience) {
		this.experience = experience;
	}

	public Integer getExperienceToNextLevel() {
		return experienceToNextLevel;
	}

	public void setExperienceToNextLevel(Integer experienceToNextLevel) {
		this.experienceToNextLevel = experienceToNextLevel;
	}

	public List<Skill> getSkills() {
		return skills;
	}

	public void setSkills(List<Skill> skills) {
		this.skills = skills;
	}

	public Item getWeapon() {
		return weapon;
	}

	public void setWeapon(Item weapon) {
		this.weapon = weapon;
	}

	public Item getHelmet() {
		return helmet;
	}

	public void setHelmet(Item helmet) {
		this.helmet = helmet;
	}

	public Item getArmor() {
		return armor;
	}

	public void setArmor(Item armor) {
		this.armor = armor;
	}

	public Item getAccessory() {
		return accessory;
	}

	public void setAccessory(Item accessory) {
		this.accessory = accessory;
	}
	
	
	@Override
	public Integer getAttack() {
		Integer val = 0;
		
		val = super.getAttack();
		
		if(weapon != null) {
			val = val + weapon.getStatChanges().getAttack();
		}
		
		if(helmet != null) {
			val = val + helmet.getStatChanges().getAttack();
		}
		
		if(armor != null) {
			val = val + armor.getStatChanges().getAttack();
		}
		
		if(accessory != null) {
			val = val + accessory.getStatChanges().getAttack();
		}
		
		return val; 
	}
	
	
	@Override
	public Integer getDefense() {
		Integer val = 0;
		
		val = super.getDefense();
		
		if(weapon != null) {
			val = val + weapon.getStatChanges().getDefense();
		}
		
		if(helmet != null) {
			val = val + helmet.getStatChanges().getDefense();
		}
		
		if(armor != null) {
			val = val + armor.getStatChanges().getDefense();
		}
		
		if(accessory != null) {
			val = val + accessory.getStatChanges().getDefense();
		}
		
		return val;
	}
	
	
	@Override
	public Integer getSkill() {
		Integer val = 0;
		
		val = super.getSkill();
		
		if(weapon != null) {
			val = val + weapon.getStatChanges().getSkill();
		}
		
		if(helmet != null) {
			val = val + helmet.getStatChanges().getSkill();
		}
		
		if(armor != null) {
			val = val + armor.getStatChanges().getSkill();
		}
		
		if(accessory != null) {
			val = val + accessory.getStatChanges().getSkill();
		}
		
		return val;
	}
	
	
	@Override
	public Integer getBarrier() {
		Integer val = 0;
		
		val = super.getBarrier();
		
		if(weapon != null) {
			val = val + weapon.getStatChanges().getBarrier();
		}
		
		if(helmet != null) {
			val = val + helmet.getStatChanges().getBarrier();
		}
		
		if(armor != null) {
			val = val + armor.getStatChanges().getBarrier();
		}
		
		if(accessory != null) {
			val = val + accessory.getStatChanges().getBarrier();
		}
		
		return val;
	}
	
	
	@Override
	public Integer getMaxHP() {
		Integer val = 0;
		
		val = super.getMaxHP();
		
		if(weapon != null) {
			val = val + weapon.getStatChanges().getMaxHP();
		}
		
		if(helmet != null) {
			val = val + helmet.getStatChanges().getMaxHP();
		}
		
		if(armor != null) {
			val = val + armor.getStatChanges().getMaxHP();
		}
		
		if(accessory != null) {
			val = val + accessory.getStatChanges().getMaxHP();
		}
		
		return val;
	}
	
	
	@Override
	public Integer getMaxMP() {
		Integer val = 0;
		
		val = super.getMaxMP();
		
		if(weapon != null) {
			val = val + weapon.getStatChanges().getMaxMP();
		}
		
		if(helmet != null) {
			val = val + helmet.getStatChanges().getMaxMP();
		}
		
		if(armor != null) {
			val = val + armor.getStatChanges().getMaxMP();
		}
		
		if(accessory != null) {
			val = val + accessory.getStatChanges().getMaxMP();
		}
		
		return val;
	}

	public Integer getHeroID() {
		return heroID;
	}

	public void setHeroID(Integer heroID) {
		this.heroID = heroID;
	}

	public Integer getBaseHP() {
		return super.getHP();
	}

	public Integer getBaseMP() {
		return super.getMP();
	}
	
	public Integer getBaseMaxHP() {
		return super.getMaxHP();
	}
	
	public Integer getBaseMaxMP() {
		return super.getMaxMP();
	}
	
	public Integer getBaseAttack() {
		return super.getAttack();
	}
	
	public Integer getBaseDefense() {
		return super.getDefense();
	}
	
	public Integer getBaseSkill() {
		return super.getSkill();
	}
	
	public Integer getBaseBarrier() {
		return super.getBarrier();
	}
}
