Show
Ignore:
Timestamp:
05/04/08 01:19:02 (7 months ago)
Author:
bct
Message:

couple of quick bugfixes

Location:
branches/session_centric/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/session_centric/src/session.py

    r9567 r9568  
    2424                stanza_session.EncryptedStanzaSession.acknowledge_termination(self) 
    2525 
    26                 self.control.session = None 
     26                if self.control: 
     27                        self.control.session = None 
    2728 
    2829        # remove events associated with this session from the queue 
  • branches/session_centric/src/tictactoe.py

    r9566 r9568  
    254254                self.setup_window() 
    255255 
     256        # check if the last move (at row r and column c) won the game 
    256257        def check_for_strike(self, p, r, c, strike): 
    257258                # number in a row: up and down, left and right 
     
    269270 
    270271                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 
    271275                        # vertical check 
    272                         try: 
     276                        if r_in_range: 
    273277                                tallyI = tallyI + 1 
    274278                                if self.board[r+d][c] != p: 
    275279                                        tallyI = 0 
    276                         except IndexError: 
    277                                 pass 
    278280 
    279281                        # horizontal check 
    280                         try: 
     282                        if c_in_range: 
    281283                                tally_ = tally_ + 1 
    282284                                if self.board[r][c+d] != p: 
    283285                                        tally_ = 0 
    284                         except IndexError: 
    285                                 pass 
    286286 
    287287                        # diagonal checks 
    288                         try: 
     288                        if r_in_range and c_in_range: 
    289289                                tallyL = tallyL + 1 
    290290                                if self.board[r+d][c+d] != p: 
    291291                                        tallyL = 0 
    292                         except IndexError: 
    293                                 pass 
    294  
    295                         try: 
     292 
     293                        if r_in_range and 0 <= c-d < self.cols: 
    296294                                tallyF = tallyF + 1 
    297295                                if self.board[r+d][c-d] != p: 
    298296                                        tallyF = 0 
    299                         except IndexError: 
    300                                 pass 
    301297 
    302298                        if any([t == strike for t in (tallyL, tallyF, tallyI, tally_)]):