X-Git-Url: https://harishankar.org/repos/?p=getaclue.git;a=blobdiff_plain;f=crosswordpuzzle.py;fp=crosswordpuzzle.py;h=fb9ada55dad410a3e0182d3f076be0db8d6b8cc4;hp=c1f822b3ed8a121c7af46d456626225f9de18471;hb=cd153df772f936f9aaed0f75d83f15c05a6ee9b6;hpb=85159420b6ed652a259484b3cf192f602d9418c0 diff --git a/crosswordpuzzle.py b/crosswordpuzzle.py index c1f822b..fb9ada5 100644 --- a/crosswordpuzzle.py +++ b/crosswordpuzzle.py @@ -156,40 +156,6 @@ class CrosswordPuzzle: self.data[row][col+i].char = word[i].upper () self.data[row][col+i].occupied_across = True - # display the grid with words - def print_grid (self, no_words=False): - # get row, col and print them (with grid number if set) - for col in range (self.cols): - # print the first row as column headers - print self.BLUE + ' ' + str (col) + self.ENDCOL, - print - - for row in range (self.rows): - for col in range (self.cols): - # print the data - # if the cell is numbered i.e. start of a word - if self.data[row][col].numbered != 0: - print self.BRICKRED + str(self.data[row][col].numbered) + self.ENDCOL, - # print a space - else: - print ' ', - # if the character is not a blank or a block - if self.data[row][col].char <> "." and self.data[row][col].char <> "#": - # if words are to be shown regardless of hidden/revealed state - if no_words is False: - print self.BOLD + self.data[row][col].char + self.ENDCOL, - else: - # display only revealed - if self.data[row][col].revealed is True: - print self.BOLD + self.data[row][col].char + self.ENDCOL, - # else print a block - else: - print self.GREY + '.' + self.ENDCOL, - else: - print self.GREY + self.data[row][col].char + self.ENDCOL, - - print ' ' + self.BLUE + str(row) + self.ENDCOL - # freeze the grid numbers etc. def freeze_grid (self): # numbering @@ -208,3 +174,13 @@ class CrosswordPuzzle: self.frozen_grid = True + # unfreeze the grid numbers etc. + def unfreeze_grid (self): + # run through the grid + for row in range (self.rows): + for col in range (self.cols): + self.data[row][col].numbered = 0 + if (self.data[row][col].occupied_across is False and + self.data[row][col].occupied_down is False): + self.data[row][col].char = '.' +