View Javadoc

1   package cz.cuni.amis.pogamut.defcon.utils.closestpoints;
2   
3   import java.util.List;
4   import java.util.Map.Entry;
5   import java.util.SortedMap;
6   import java.util.logging.Logger;
7   
8   import cz.cuni.amis.pogamut.defcon.utils.closestpoints.ClosestPointsLookUp.ClosestPoints;
9   
10  /**
11   * Collects the reasonably good spawn points for fleet spawning and simplifies
12   * access to them.
13   * 
14   * @author Radek 'Black_Hand' Pibil
15   * 
16   */
17  public class ClosestPointsManager {
18  
19  	/**
20  	 * First index is enemy, second his territoryId, third own territoryId.
21  	 */
22  	private SortedMap<Integer, SortedMap<Integer, List<ClosestPoints>>> closestPoints;
23  
24  	private Logger log;
25  
26  
27  	public ClosestPointsManager(
28  			SortedMap<Integer, SortedMap<Integer, List<ClosestPoints>>> closestPoints) {
29  		this(closestPoints, null);
30  	}
31  
32  	public ClosestPointsManager(
33  			SortedMap<Integer, SortedMap<Integer, List<ClosestPoints>>> closestPointsToEnemyTerritories,
34  			Logger log) {
35  		this.closestPoints = closestPointsToEnemyTerritories;
36  		this.log = log;
37  	}
38  
39  	public final SortedMap<Integer, SortedMap<Integer, List<ClosestPoints>>> getClosestPoints() {
40  		return closestPoints;
41  	}
42  
43  	public List<ClosestPoints> getClosestForSpecificTerritories(
44  			int enemyTerritoryId,
45  			int ownTerritoryId) {
46  
47  		return closestPoints.get(enemyTerritoryId).get(ownTerritoryId);
48  	}
49  
50  	public SortedMap<Integer, List<ClosestPoints>> getClosestForEnemyTerritory(
51  			int enemyTerritoryId) {
52  
53  		return closestPoints.get(enemyTerritoryId);
54  	}
55  }