1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package nl.tudelft.goal.ut2004.visualizer.gui.action;
18
19 import java.awt.event.ActionEvent;
20 import java.awt.event.ActionListener;
21
22 import nl.tudelft.goal.ut2004.visualizer.controller.ServerController;
23
24 import cz.cuni.amis.pogamut.unreal.communication.messages.gbinfomessages.IPlayer;
25 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.ChangeTeam;
26 import cz.cuni.amis.pogamut.ut2004.server.IUT2004Server;
27
28 public class ChangeTeamAction implements ActionListener {
29
30 private final IPlayer player;
31
32 public ChangeTeamAction(IPlayer bot) {
33 this.player = bot;
34 }
35
36 @Override
37 public void actionPerformed(ActionEvent arg0) {
38 ServerController controller = ServerController.getInstance();
39 IUT2004Server server = controller.getServer();
40 assert server != null;
41
42 int team = player.getTeam();
43 if (team != 0 || team != 1) {
44 team = (int) Math.round(Math.random());
45 }
46
47 ChangeTeam change = new ChangeTeam(player.getId(), team);
48 server.getAct().act(change);
49
50 }
51 }