comparison pytouhou/game/game.pyx @ 502:3d3285918ba1

Disallow collection of items dropped by the other player in netplay, also fixes a longstanding bug where autocollection worked with those items.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 23 Oct 2013 18:24:08 +0200
parents 3da7395f39e3
children 292fea5c584e
comparison
equal deleted inserted replaced
501:4778c482f24a 502:3d3285918ba1
127 127
128 cdef void unset_player_bomb(self): 128 cdef void unset_player_bomb(self):
129 self.texts[4] = None 129 self.texts[4] = None
130 130
131 131
132 cpdef drop_bonus(self, double x, double y, long _type, end_pos=None): 132 cpdef drop_bonus(self, double x, double y, long _type, end_pos=None, player=None):
133 if _type > 6: 133 if _type > 6:
134 return 134 return
135 if len(self.items) >= self.nb_bullets_max: 135 if len(self.items) >= self.nb_bullets_max:
136 return #TODO: check 136 return #TODO: check
137 item_type = self.item_types[_type] 137 item_type = self.item_types[_type]
138 self.items.append(Item((x, y), _type, item_type, self, end_pos=end_pos)) 138 self.items.append(Item((x, y), _type, item_type, self, end_pos=end_pos,
139 player=player))
139 140
140 141
141 cdef void autocollect(self, Player player): 142 cdef void autocollect(self, Player player):
142 cdef Item item 143 cdef Item item
143 144
163 164
164 cpdef change_bullets_into_star_items(self): 165 cpdef change_bullets_into_star_items(self):
165 cdef Player player 166 cdef Player player
166 cdef Bullet bullet 167 cdef Bullet bullet
167 cdef Laser laser 168 cdef Laser laser
169 cdef Item item
168 170
169 player = min(self.players, key=select_player_key) 171 player = min(self.players, key=select_player_key)
170 item_type = self.item_types[6] 172 item_type = self.item_types[6]
171 self.items.extend([Item((bullet.x, bullet.y), 6, item_type, self, player=player) 173 items = [Item((bullet.x, bullet.y), 6, item_type, self)
172 for bullet in self.bullets]) 174 for bullet in self.bullets]
173 for laser in self.lasers: 175 for laser in self.lasers:
174 self.items.extend([Item(pos, 6, item_type, self, player=player) 176 items.extend([Item(pos, 6, item_type, self)
175 for pos in laser.get_bullets_pos()]) 177 for pos in laser.get_bullets_pos()])
176 laser.cancel() 178 laser.cancel()
179 for item in items:
180 item.autocollect(player)
181 self.items.extend(items)
177 self.bullets = [] 182 self.bullets = []
178 183
179 184
180 cpdef change_bullets_into_bonus(self): 185 cpdef change_bullets_into_bonus(self):
181 cdef Player player 186 cdef Player player