package edu.calpoly.csc480.Entomo.Tile.OdorTile;

import java.awt.*;

import com.bcurry.www.awt.*;

import edu.calpoly.csc480.Entomo.Ant.*;
import edu.calpoly.csc480.Entomo.Tile.*;

public class OdorTile extends Tile {
	public static final int maxOdor = 99;

	public OdorTile()					{this(0);}
	public OdorTile(int odor)		{setOdor(odor);}
	
	public char toChar()				{return ' ';}
	public String getName() {
		return (
		 means != null ? "Ant" : 
		 (odor != 0 ? "Pheremone" : "Empty")
		);
	}

	public boolean hasAnt()			{return (means != null);}

	final public int getOdor()		{return odor;}
	final public Means getMeans()	{return means;}

	public void setOdor(int odor) {
		this.odor = odor;
		view.updateScheme();
	}

	public void setMeans(Means means) {
		this.means = means;
	}

	public void decayOdor(int amount) {
		int newOdor = odor-amount;
		if (newOdor < 0) {newOdor = 0;}
		setOdor(newOdor);
	}

	public void spawnOdor(int amount) {
		int newOdor = odor+amount;
		if (newOdor > maxOdor) {newOdor = maxOdor;}
		setOdor(newOdor);
	}

	protected int odor;
	protected Means means;

	protected TileView makeView()		{return new OdorTileView();}
}