View Javadoc

1   package cz.cuni.amis.pogamut.defcon.ai.buildingai;
2   
3   import cz.cuni.amis.pogamut.defcon.agent.impl.DefConAgentLogicController;
4   import cz.cuni.amis.pogamut.defcon.ai.AbstractAI;
5   import cz.cuni.amis.pogamut.defcon.base3d.worldview.object.DefConLocation;
6   import cz.cuni.amis.pogamut.defcon.communication.messages.infos.DefConUnitObject;
7   
8   /**
9    * Implements common features for buildings.
10   * 
11   * @author Radek 'Black_Hand' Pibil
12   * 
13   * @param <T>
14   */
15  public abstract class AbstractBuildingAI<T extends DefConUnitObject<?>> extends
16  		AbstractAI
17  		implements IBuildingAI {
18  
19  	protected final T building;
20  	protected int nukes;
21  
22  	public AbstractBuildingAI(T building, DefConAgentLogicController<?> logic) {
23  		super(logic, building.getId());
24  		this.building = building;
25  		nukes = logic.getGameInfo().getNukeSupply(unitId);
26  	}
27  
28  	protected boolean hasSpareNukes() {
29  		return nukes > 0;
30  	}
31  
32  	@Override
33  	public DefConLocation getLocation() {
34  		return building.getLocation();
35  	}
36  }