Example #1
0
 def setPlayerLabel(self):
     """
     Setup label to represent communicate info about and to active player
     """
     self.playerVar = Tkinter.StringVar()
     self.playerVar.set("Player %s has %d moves left"%(self.playerColor.title(), self.turnNumber))
     Tkinter.Label(self.frame, textvariable=self.playerVar).grid(row=2)
     self.playerOptions = utils.redOptions() if self.playerColor == 'red' else utils.blueOptions()
     self.playerOptions = [x.title() for x in self.playerOptions]
     self.playerOptions.insert(0, "Choose Move")
     self.var = Tkinter.StringVar()
     self.var.set(self.playerOptions[0])
     drop = Tkinter.OptionMenu(self.frame, self.var, *self.playerOptions, command=self.optionCallback)
     drop.grid(row=3)
Example #2
0
        """
        Start a new game in terminal/commandline mode
        """
        print "\nChoose a Player Color."
        playerColor = raw_input("Red or Blue? ").lower()
        try:
            self.newPlayerCtrl(playerColor)
        except utils.ServerException, e:
            print e
            self.newRawGame()
        turnNum = 4
        while turnNum != 0:
            nextMoveMsg= "\nPlayer %s you have %d moves left.\n" \
                  "Pick your next move."
            print nextMoveMsg%(playerColor.title(), turnNum)
            playerOptions = utils.redOptions() if playerColor == 'red' else utils.blueOptions()
            playerOptions = [x.title() for x in playerOptions]
            playerMove = raw_input("%s "%playerOptions)
            try:
                responce = self.submitPlayerMove(playerMove)
            except utils.ServerException, e:
                continue
            print "%s Player picked %s"%(responce.get('computerColor').title(), responce.get('computerChoice').title())
            print "Red: %s\nBlue: %s"%(responce['score'].get('red'), responce['score'].get('blue'))
            turnNum += -1



if __name__ == "__main__":
    ctrl = Controller()
Example #3
0
        Start a new game in terminal/commandline mode
        """
        print "\nChoose a Player Color."
        playerColor = raw_input("Red or Blue? ").lower()
        try:
            self.newPlayerCtrl(playerColor)
        except utils.ServerException, e:
            print e
            self.newRawGame()
        turnNum = 4
        while turnNum != 0:
            nextMoveMsg= "\nPlayer %s you have %d moves left.\n" \
                  "Pick your next move."
            print nextMoveMsg % (playerColor.title(), turnNum)
            playerOptions = utils.redOptions(
            ) if playerColor == 'red' else utils.blueOptions()
            playerOptions = [x.title() for x in playerOptions]
            playerMove = raw_input("%s " % playerOptions)
            try:
                responce = self.submitPlayerMove(playerMove)
            except utils.ServerException, e:
                continue
            print "%s Player picked %s" % (responce.get('computerColor').title(
            ), responce.get('computerChoice').title())
            print "Red: %s\nBlue: %s" % (responce['score'].get('red'),
                                         responce['score'].get('blue'))
            turnNum += -1


if __name__ == "__main__":
    ctrl = Controller()