View Javadoc

1   package cz.cuni.amis.pogamut.udk.communication.translator.bot.state;
2   
3   import cz.cuni.amis.fsm.FSMState;
4   import cz.cuni.amis.fsm.FSMTransition;
5   import cz.cuni.amis.fsm.IFSMState;
6   import cz.cuni.amis.pogamut.base.communication.messages.InfoMessage;
7   import cz.cuni.amis.pogamut.udk.communication.messages.gbinfomessages.Player;
8   import cz.cuni.amis.pogamut.udk.communication.messages.gbinfomessages.PlayerListEnd;
9   import cz.cuni.amis.pogamut.udk.communication.messages.gbinfomessages.PlayerListStart;
10  import cz.cuni.amis.pogamut.udk.communication.translator.TranslatorContext;
11  import cz.cuni.amis.pogamut.udk.communication.translator.bot.support.BotListState;
12  import cz.cuni.amis.pogamut.udk.communication.translator.shared.events.InitCommandRequest;
13  import cz.cuni.amis.pogamut.udk.communication.translator.shared.events.PlayerListObtained;
14  
15  /**
16   * Takes care of the player list. It stores them inside a List object and when END message comes it sends
17   * them to the world view via PlayerListObtained event.
18   * <p><p>
19   * Last state of the handshake - we switch from this state to the ConfigureMessageExpectedState. 
20   * 
21   * @author Jimmy
22   */
23  @FSMState(map={@FSMTransition(
24  					state=HandshakeControllerState.class, 
25  					symbol={PlayerListEnd.class},
26  					transition={})}
27  )
28  public class PlayerListState extends BotListState<Player, TranslatorContext> {
29  
30  	public PlayerListState() {
31  		super(PlayerListStart.class, Player.class, PlayerListEnd.class);
32  	}
33  	
34  	@Override
35  	public void stateLeaving(TranslatorContext context,
36  			IFSMState<InfoMessage, TranslatorContext> toState, InfoMessage symbol) {
37  		super.stateLeaving(context, toState, symbol);
38  		context.getEventQueue().pushEvent(new PlayerListObtained(getList()));
39  		newList();
40  	}
41  	
42  	@Override
43  	public void stateSymbol(TranslatorContext context, InfoMessage symbol) {
44  		super.stateSymbol(context, symbol);
45  		context.getEventQueue().pushEvent((Player)symbol);
46  	}
47  
48  }