View Javadoc

1   package cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages;
2    		
3    		// --- IMPORTS FROM /messages/settings/javasettings/javaimport BEGIN
4   			import java.util.*;import javax.vecmath.*;import cz.cuni.amis.pogamut.base.communication.messages.*;import cz.cuni.amis.pogamut.base.communication.worldview.*;import cz.cuni.amis.pogamut.base.communication.worldview.event.*;import cz.cuni.amis.pogamut.base.communication.worldview.object.*;import cz.cuni.amis.pogamut.multi.communication.worldview.object.*;import cz.cuni.amis.pogamut.base.communication.translator.event.*;import cz.cuni.amis.pogamut.multi.communication.translator.event.*;import cz.cuni.amis.pogamut.base3d.worldview.object.*;import cz.cuni.amis.pogamut.base3d.worldview.object.event.*;import cz.cuni.amis.pogamut.ut2004.communication.messages.*;import cz.cuni.amis.pogamut.ut2004.communication.worldview.objects.*;import cz.cuni.amis.pogamut.ut2004multi.communication.worldview.objects.*;import cz.cuni.amis.pogamut.ut2004.communication.translator.itemdescriptor.*;import cz.cuni.amis.pogamut.ut2004.communication.messages.ItemType.Category;import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;import cz.cuni.amis.utils.exception.*;import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result;import cz.cuni.amis.utils.SafeEquals;import cz.cuni.amis.pogamut.base.agent.*;import cz.cuni.amis.pogamut.multi.agent.*;import cz.cuni.amis.pogamut.multi.communication.worldview.property.*;import cz.cuni.amis.pogamut.ut2004multi.communication.worldview.property.*;import cz.cuni.amis.utils.token.*;import cz.cuni.amis.utils.*;
5   		// --- IMPORTS FROM /messages/settings/javasettings/javaimport END
6   		
7   		
8   		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name='all'] BEGIN
9   				
10  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name='all'] END
11  		
12  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=event]+classtype[@name=impl] BEGIN
13  		
14  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=event]+classtype[@name=impl] END
15      
16   		/**
17           *  
18           			Definition of the event PLS.
19           		
20           *
21           *  <p></p><p></p>
22           *  Complete message documentation:               
23           *  
24  		Synchronous message. Contains the info about player score.
25  	
26           */
27   	public class PlayerScore 
28    				extends InfoMessage
29      			implements IWorldEvent, IWorldChangeEvent
30      			
31  	    {
32   	
33      	/** Example how the message looks like - used during parser tests. */
34      	public static final String PROTOTYPE =
35      		"PLS {Id unreal_id}  {Score 0}  {Deaths 0} ";
36      
37      	
38      	
39      	/**
40      	 * Parameter-less contructor for the message.
41      	 */
42  		public PlayerScore()
43  		{
44  		}
45  	
46      	
47      	
48      	
49      	/**
50  		 * Creates new instance of the message PlayerScore.
51  		 * 
52  		Synchronous message. Contains the info about player score.
53  	
54  		 * Corresponding GameBots message
55  		 *   
56  		 *   is
57  		 *   PLS.
58  		 * 
59   	  	 * 
60  		 *   
61  		 *     @param lastSeenTime 
62  			When was the last time we've received info about this
63  			object.
64  		
65  		 *   
66  		 * 
67  		 *   
68  		 *     @param Id Unique Id of the player.
69  		 *   
70  		 * 
71  		 *   
72  		 *     @param Score 
73  			Number of player frags (how many times the player killed
74  			other players) or number of victory points (player frags +
75  			some special measurement that can differ from game type to
76  			game type).
77  		
78  		 *   
79  		 * 
80  		 *   
81  		 *     @param Deaths Number of players deaths.
82  		 *   
83  		 * 
84  		 */
85  		public PlayerScore(
86  			double lastSeenTime,  UnrealId Id,  int Score,  int Deaths
87  		) {
88  			
89  					this.lastSeenTime = lastSeenTime;
90  				
91  					this.Id = Id;
92  				
93  					this.Score = Score;
94  				
95  					this.Deaths = Deaths;
96  				
97  		}
98      
99      	/**
100 		 * Cloning constructor from the full message.
101 		 *
102 		 * @param original
103 		 */
104 		public PlayerScore(PlayerScore original) {		
105 			
106 					this.lastSeenTime = original.getLastSeenTime()
107  	;
108 				
109 					this.Id = original.getId()
110  	;
111 				
112 					this.Score = original.getScore()
113  	;
114 				
115 					this.Deaths = original.getDeaths()
116  	;
117 				
118 			this.SimTime = original.getSimTime();			
119 		}
120 		
121 	   		
122 			protected long SimTime;
123 				
124 			/**
125 			 * Simulation time in MILLI SECONDS !!!
126 			 */	
127 			@Override
128 			public long getSimTime() {
129 				return SimTime;
130 			}
131 						
132 			/**
133 			 * Used by Yylex to slip correct time of the object or programmatically.
134 			 */
135 			protected void setSimTime(long SimTime) {
136 				this.SimTime = SimTime;
137 			}
138 	   	
139     	
140 	    /**
141          * 
142 			When was the last time we've received info about this
143 			object.
144 		 
145          */
146         protected
147          double lastSeenTime =
148        	0;
149 	
150  		/**
151          * 
152 			When was the last time we've received info about this
153 			object.
154 		 
155          */
156         public  double getLastSeenTime()
157  	 {
158     					return lastSeenTime;
159     				}
160     			
161     	
162 	    /**
163          * Unique Id of the player. 
164          */
165         protected
166          UnrealId Id =
167        	null;
168 	
169  		/**
170          * Unique Id of the player. 
171          */
172         public  UnrealId getId()
173  	 {
174     					return Id;
175     				}
176     			
177     	
178 	    /**
179          * 
180 			Number of player frags (how many times the player killed
181 			other players) or number of victory points (player frags +
182 			some special measurement that can differ from game type to
183 			game type).
184 		 
185          */
186         protected
187          int Score =
188        	0;
189 	
190  		/**
191          * 
192 			Number of player frags (how many times the player killed
193 			other players) or number of victory points (player frags +
194 			some special measurement that can differ from game type to
195 			game type).
196 		 
197          */
198         public  int getScore()
199  	 {
200     					return Score;
201     				}
202     			
203     	
204 	    /**
205          * Number of players deaths. 
206          */
207         protected
208          int Deaths =
209        	0;
210 	
211  		/**
212          * Number of players deaths. 
213          */
214         public  int getDeaths()
215  	 {
216     					return Deaths;
217     				}
218     			
219  		
220  	    public String toString() {
221             return
222             	super.toString() + "[" +
223             	
224 		              			"Id = " + String.valueOf(getId()
225  	) + " | " + 
226 		              		
227 		              			"Score = " + String.valueOf(getScore()
228  	) + " | " + 
229 		              		
230 		              			"Deaths = " + String.valueOf(getDeaths()
231  	) + " | " + 
232 		              		
233 				"]";           		
234         }
235  	
236  		
237  		public String toHtmlString() {
238  			return super.toString() + "[<br/>" +
239             	
240 		              			"<b>Id</b> = " + String.valueOf(getId()
241  	) + " <br/> " + 
242 		              		
243 		              			"<b>Score</b> = " + String.valueOf(getScore()
244  	) + " <br/> " + 
245 		              		
246 		              			"<b>Deaths</b> = " + String.valueOf(getDeaths()
247  	) + " <br/> " + 
248 		              		
249 				"<br/>]";     
250 		}
251  	 
252  	    public String toJsonLiteral() {
253             return "PlayerScore(null, "
254             		
255                    + ")";
256         }
257  	
258  		
259  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
260         	
261 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
262 		
263 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=event+classtype[@name=impl]) ---
264 	        
265 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=event+classtype[@name=impl]) ---        	            	
266  	
267 		}
268