1 package cz.cuni.amis.pogamut.ut2004.tag.bot;
2
3 import cz.cuni.amis.pogamut.base.communication.worldview.IWorldView;
4 import cz.cuni.amis.pogamut.base.communication.worldview.event.IWorldEventListener;
5 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.ControlMessage;
6 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.PlayerJoinsGame;
7 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.PlayerLeft;
8 import cz.cuni.amis.pogamut.ut2004.tag.protocol.TagMessagesTranslator;
9 import cz.cuni.amis.pogamut.ut2004.tag.protocol.messages.TagGameEnd;
10 import cz.cuni.amis.pogamut.ut2004.tag.protocol.messages.TagGameRunning;
11 import cz.cuni.amis.pogamut.ut2004.tag.protocol.messages.TagGameStart;
12 import cz.cuni.amis.pogamut.ut2004.tag.protocol.messages.TagMessage;
13 import cz.cuni.amis.pogamut.ut2004.tag.protocol.messages.TagPassed;
14 import cz.cuni.amis.pogamut.ut2004.tag.protocol.messages.TagPlayerImmunity;
15 import cz.cuni.amis.pogamut.ut2004.tag.protocol.messages.TagPlayerScoreChanged;
16 import cz.cuni.amis.pogamut.ut2004.tag.protocol.messages.TagPlayerStatusChanged;
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 public class TagEvents {
32
33 protected boolean enabled = false;
34
35 protected IWorldView worldView;
36
37 protected IWorldEventListener<TagGameStart> tagGameStartListener = new IWorldEventListener<TagGameStart>() {
38
39 @Override
40 public void notify(TagGameStart event) {
41 tagGameStart(event);
42 }
43
44 };
45
46 protected IWorldEventListener<TagGameRunning> tagGameRunningListener = new IWorldEventListener<TagGameRunning>() {
47
48 @Override
49 public void notify(TagGameRunning event) {
50 tagGameRunning(event);
51 }
52
53 };
54
55 protected IWorldEventListener<TagGameEnd> tagGameEndListener = new IWorldEventListener<TagGameEnd>() {
56
57 @Override
58 public void notify(TagGameEnd event) {
59 tagGameEnd(event);
60 }
61
62 };
63
64 protected IWorldEventListener<TagPlayerImmunity> tagPlayerImmunityListener = new IWorldEventListener<TagPlayerImmunity>() {
65
66 @Override
67 public void notify(TagPlayerImmunity event) {
68 tagPlayerImmunity(event);
69 }
70
71 };
72
73 protected IWorldEventListener<TagPlayerScoreChanged> tagPlayerScoreChangedListener = new IWorldEventListener<TagPlayerScoreChanged>() {
74
75 @Override
76 public void notify(TagPlayerScoreChanged event) {
77 tagPlayerScoreChanged(event);
78 }
79
80 };
81
82 protected IWorldEventListener<TagPlayerStatusChanged> tagPlayerStatusChangedListener = new IWorldEventListener<TagPlayerStatusChanged>() {
83
84 @Override
85 public void notify(TagPlayerStatusChanged event) {
86 tagPlayerStatusChanged(event);
87 }
88
89 };
90
91 protected IWorldEventListener<TagPassed> tagPassedListener = new IWorldEventListener<TagPassed>() {
92
93 @Override
94 public void notify(TagPassed event) {
95 tagPassed(event);
96 }
97
98 };
99
100 public TagEvents(IWorldView worldView) {
101 this.worldView = worldView;
102 }
103
104 public void enableTagEvents() {
105 if (enabled) return;
106 enabled = true;
107
108 worldView.addEventListener(TagGameStart.class, tagGameStartListener);
109 worldView.addEventListener(TagGameRunning.class, tagGameRunningListener);
110 worldView.addEventListener(TagGameEnd.class, tagGameEndListener);
111 worldView.addEventListener(TagPassed.class, tagPassedListener);
112 worldView.addEventListener(TagPlayerImmunity.class, tagPlayerImmunityListener);
113 worldView.addEventListener(TagPlayerScoreChanged.class, tagPlayerScoreChangedListener);
114 worldView.addEventListener(TagPlayerStatusChanged.class, tagPlayerStatusChangedListener);
115 }
116
117 public void disableTagEvents() {
118 if (!enabled) return;
119 enabled = false;
120
121 worldView.removeEventListener(TagGameStart.class, tagGameStartListener);
122 worldView.removeEventListener(TagGameRunning.class, tagGameRunningListener);
123 worldView.removeEventListener(TagGameEnd.class, tagGameEndListener);
124 worldView.removeEventListener(TagPassed.class, tagPassedListener);
125 worldView.removeEventListener(TagPlayerImmunity.class, tagPlayerImmunityListener);
126 worldView.removeEventListener(TagPlayerScoreChanged.class, tagPlayerScoreChangedListener);
127 worldView.removeEventListener(TagPlayerStatusChanged.class, tagPlayerStatusChangedListener);
128 }
129
130
131
132
133
134 public void tagGameStart(TagGameStart event) {
135 }
136
137 public void tagGameRunning(TagGameRunning event) {
138 }
139
140 public void tagGameEnd(TagGameEnd event) {
141 }
142
143 public void tagPassed(TagPassed event) {
144 }
145
146 public void tagPlayerImmunity(TagPlayerImmunity event) {
147 }
148
149 public void tagPlayerScoreChanged(TagPlayerScoreChanged event) {
150 }
151
152 public void tagPlayerStatusChanged(TagPlayerStatusChanged event) {
153 }
154
155 }