Exemplo n.º 1
0
    def placeButtons(self):
        self.shuffleButton = func.Button(self.root,
                                         text="Shuffle",
                                         command=self.shuffleRack)
        self.shuffleButton.place(x=self.x - 50, y=self.y + 100)

        self.enterButton = func.Button(self.root,
                                       text="Enter Word",
                                       command=self.getNewWord)
        self.enterButton.place(x=self.x + 150, y=self.y + 100)

        self.returnButton = func.Button(self.root,
                                        text="Return",
                                        command=self.returnMovables)
        self.returnButton.place(x=self.x + 250, y=self.y + 100)

        self.exchangeButton = func.Button(self.root,
                                          text="Exchange",
                                          command=self.exchange)
        self.exchangeButton.place(x=self.x + 50, y=self.y + 100)

        self.dictButton = func.Button(self.root,
                                      text="Dictionary",
                                      command=self.make_dict)
        self.dictButton.place(x=self.x - 150, y=self.y + 100)
Exemplo n.º 2
0
    def exchange(self):
        self.root.update_idletasks()

        self.exchangeWindow = func.Toplevel(self.root, height=self.screenHeight/2, \
                                  width = self.screenWidth/2-200)
        self.exchangeWindow.wm_title("Exchange")

        label = func.Label(
            self.exchangeWindow,
            text="Drag the letters you wish to exchange to the rack.",
            relief=func.RAISED)
        label.place(x=90, y=30, height=50, width=320)

        self.exchangeLetters = []
        for letterCount in range(len(self.rack)):
            self.exchangeLetters.append(
                tiles.MovingExchangeLetter(self.exchangeWindow,
                                           self.rack[letterCount],
                                           letterCount * 30 + 150, 300,
                                           self.exchangeWindow))
        for i in self.exchangeLetters:
            i.els = self.exchangeLetters
            i.weed_els()
        self.exchangeLetters[-1].getExchangeRack()

        button = func.Button(self.exchangeWindow,
                             text="Back",
                             command=self.exchangeWindow.destroy)
        button.place(x=250, y=175)

        exchangeButton = func.Button(self.exchangeWindow,
                                     text="Enter",
                                     command=self.getNewTiles)
        exchangeButton.place(x=175, y=175)
Exemplo n.º 3
0
    def make_dict(self):
        self.dict_window = func.Toplevel(self.root, height=500, width=500)
        self.dict_window.title("Dictionary")
        l = func.Label(self.dict_window, height=2, width=50, text="Type a word below to check if it's actually a word.")
 #       self.sv = func.StringVar()
#        self.sv.set("Word")
        self.e = func.Entry(self.dict_window)#, textvariable=self.sv)
        self.e.delete(0, func.END)
        self.e.insert(0, "word")
 #       e.place(height=2, width=50)
        be = func.Button(self.dict_window, text="Enter", command=self.checkDictWord)
        bb = func.Button(self.dict_window, text="Back", command=self.dict_window.destroy)
        self.dwlgen = 0
        for i in [l, self.e, bb, be]:
            i.pack()
Exemplo n.º 4
0
def setup():
    func.setup()

    func.root.config(bg=func.generateRandomColor())

    welcomeLabel = func.Label(func.root, text="Welcome to Scrabble in Python!")
    instructionsButton = func.Button(func.root,
                                     text="Instructions",
                                     command=instructions)
    playButton = func.Button(func.root, text="Play", command=play)
    playSavedButton = func.Button(func.root,
                                  text="Play Saved Game",
                                  command=games.playSavedGame)
    exitButton = func.Button(func.root, text="Exit", command=exitGame)

    welcomeLabel.place(x=40, y=0)
    #instructionsButton.place(x = 90, y = 50)
    playButton.place(x=110, y=100)
    #playSavedButton.place(x = 76, y = 150)
    exitButton.place(x=112, y=200)
Exemplo n.º 5
0
    def __init__(self, root, file="savedGame.txt"):
        self.root = func.Toplevel(root)
        self.root.withdraw()
        self.gameWindow = func.Toplevel(self.root,
                                        height=root.winfo_screenheight(),
                                        width=root.winfo_screenwidth())
        self.gameWindow.resizable(0, 0)
        self.gameWindow.wm_title("Saved Games")
        gameTexts = open(file).read()
        gameTexts = gameTexts.split("New Game\n")
        newGameTexts = []
        for i in gameTexts:
            newGameTexts.append(i.strip())
        #print(gameTexts)
        self.gameTexts = newGameTexts
        gameLabels = []
        gameButtons = []
        deleteButtons = []
        column = 0
        for gameText in gameTexts:
            if gameText:
                fullText = self.setGameVars(gameText)
                if fullText != "nogame":
                    text = """%s's score: %s
        %s's score: %s
        Mode 1: %s
        Mode 2: %s""" % (fullText[0], fullText[1], fullText[2], fullText[3],
                         fullText[4], fullText[5])
                    gameLabel = func.Label(
                        self.gameWindow,
                        text=text,
                        height=4,
                        width=20,
                        relief=func.RAISED)  #Definetly changeable
                    gameLabels.append(gameLabel)
                    gameLabels[-1].place(x=0, y=column * 100)

                    gameButton = func.Button(self.gameWindow, text="Play!", height=1, width=5, \
                                        command=lambda game=gameText: self.play(game))
                    gameButtons.append(gameButton)
                    gameButtons[-1].place(x=350,
                                          y=(gameTexts.index(gameText) * 100))

                    column += 1
Exemplo n.º 6
0
def instructions():
    """Needs to be updated"""
    text = """Instructions for Scrabble:

    You get a rack of 7 tiles to start the game. You must play words with these
    7 tiles so that each word formed vertically and horizontally is a word.
    
    \tNote: Whenever you play a word, make sure that it touches at least
    \tone other letter on the board (not diagonally.)
    \tThe first move must touch the star in the middle of the board.
    
    To play a tile, click and drag the tile to the board.
    \tNote: When you play a tile, make sure that it snaps into a space.
    \tIf it doesn't, then it didn't place and you have to do it again.
    "?" tiles are blank tiles. They can be played as any letter.

    If you can't find any words to make, you can exchange. Exchanging 
   You get a certain amount of points based on the letters you played.
    Special Score Tiles:
    \tTWS (triple word score): Multiplies your score for that turn by 3.
    \tDWS (double word score): Multiplies your score for that turn by 2.
    \tTLS (triple letter score): Multiplies your score for that letter by 3.
    \tDLS (double letter score): Multiplies your score for that letter by 2.
    
    Once you play a word, you draw tiles until you have seven again.
    The game ends when there are no tiles left in the bag.

    Modes:
    Normal: wrong word -> continue
    Hardcore: wrong word -> lose turn

    Normal: play until no tiles in bag
    Short: play to 75 points"""

    instructionsWindow = func.Toplevel(root,
                                       height=root.winfo_screenheight(),
                                       width=root.winfo_screenwidth())
    instructionsWindow.title("Instructions")
    instructionsLabel = func.Label(instructionsWindow, text=text, justify=LEFT)
    instructionsLabel.place(x=300, y=10, height=750, width=500)
    closeButton = func.Button(instructionsLabel,
                              text="Close",
                              command=instructionsWindow.destroy)
    closeButton.place(x=225, y=600)
Exemplo n.º 7
0
 def chooseBlank(self):
     self.blankWindow.deiconify()
     chooseLabel = func.Label(self.blankWindow, text = "Choose the tile you want your blank to be.")
     chooseLabel.place(x = 400, y = 200, width = 300, height = 100)
     self.choiceWindow = func.Frame(self.blankWindow)
     self.choiceWindow.place(x=400, y=400, width=500, height = 500)
     buttons = []
     row = 1
     column = 1
     for letter in func.ascii_uppercase:
         button = func.Button(self.choiceWindow, text = letter,
                         command = lambda letter=letter: self.setBlank(letter), \
                         height = 1, width = 1)
         buttons.append(button)
         buttons[-1].place(x = row * 30, y = column * 30)
         column += 1
         if column % 6 == 0:
             column = 1
             row += 1
Exemplo n.º 8
0
    def startTurn(self, otherName, otherScore):
        try:
            self.oldroot.destroy()
        except AttributeError:
            pass
        self.drawTiles()
        self.switchTurn = 0
        self.dwlgen = 0
        self.root.deiconify()
        self.root.title("%s's Turn" % self.name)
        self.root.resizable(0, 0)
        self.root.geometry("%dx%d%+d%+d" % (675, 700, 0, 0))
        self.root.config(bg=func.generateRandomColor())
        #        self.root.config(
        self.rackFrame = func.Frame(self.root, bd=1, relief=func.RAISED)
        self.rackFrame.place(x=self.x, y=self.y + 25, width=300, height=50)

        self.getMovables(self.x + 50, self.y + 25)
        for movable in self.movables:
            movable.board = self.board

        self.coverUp = func.Button(self.root,
                                   text="Click to see tiles",
                                   command=self.showTiles)
        self.coverUp.place(x=self.x, y=self.y + 25, width=300, height=50)
        self.coverUp.lift()

        self.rackFrame.lower()
        self.movables[-1].getBoard()

        self.placeButtons()

        self.screenHeight = self.root.winfo_screenheight()
        self.screenWidth = self.root.winfo_screenwidth()

        self.getScoreBoard(otherName, otherScore)

        self.root.mainloop()
Exemplo n.º 9
0
def play():
    global enterWindow, name1Var, name2Var, mode1Var, mode2Var, playing

    playing = 1
    enterWindow = func.Toplevel(func.root, height = func.root.winfo_screenheight(),\
                           width = func.root.winfo_screenwidth())
    enterWindow.wm_title("Enter Names and Modes")

    label1 = func.Label(enterWindow, text="Enter name 1:")
    label1.place(x=50, y=50, height=20, width=95)
    name1Var = func.StringVar()
    name1Var.set("Joe")
    name1 = func.Entry(enterWindow, textvariable=name1Var)
    name1.place(x=150, y=50, height=20, width=100)

    label2 = func.Label(enterWindow, text="Enter name 2:")
    label2.place(x=50, y=175, height=20, width=95)
    name2Var = func.StringVar()
    name2Var.set("CPU")
    name2 = func.Entry(enterWindow, textvariable=name2Var)
    name2.place(x=150, y=175, height=20, width=100)

    cpuRemindLabel = func.Label(enterWindow,
                                text="""Note: If name 2 is CPU, the computer
    will play for that player.""")
    cpuRemindLabel.place(x=50, y=215, height=30, width=250)

    mode1Label = func.Label(enterWindow,
                            text="Enter mode 1 (normal or hardcore):")
    mode1Label.place(x=50, y=295, height=20, width=210)
    mode1Var = func.StringVar()
    mode1Var.set("normal")
    mode1 = func.Entry(enterWindow, textvariable=mode1Var)
    mode1.place(x=270, y=295, height=20, width=100)

    mode1Questions = func.Button(enterWindow, text="?", command=mode1questions)
    mode1Questions.place(x=370, y=280, height=50, width=50)

    mode1Switch = func.Button(enterWindow,
                              text="Switch",
                              command=mode1VarSwitch)
    mode1Switch.place(x=430, y=280, height=50, width=75)

    mode2Label = func.Label(enterWindow,
                            text="Enter mode 2 (normal or short):")
    mode2Label.place(x=50, y=465, height=20, width=200)
    mode2Var = func.StringVar()
    mode2Var.set("normal")
    mode2 = func.Entry(enterWindow, textvariable=mode2Var)
    mode2.place(x=270, y=465, height=20, width=100)

    mode2Questions = func.Button(enterWindow, text="?", command=mode2questions)
    mode2Questions.place(x=370, y=450, height=50, width=50)

    mode2Switch = func.Button(enterWindow,
                              text="Switch",
                              command=mode2VarSwitch)
    mode2Switch.place(x=430, y=450, height=50, width=75)

    enterButton = func.Button(enterWindow,
                              text="Enter data",
                              command=checkData)
    enterButton.place(x=100, y=500)