package jonathan.geoffroy.zorbscity.model.cityObjects.buildings.houses;

import jonathan.geoffroy.zorbscity.model.Simulator;
import jonathan.geoffroy.zorbscity.model.cityObjects.buildings.House;

/**
 * A FreeHouse is a house which have no person inside.
 * It's the only house that player can put inside his city.
 * It transform into a TentHouse as soon as at least one person take the FreeHouse
 * This kind of house do not have any needed resource
 * @author Jonathan GEOFFROY
 * @version 0.1
 */
public class FreeHouse extends House {

	/**
	 * auto-generated serial (using eclipse)
	 */
	private static final long serialVersionUID = -7347638785374081426L;

	@Override
	public boolean shouldIncrease() {
		return numberPeople > 0;
	}

	@Override
	protected House getNextHouseType() {
		return new TentHouse(this);
	}

	@Override
	protected House getPreviousHouseType() {
		return null;
	}

	@Override
	public void onAddedIntoCity(Simulator sim) {
		super.onAddedIntoCity(sim);
		sim.addInhabitants(1);
	}

	@Override
	protected void addNeededResources() {}

	@Override
	public void addPeople(Simulator sim, int numberPeople) {
		super.addPeople(sim, numberPeople);
		if(this.numberPeople > 0) {
			sim.transform(this, getNextHouseType());
		}
	}

	@Override
	public int getMaxPeopleNumber() {
		return 4;
	}
}
