* @throws RealPlayerException
* @throws ClickedByRealPlayerException
*/
public void clicked() throws RealPlayerException {
Player realPlayer = null;
try {
realPlayer = Game.getInstance().getPlayerManager().getRealPlayer();
} catch (RealPlayerException e) {
e.printStackTrace();
return;
}
Base selectedBases = realPlayer.getSelectedBases();
// 1st case : the player doesn't have any selected base, so current one become his selected base (if it's his base) !
if(selectedBases == null) {
// if he selects a neutral base : nothing is done
if(this.getPlayer() == null){
System.out.println("1st case : it's a neutral base, you can't select it !");
}
// if he selects the base of an other player : nothing is done
else if((this.getPlayer().getName() != realPlayer.getName())){
System.out.println("1st case : it's not your base, you can't select it !");
}
// if he selects one of his base : we add the command selection
else if((this.getPlayer().getName() == realPlayer.getName())) {
SelectBase selectionCommand = new SelectBase(realPlayer, this);
Engine.getInstance().getCommands().add(selectionCommand);
//it sets the first point of Line, which is the coordinate of the first Base, i.e the SelectedBase
AppliWindow.getInstance().getLine().displayFirstPoint(this);
}
}
// 2nd case : current base is already selected by the realPlayer : nothing is done
else if (selectedBases.equals(this)) {
System.out.println("2nd case : Base from : "+realPlayer.getSelectedBases().getName()+" already selected.");
}
// 3rd case : the realPlayer has an other base selected : agents can go from the selected base to current one ! (and we deselect the base)
else {