package ei.game.player;

import java.util.ArrayList;

import ei.engine.scene.Node;
import ei.game.scene.GameEntity;
import ei.game.scene.buildings.Building;

public abstract class Player {
	private ArrayList<GameEntity> units;
	private Node unitsNode;
	private int kredits;
	
	public Player(){
		units = new ArrayList<GameEntity>();
		unitsNode = new Node("HumanPlayerNode");
		kredits = 1000;
	}
	
	public void setKredits(int k){
		kredits = k;
	}
	
	public int getKredits(){
		return kredits;
	}
	
	public void addKredits(int add){
		kredits += add;
	}
	
	public void addUnit(GameEntity u){
		units.add(u);
		unitsNode.add(u.getNode());
	}
	
	public void removeUnit(GameEntity u){
		units.remove(u);
		unitsNode.remove(u.getNode());
	}
	
	public GameEntity getUnit(int i){
		return units.get(i);
	}
	
	public int unitCount(){
		return units.size();
	}
	
	public Node getNode(){
		return unitsNode;
	}

	public void update() {
		for(int i=0; i<units.size() ;i++){
			units.get(i).update();			
		}
	}
	
	public void kilAll(){
		for(int i=0; i<units.size() ;i++){
			units.get(i).destroyed();
			units.get(i).remove();		
		}
	}
	
	public abstract Building getCC();
	
	public abstract boolean defeated();
	
	public abstract void endGame(int status);
}
