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=base]+classtype[@name=abstract] BEGIN
13  		
14  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=base]+classtype[@name=abstract] END
15      
16   		/**
17           *  
18              				Abstract definition of the GameBots2004 message TES.  
19              			
20           *
21           *  <p></p><p></p>
22           *  Complete message documentation:               
23           *  
24  		Synchronous message. Contains the info about team score.
25  	
26           */
27   	public abstract class TeamScore   
28    				extends 
29    				InfoMessage
30    						implements IWorldEvent, IWorldChangeEvent, ICompositeWorldObject
31    						
32  	    {
33   	
34      	/** Example how the message looks like - used during parser tests. */
35      	public static final String PROTOTYPE =
36      		"TES {Id unreal_id}  {Team 0}  {Score 0} ";
37      
38      	
39      	
40      	/**
41      	 * Parameter-less contructor for the message.
42      	 */
43  		public TeamScore()
44  		{
45  		}
46  	
47  				// abstract message, it does not have any more constructors				
48  			
49  	   		
50  			protected long SimTime;
51  				
52  			/**
53  			 * Simulation time in MILLI SECONDS !!!
54  			 */	
55  			@Override
56  			public long getSimTime() {
57  				return SimTime;
58  			}
59  						
60  			/**
61  			 * Used by Yylex to slip correct time of the object or programmatically.
62  			 */
63  			protected void setSimTime(long SimTime) {
64  				this.SimTime = SimTime;
65  			}
66  	   	
67   		/**
68           * Message identifier. 
69           */
70          public abstract UnrealId getId()
71   	;
72  		    			
73   		/**
74           * Team identifier. 
75           */
76          public abstract Integer getTeam()
77   	;
78  		    			
79   		/**
80           * 
81  			The score of the team (can be some special measurement that
82  			differs from game type to game type - number of stolen flags
83  			in CTF game, number of team frags in TeamGame, etc.)
84  		 
85           */
86          public abstract Integer getScore()
87   	;
88  		    			
89      	
90      	public static class TeamScoreUpdate
91       extends GBObjectUpdate implements ICompositeWorldObjectUpdatedEvent, IGBWorldObjectEvent {	
92  			private TeamScore object;
93  			private long time;
94  			private ITeamId teamId;
95  			
96  			public TeamScoreUpdate
97      (TeamScore source, long eventTime, ITeamId teamId) {
98  				this.object = source;
99  				this.time = eventTime;
100 				this.teamId = teamId;
101 			}
102 			
103 			/**
104 			 * Simulation time in MILLI SECONDS !!!
105 			 */ 
106 			@Override
107 			public long getSimTime() {
108 				return time;
109 			}
110 	
111 			@Override
112 			public IWorldObject getObject() {
113 				return object;
114 			}
115 	
116 			@Override
117 			public WorldObjectId getId() {
118 				return object.getId();
119 			}
120 	
121 			@Override
122 			public ILocalWorldObjectUpdatedEvent getLocalEvent() {
123 				return new TeamScoreLocalImpl.TeamScoreLocalUpdate
124     ((TeamScoreLocal)object.getLocal(), time);
125 			}
126 	
127 			@Override
128 			public ISharedWorldObjectUpdatedEvent getSharedEvent() {
129 				return new TeamScoreSharedImpl.TeamScoreSharedUpdate
130     ((TeamScoreShared)object.getShared(), time, teamId);
131 			}
132 	
133 			@Override
134 			public IStaticWorldObjectUpdatedEvent getStaticEvent() {
135 				return new TeamScoreStaticImpl.TeamScoreStaticUpdate
136     ((TeamScoreStatic)object.getStatic(), time);
137 			}
138 			
139 		}
140     
141  		
142  	    public String toString() {
143             return
144             	super.toString() + "[" +
145             	
146 		              			"Id = " + String.valueOf(getId()
147  	) + " | " + 
148 		              		
149 		              			"Team = " + String.valueOf(getTeam()
150  	) + " | " + 
151 		              		
152 		              			"Score = " + String.valueOf(getScore()
153  	) + " | " + 
154 		              		
155 				"]";           		
156         }
157  	
158  		
159  		public String toHtmlString() {
160  			return super.toString() + "[<br/>" +
161             	
162 		              			"<b>Id</b> = " + String.valueOf(getId()
163  	) + " <br/> " + 
164 		              		
165 		              			"<b>Team</b> = " + String.valueOf(getTeam()
166  	) + " <br/> " + 
167 		              		
168 		              			"<b>Score</b> = " + String.valueOf(getScore()
169  	) + " <br/> " + 
170 		              		
171 				"<br/>]";     
172 		}
173  	 
174  	    public String toJsonLiteral() {
175             return "TeamScore(null, "
176             		
177                    + ")";
178         }
179  	
180  		
181  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
182         	
183 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
184 		
185 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=base+classtype[@name=abstract]) ---
186 	        
187 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=base+classtype[@name=abstract]) ---        	            	
188  	
189 		}
190