Changeset 182:77dd3fe5a2d4
Legend:
- Unmodified
- Added
- Removed
-
main.py
r181 r182 ˆà 139 139 self.end()ˆà 140 140 return Falseˆà ˆà 141 def snake_len_check(self):ˆà ˆà 142 """Get the snake with maximum length - the winerˆà ˆà 143 ˆà ˆà 144 Return:ˆà ˆà 145 winer - list of snake or snakes with max lengthˆà ˆà 146 length - this maximum length"""ˆà ˆà 147 length=0ˆà ˆà 148 winer = []ˆà ˆà 149 for snake in self.engine.snakes:ˆà ˆà 150 if snake != None:ˆà ˆà 151 if len(snake.cells) > length:ˆà ˆà 152 length = len(snake.cells)ˆà ˆà 153 winer = [snake]ˆà ˆà 154 elif len(snake.cells) == length:ˆà ˆà 155 winer.append(snake) ˆà ˆà 156 return winer, lengthˆà ˆà 157 ˆà 141 158 ˆà 142 159 def restart(self, survived):ˆà òÀæ òÀæ ˆà 165 182 self.engine.redraw()ˆà 166 183 self.canvas.create_text(offset[0]+ field_geometry[0]/2.0, offset[1]+field_geometry[1]/2.0, text="End of the round", fill="white", font="bold")ˆà ˆà 184 winer, length = self.snake_len_check()ˆà ˆà 185 if len(winer) > 1:ˆà ˆà 186 self.canvas.create_text(offset[0]+ field_geometry[0]/2.0, offset[1]+field_geometry[1]*2.0/3.0, text="Number of winers: %s" %(len(winer)), fill="white", font="bold")ˆà ˆà 187 else:ˆà ˆà 188 self.canvas.create_text(offset[0]+ field_geometry[0]/2.0, offset[1]+field_geometry[1]*2.0/3.0, text="Winer: %s" %(winer[0].name), fill="white", font="bold")ˆà ˆà 189 self.canvas.create_text(offset[0]+ field_geometry[0]/2.0, offset[1]+field_geometry[1]*3.0/4.0, text="Total woner length: %s" %(length), fill="white", font="bold")ˆà 167 190 passˆà 168 191 ˆà
Note: See TracChangeset
for help on using the changeset viewer.