示例#1
0
文件: words.py 项目: Voder/PBE
    def display(self):
        print(nl*5)

        for n, word in enumerate1(self.words):
            print(lettertpl % n, space, word, nl)
            lnumbers = sjoin(range1(len(word)), space * word.spacing(), lettertpl)
            print(space*4, lnumbers, nl*2)

        print(self.stattpl % (self.random_reveals, self.guesses), nl)
示例#2
0
    def draw(self):
        print(nl*5)
        def ljoin(L): return sjoin(L, space, tiletpl)

        print( space*4, ljoin((1,2,3)), space, ljoin((4,5,6)), space, ljoin((7,8,9)), nl )

        for n, row in enumerate1(self.board):
            print(tiletpl % n, space,
                  ljoin(row[:3]), space, ljoin(row[3:6]), space, ljoin(row[6:9]),
                  nl)
            if n in (3,6): print()
示例#3
0
    def get_move(self, valid_moves):
        """Get player's choice of move."""
        moves = [space] * (length + 6)
        for n, (loc, _) in enumerate1(valid_moves):
            moves[loc] = n
        print(sjoin(moves))

        while True:
            try:
                return valid_moves[ self.textinput.getval() ]
            except IndexError:
                print(self.textinput.invalid_move)
示例#4
0
    def get_move(self, valid_moves):
        """Get player's choice of move."""
        moves = [space] * (length + 6)
        for n, (loc, _) in enumerate1(valid_moves):
            moves[loc] = n
        print(sjoin(moves))

        while True:
            val = self.term.getch()
            if val=='q':
                sys.exit()
            try:
                return valid_moves[int(val)-1]
            except (ValueError, IndexError):
                print("Invalid move")
示例#5
0
    def draw(self):
        print(nl*5)
        def ljoin(L):
            return sjoin(L, space, tiletpl)

        for n, row in enumerate1(self.board):
            print(space,
                  ljoin(row[:3]),
                  space,
                  ljoin(row[3:6]),
                  space,
                  ljoin(row[6:9]),
                  nl)
            if n in (3,6):
                print()
示例#6
0
    def draw(self, pause=None):
        pause = pause or self.pause_time
        print(nl * self.screen_sep)

        if self.num_grid:
            print(space, space*(self.xpad + 1), ujoin( range1(self.width), space, self.tiletpl ), nl * self.ypad)

        for n, row in enumerate1(self.board):
            args = [self.tiletpl % n] if self.num_grid else []
            if self.stackable:
                row = (tile[-1] for tile in row)
            args = [space] + args + [ujoin(row, space, self.tiletpl), nl * self.ypad]
            print(*args)

        self.status()
        sleep(pause)
示例#7
0
    def play(self):
        print(nl * 2)
        for section_num, section in enumerate1(self.sections):

            if re.match(cmdpat, section):
                section = section.split()
                cmd, arg = section[0], getitem(section, 1)

                if cmd == ":pause": self.pause(arg, section_num)
                elif cmd == ":clear": print(nl * screensep)
                elif cmd == ":type": self.typeblock = True

            else:
                self.display(section.lstrip(nl))

        print(nl * 2, "----- END -----", nl * 2)
示例#8
0
文件: tmovies.py 项目: Voder/PBE
    def play(self):
        print(nl * 2)
        for section_num, section in enumerate1(self.sections):

            if re.match(cmdpat, section):
                section  = section.split()
                cmd, arg = section[0], getitem(section, 1)

                if   cmd == ":pause" : self.pause(arg, section_num)
                elif cmd == ":clear" : print(nl * screensep)
                elif cmd == ":type"  : self.typeblock = True

            else:
                self.display(section.lstrip(nl))

        print(nl*2, "----- END -----", nl*2)
示例#9
0
文件: board.py 项目: saisai/pyquest
    def draw(self, pause=None):
        pause = pause or self.pause_time
        print(nl * self.screen_sep)

        if self.num_grid:
            print(space, space * (self.xpad + 1),
                  ujoin(range1(self.width), space, self.tiletpl),
                  nl * self.ypad)

        for n, row in enumerate1(self.board):
            args = [self.tiletpl % n] if self.num_grid else []
            if self.stackable:
                row = (tile[-1] for tile in row)
            args = [space] + args + [
                ujoin(row, space, self.tiletpl), nl * self.ypad
            ]
            print(*args)

        self.status()
        sleep(pause)
示例#10
0
 def draw(self):
     print( ujoin((n+1 for n in range(self.maxx), tpl=tiletpl)), nl )
     for n, row in enumerate1(self.board):
         print( str(n), ujoin(row, tpl=tiletpl), nl)