1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 """
18 This module give a snapshot of a BZoo World
19
20 """
22
24 """
25 @return: N/A
26 @rtype: bzClient
27 """
28
29
30 self.playerspseudos = []
31 self.playerspositions = []
32 self.playersorientations = []
33 self.playersactions = []
34 self.playersscenes = []
35
36
37 self.playersmessages = []
38
39
40
41
43 """
44 Gives the number of clients connected to the serveur.
45 @return: The number of people connected to the server
46 @rtype: Integer
47 """
48 return (len(self.pseudos))
49
51 """
52 Gives the list of currently connected players
53 @return: the list of connected players'pseudos
54 @rtype: list of String
55 """
56 return (self.playerspseudos)
57
59 """
60 Gives the Id of the player which pseudo is name
61 @param name: The pseudo of the player.
62 @type name: String
63 @return: the Id of the player.
64 @rtype: Integer
65 """
66 return (self.pseudos.index(name))
67
69 """
70 Gives the pseudo of the player which id is Id
71 @param Id: The id of the player.
72 @type Id: Integer
73 @return: the pseudo of the player.
74 @rtype: String
75 """
76 return (self.pseudos[Id])
77
79 """
80 Gives the rotation matrix of the player which Id is Id
81 @param Id: The id of the player.
82 @type Id: Integer
83 @return: the orientation matrix of the player.
84 @rtype: 3*3 Matrix
85 """
86 return (self.orientations[Id])
87
89 """
90 Gives the position vector of the player which id is Id
91 @param Id: The id of the player.
92 @type Id: Integer
93 @return: the position of the player [PosX, PosY, PosY].
94 @rtype: 3*1 Vector
95 """
96 return (self.positions[Id])
97
99 """
100 Gives the action the player is currently performing
101 @param Id: The id of the player.
102 @type Id: Integer
103 @return: the action played by the player.
104 @rtype: Integer
105 """
106 return (self.actions[Id])
107
109 """
110 Gives the scene the player is in.
111 @param Id: The id of the player.
112 @type Id: Integer
113 @return: the scene number the player is in.
114 @rtype: Integer
115 """
116 return (self.actions[Id])
117
119 """
120 Gives a list of player's rotation matrix.
121 @return: the list of players rotation matrix.
122 @rtype: list of 3*3 Matrix.
123 """
124 return (self.playersorientations)
125
127 """
128 Gives a list of player's position vector.
129 @return: the list of players position vector [posX, posY, posY].
130 @rtype: list of 3*1 Vector.
131 """
132 return (self.playerpositions)
133
135 """
136 Gives a list of player's action.
137 @return: the list of players action.
138 @rtype: list of Integer.
139 """
140 return (self.playeractions)
141
143 """
144 Gives a list of player's scene.
145 @return: the list of players scene.
146 @rtype: list of Integer.
147 """
148 return (self.playersscenes)
149
150
151 - def popTextMessage(self,):
152 """
153 Gives the next received text message and remove it from pending message
154 @return: the next message (sender_pseudo , message).
155 @rtype: tuple {String, String} or None
156 """
157 return (self.playersmessages.pop(0))
158
159
161 """
162 Updates picture information from a message list.
163 @param msgList: The list of recently received message .
164 @type msgList: dictionnary
165 """
166 for mess in msg_list.keys():
167
168
169
170 if mess == "1":
171 self.pseudos, self.positions, self.orientations, self.actions = msg_list["1"]
172 self.id = self.pseudos.index(self.pseudo)
173
174 elif mess == "3":
175 ids, messages = msg_list["3"]
176 for idx_client in range (len(ids)):
177
178 self.display.QueueMessage( messages[idx_client], self.pseudos[ids[idx_client]])
179
180 elif mess == "0":
181
182 self.playerspositions[idClient] = msglist[mess][0]
183 self.playersorientations[idClient] = msglist[mess][1]
184 self.playersactions[idClient] = msglist[mess][2]
185
186 elif mess == "2" :
187
188 pass
189
190 else:
191 print "Unkown message type %s "%mess
192
193
194
195 if __name__ == "__main__":
196 print "bzPicture"
197
198 aPicture = bzPicture()
199
200
201
202 del aPicture
203