コード例 #1
0
ファイル: playcube.py プロジェクト: drumsen/pycube
    def feedCube(self, moveList, printall):
        """ gets a list with steps and calls move to execute them """
        whitecross = ["z", "z"]
        moveList = whitecross + moveList
        for step in moveList:
            if step in {"x", "x'", "y", "y'", "z", "z'"}:
                rotmove = opscube.rotMoves(step)
                for move in rotmove:
                    self.cube.move(move)
                continue

            if step[0].islower():
                if step[-1] == "2":
                    doublemove = opscube.doubleMoves(step[0]) * 2
                else:
                    doublemove = opscube.doubleMoves(step)
                for move in doublemove:
                    self.cube.move(move)
                continue

            if step[-1] == "2":
                self.cube.move(step[0])
                self.cube.move(step[0])
                continue

            if step[-1] == "'":
                self.cube.move(step[0].upper())
                continue

            else:
                self.cube.move(step.lower())
        if printall:
            print(self.cube)
        else:
            print(self.cube.toplayerprint())
コード例 #2
0
ファイル: playcube.py プロジェクト: drumsen/pycube
 def interactive(self):
     while True:
         c = getch()  # commands:
         if c == "p":  # p = scrambles the cube
             self.feedCube(scramble.scramble())
         if c == "q":  # q = exit cubemode
             return -1
         if c == "n":  # n = loads new cube(solved)
             self.cube = loadCube()
             print(self.cube)
         if c.lower() in {"u", "f", "l", "r", "b", "d", "m", "e", "s"}:  # moves the slice (shift inverts move)
             self.cube.move(c)
             print(self.cube)
         if c.lower() in {"x", "y", "z"}:
             for turn in opscube.rotMoves(c):
                 self.cube.move(turn)
             print(self.cube)
         if c == "1":
             doublemove = opscube.doubleMoves("d")
             for move in doublemove:
                 self.cube.move(move)
             print(self.cube)