View Javadoc

1   package nl.tudelft.goal.ut2004.selector;
2   
3   import java.util.Collection;
4   
5   import cz.cuni.amis.pogamut.base3d.worldview.object.ILocated;
6   import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;
7   import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.FlagInfo;
8   
9   /**
10   * Selects the friendly flag carrier.
11   * 
12   * @author mpkorstanje
13   *
14   */
15  public class FriendlyFlagCarrier extends ContextSelector {
16  
17  	
18  	/* (non-Javadoc)
19  	 * @see java.lang.Object#toString()
20  	 */
21  	@Override
22  	public String toString() {
23  		return "FriendlyFlagCarrier";
24  	}
25  
26  	@Override
27  	public ILocated select(Collection<? extends ILocated> c) {
28  		
29  		FlagInfo flag = modules.getGame().getCTFFlag(1- modules.getInfo().getTeam());
30  		UnrealId holderId = flag.getHolder();
31  		if(holderId == null){
32  			return null;
33  		}
34  		
35  		return modules.getPlayers().getPlayer(holderId);
36  	}
37  }