Changeset 9568
- Timestamp:
- 05/04/08 01:19:02 (4 months ago)
- Location:
- branches/session_centric/src
- Files:
-
- 2 modified
-
session.py (modified) (1 diff)
-
tictactoe.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/session_centric/src/session.py
r9567 r9568 24 24 stanza_session.EncryptedStanzaSession.acknowledge_termination(self) 25 25 26 self.control.session = None 26 if self.control: 27 self.control.session = None 27 28 28 29 # remove events associated with this session from the queue -
branches/session_centric/src/tictactoe.py
r9566 r9568 254 254 self.setup_window() 255 255 256 # check if the last move (at row r and column c) won the game 256 257 def check_for_strike(self, p, r, c, strike): 257 258 # number in a row: up and down, left and right … … 269 270 270 271 for d in xrange(-strike, strike): 272 r_in_range = 0 <= r+d < self.rows 273 c_in_range = 0 <= c+d < self.cols 274 271 275 # vertical check 272 try:276 if r_in_range: 273 277 tallyI = tallyI + 1 274 278 if self.board[r+d][c] != p: 275 279 tallyI = 0 276 except IndexError:277 pass278 280 279 281 # horizontal check 280 try:282 if c_in_range: 281 283 tally_ = tally_ + 1 282 284 if self.board[r][c+d] != p: 283 285 tally_ = 0 284 except IndexError:285 pass286 286 287 287 # diagonal checks 288 try:288 if r_in_range and c_in_range: 289 289 tallyL = tallyL + 1 290 290 if self.board[r+d][c+d] != p: 291 291 tallyL = 0 292 except IndexError: 293 pass 294 295 try: 292 293 if r_in_range and 0 <= c-d < self.cols: 296 294 tallyF = tallyF + 1 297 295 if self.board[r+d][c-d] != p: 298 296 tallyF = 0 299 except IndexError:300 pass301 297 302 298 if any([t == strike for t in (tallyL, tallyF, tallyI, tally_)]):
