コード例 #1
0
ファイル: Board.py プロジェクト: zu-ctrl/ITSecCardGame
    def DrawCards(self, frame, cards, maxFrames):
        GlobalFunc.RemoveAllChildren(frame)
        counter = 0
        for c in cards:
            cardSpot = tk.Frame(frame,
                                height=self.__cardHeight,
                                width=self.__cardWidth)
            cardSpot.config(borderwidth=5, relief=RIDGE)
            cardSpot.pack(side=LEFT, pady=10, padx=10, fill=NONE)
            cardSpot.pack_propagate(0)
            card = Card(c, self.__controller)
            card.Draw(cardSpot, self.__cardHeight, self.__cardWidth)

            cardSpot.bind("<Enter>",
                          lambda e, area=cardSpot: self.MouseEnterArea(area))
            cardSpot.bind("<Leave>",
                          lambda e, area=cardSpot: self.MouseLeaveArea(area))
            counter += 1

        if counter < maxFrames:
            for i in range(counter, maxFrames):
                cardSpot = tk.Frame(frame,
                                    height=self.__cardHeight,
                                    width=self.__cardWidth)
                cardSpot.config(borderwidth=5,
                                relief=RIDGE,
                                background=Controller.Master.MasterController.
                                BACKGROUND_COLOR_CARD)
                cardSpot.pack(side=LEFT, pady=10, padx=10)
                cardSpot.bind(
                    "<Enter>",
                    lambda e, area=cardSpot: self.MouseEnterArea(area))
                cardSpot.bind(
                    "<Leave>",
                    lambda e, area=cardSpot: self.MouseLeaveArea(area))
コード例 #2
0
ファイル: Board.py プロジェクト: zu-ctrl/ITSecCardGame
    def AppendInformation(self, message):
        if self.__messageCount == 0:
            GlobalFunc.RemoveAllChildren(self.__messageArea)
            self.__messageArea.pack_propagate(0)

            self.__actionArea = tk.Frame(
                self.__messageArea,
                background=Controller.Master.MasterController.RED,
                borderwidth=5,
                relief=RIDGE)
            self.__actionArea.pack()
            label = tk.Label(self.__actionArea,
                             text=self.ACTIONS,
                             background=Controller.Master.MasterController.RED,
                             wraplength=(self.__root.winfo_width() / 4) - 10)
            label.config(font=("Arial Black", 16, BOLD))
            label.pack()

        messageLabel = tk.Label(
            self.__actionArea,
            text=message,
            background=Controller.Master.MasterController.RED,
            wraplength=(self.__root.winfo_width() / 4) - 10)
        messageLabel.config(font=("Arial", 12))
        messageLabel.pack()
        self.__root.update()
        self.__messageCount += 1
コード例 #3
0
ファイル: Board.py プロジェクト: zu-ctrl/ITSecCardGame
 def PutOpponentInformation(self, opponent):
     GlobalFunc.RemoveAllChildren(self.__opponentInformationArea)
     self.GenerateTextPair(self.PLAYER_INFO_CARDS_ON_HAND,
                           len(opponent.hand),
                           self.__opponentInformationArea)
     self.GenerateTextPair(self.PLAYER_INFO_CARDS_LEFT, opponent.CardsLeft,
                           self.__opponentInformationArea)
コード例 #4
0
    def AddMenuText(self, menuArea):

        label = tk.Label(menuArea, text=self.INFO_MENU, justify=LEFT)
        label.bind("<Button-1>", self.__controller.OpenMenu)
        label.pack(side=LEFT, padx=5)

        labelClose = tk.Label(menuArea, text=self.INFO_EXIT, justify=LEFT)
        labelClose.bind(
            "<Button-1>",
            lambda e, root=self.__root: GlobalFunc.CloseWindow(root))
        labelClose.pack()
コード例 #5
0
ファイル: Board.py プロジェクト: zu-ctrl/ITSecCardGame
    def PutPlayerInformation(self, player):
        GlobalFunc.RemoveAllChildren(self.__playerInformationArea)
        self.GenerateTextPair(self.PLAYER_INFO_ACTION_POINTS,
                              player.ActionPoints,
                              self.__playerInformationArea)
        self.GenerateTextPair(self.PLAYER_INFO_CARDS_LEFT, player.CardsLeft,
                              self.__playerInformationArea)

        endTurnButton = tk.Button(self.__playerInformationArea,
                                  text="End turn")
        endTurnButton.bind("<ButtonRelease-1>",
                           lambda e: self.__controller.EndTurn())
        endTurnButton.pack(anchor=S, pady=25)
コード例 #6
0
ファイル: Board.py プロジェクト: zu-ctrl/ITSecCardGame
    def AddInformation(self, informationText):
        GlobalFunc.RemoveAllChildren(self.__messageArea)
        self.__messageArea.pack_propagate(0)

        information = tk.Frame(
            self.__messageArea,
            background=Controller.Master.MasterController.RED,
            borderwidth=5,
            relief=RIDGE)
        information.pack()
        label = tk.Label(information,
                         text=informationText,
                         background=Controller.Master.MasterController.RED,
                         wraplength=(self.__root.winfo_width() / 4) - 10)
        label.config(font=("Arial Black", 16, BOLD))
        label.pack()
        self.__root.update()
コード例 #7
0
    def ShowSettings(self, settings):
        musicToggle = settings.Music
        self.__menuVisible = False
        GlobalFunc.RemoveAllChildren(self.__root)

        settings = tk.Frame(self.__root)
        settings.config(borderwidth=5,
                        relief=RIDGE,
                        background=Controller.Master.MasterController.RED)
        settings.pack(anchor=CENTER)

        settingsHeading = tk.Label(
            settings,
            text=self.SETTINGS,
            background=Controller.Master.MasterController.RED)
        settingsHeading.config(font=("Arial Black", 25, BOLD))

        settingsFont = tkFont.Font(settingsHeading,
                                   settingsHeading.cget("font"))
        settingsFont.configure(underline=True)
        settingsHeading.config(font=settingsFont)

        settingsHeading.pack()

        soundFrame = tk.Frame(settings)
        soundFrame.pack()

        if musicToggle:
            music = self.GenerateLabel(soundFrame, "Music: ON")
            music.bind("<Button-1>",
                       lambda e: self.__controller.MusicOff(music))
        else:
            music = self.GenerateLabel(soundFrame, "Music: OFF")
            music.bind("<Button-1>",
                       lambda e: self.__controller.MusicOn(music))

        self.AddBackButton(settings)
コード例 #8
0
ファイル: Master.py プロジェクト: zu-ctrl/ITSecCardGame
 def CloseApplication(self):
     GlobalFunc.CloseWindow(self.__root)
コード例 #9
0
    def DisplayMenu(self):
        GlobalFunc.RemoveAllChildren(self.__root)

        menuFrame = tk.Frame(self.__root)
        menuFrame.config(borderwidth=5,
                         relief=RIDGE,
                         background=Controller.Master.MasterController.RED)
        menuFrame.pack(anchor=CENTER)

        labelMenu = tk.Label(menuFrame,
                             text=self.MENU_HEADING,
                             background=Controller.Master.MasterController.RED)
        labelMenu.config(font=("Arial Black", 25, BOLD))

        menuFont = tkFont.Font(labelMenu, labelMenu.cget("font"))
        menuFont.configure(underline=True)
        labelMenu.config(font=menuFont)
        labelMenu.pack(fill=X, padx=10, pady=5)

        labelNewGame = tk.Label(
            menuFrame,
            text=self.START_GAME,
            background=Controller.Master.MasterController.RED)
        labelNewGame.config(font=("Arial Black", 20, BOLD))
        labelNewGame.bind("<Button-1>",
                          lambda e: self.__controller.StartNewGame())
        labelNewGame.pack(fill=X, padx=10)

        labelSettings = tk.Label(
            menuFrame,
            text=self.SETTINGS,
            background=Controller.Master.MasterController.RED)
        labelSettings.config(font=("Arial Black", 20, BOLD))
        labelSettings.bind("<Button-1>",
                           lambda e: self.__controller.ShowSettings())
        labelSettings.pack(fill=X, padx=10)

        labelSettings = tk.Label(
            menuFrame,
            text=self.INSTRUCTIONS,
            background=Controller.Master.MasterController.RED)
        labelSettings.config(font=("Arial Black", 20, BOLD))
        labelSettings.bind("<Button-1>",
                           lambda e: self.__controller.ShowInstructions())
        labelSettings.pack(fill=X, padx=10)

        labelSettings = tk.Label(
            menuFrame,
            text=self.CREDITS_HEADING,
            background=Controller.Master.MasterController.RED)
        labelSettings.config(font=("Arial Black", 20, BOLD))
        labelSettings.bind("<Button-1>", lambda e: self.__controller.Credits())
        labelSettings.pack(fill=X, padx=10)

        labelExit = tk.Label(menuFrame,
                             text=self.EXIT,
                             background=Controller.Master.MasterController.RED)
        labelExit.config(font=("Arial Black", 20, BOLD))
        labelExit.bind(
            "<Button-1>",
            lambda e, root=self.__root: GlobalFunc.CloseWindow(root))
        labelExit.pack(fill=X, padx=10)
コード例 #10
0
    def ShowInstructions(self):
        GlobalFunc.RemoveAllChildren(self.__root)

        instructionFrame = tk.Frame(self.__root)
        instructionFrame.config(
            borderwidth=5,
            relief=RIDGE,
            background=Controller.Master.MasterController.RED)
        instructionFrame.pack(anchor=CENTER)

        headingInstructions = tk.Label(
            instructionFrame,
            text="Instructions",
            background=Controller.Master.MasterController.RED)
        headingInstructions.config(font=("Arial Black", 25, BOLD))

        headingFont = tkFont.Font(headingInstructions,
                                  headingInstructions.cget("font"))
        headingFont.configure(underline=True)
        headingInstructions.config(font=headingFont)
        headingInstructions.pack(fill=X, padx=10, pady=5)

        self.GenerateSecondLevelHeading(instructionFrame, "How to:")

        drawCard = self.GenerateLabel(
            instructionFrame,
            "To draw a new card, click on your deck. Your deck have the color purple."
        )
        drawCard.config(wraplength=800, justify=LEFT, pady=5, padx=5)

        attackCard = self.GenerateLabel(
            instructionFrame,
            "To attack your opponent, first click on the card you want to attack with, then click on the card you wish to attack. Your cards are the middle row, and your opponent have the cards placed at the top row."
        )
        attackCard.config(wraplength=800, justify=LEFT, pady=5, padx=5)

        #TODO: Fix the padding so it does not double.
        placeCard = self.GenerateLabel(
            instructionFrame,
            "To place a card in the pool of visible cards, click on the card you want to place that is on your hand. Your hand is the row at the bottom to the left of your deck."
        )
        placeCard.config(wraplength=800, justify=LEFT, pady=5, padx=5)

        self.GenerateSecondLevelHeading(instructionFrame, "Action costs:")
        self.GenerateLabel(
            instructionFrame,
            "Draw new card: %d action points." % Player.Player.CARD_COST)
        self.GenerateLabel(
            instructionFrame,
            "Place card: %d action points." % Player.Player.CARD_COST)
        self.GenerateLabel(
            instructionFrame, "Attack opponent card: %d action point." %
            Player.Player.ATTACK_COST)

        self.GenerateSecondLevelHeading(instructionFrame, "Rules:")
        ruleLabel = self.GenerateLabel(
            instructionFrame,
            "Force your opponent to not being able to play any more cards. This is done by attacking the opponents cards. Remember, only attack a card with lower DP than your card have AP."
        )
        ruleLabel.config(wraplength=800, justify=LEFT, pady=5, padx=5)

        self.AddBackButton(instructionFrame)
コード例 #11
0
    def ShowCredits(self, cred):
        GlobalFunc.RemoveAllChildren(self.__root)

        menuFrame = tk.Frame(self.__root)
        menuFrame.config(borderwidth=5,
                         relief=RIDGE,
                         background=Controller.Master.MasterController.RED)
        menuFrame.pack(anchor=CENTER)

        labelCredits = tk.Label(
            menuFrame,
            text=self.CREDITS_HEADING,
            background=Controller.Master.MasterController.RED)
        labelCredits.config(font=("Arial Black", 25, BOLD))
        labelCredits.pack(fill=X)

        sourceFrame = tk.Frame(menuFrame)
        sourceFrame.config(background=Controller.Master.MasterController.RED)
        sourceFrame.pack(fill=X)

        self.GenerateSecondLevelHeading(sourceFrame, self.CREDITS_SOURCE)

        for s in cred.Source:
            self.GenerateLabel(sourceFrame, s)

        musicFrame = tk.Frame(menuFrame)
        musicFrame.config(background=Controller.Master.MasterController.RED)
        musicFrame.pack(fill=X)

        self.GenerateSecondLevelHeading(musicFrame, self.CREDITS_MUSIC)

        for s in cred.Music:
            self.GenerateLabel(musicFrame, s)

        soundEffectFrame = tk.Frame(menuFrame)
        soundEffectFrame.config(
            background=Controller.Master.MasterController.RED)
        soundEffectFrame.pack(fill=X)

        self.GenerateSecondLevelHeading(soundEffectFrame, self.CREDITS_SOUND)

        for s in cred.SoundEffects:
            self.GenerateLabel(soundEffectFrame, s)

        imageFrame = tk.Frame(menuFrame)
        imageFrame.config(background=Controller.Master.MasterController.RED)
        imageFrame.pack(fill=X)

        self.GenerateSecondLevelHeading(imageFrame, self.CREDITS_IMAGES)

        for s in cred.Images:
            self.GenerateLabel(imageFrame, s)

        lisenceFrame = tk.Frame(menuFrame)
        lisenceFrame.config(background=Controller.Master.MasterController.RED)
        lisenceFrame.pack(fill=X)

        self.GenerateSecondLevelHeading(lisenceFrame, self.CREDITS_LICENSE,
                                        ("Arial Black", 12, BOLD))
        self.GenerateLabel(lisenceFrame, cred.License, ("Arial", 10, BOLD))

        self.AddBackButton(menuFrame)
コード例 #12
0
ファイル: Board.py プロジェクト: zu-ctrl/ITSecCardGame
    def __init__(self, root, controller, player, opponent):
        GlobalFunc.RemoveAllChildren(root)
        self.__messageCount = 0

        self.__root = root
        self.__root.grid_propagate(0)
        self.__controller = controller

        self.__cardHeight = 275
        self.__cardWidth = 190
        self.__playerInfoWidth = self.__root.winfo_width() - (
            self.__cardWidth * 6)

        self.__visibleCardsArea = tk.Frame(
            self.__root,
            width=self.__root.winfo_width(),
            height=(self.__root.winfo_height() / 3) * 2,
            background=Controller.Master.MasterController.BACKGROUND_COLOR)
        self.__visibleCardsArea.grid(row=0, padx=self.__cardWidth)

        #Visible cards player one
        self.__cardAreaPlayerOne = tk.Frame(
            self.__visibleCardsArea,
            background=Controller.Master.MasterController.BACKGROUND_COLOR,
            width=((self.__root.winfo_width() - 5) / 4) * 3,
            height=(self.__root.winfo_height() / 3))
        #Visible cards player two
        self.__cardAreaPlayerTwo = tk.Frame(
            self.__visibleCardsArea,
            background=Controller.Master.MasterController.BACKGROUND_COLOR,
            width=((self.__root.winfo_width() - 5) / 4) * 3,
            height=(self.__root.winfo_height() / 3))

        #Messages
        self.__opponentInformationArea = tk.Frame(
            self.__visibleCardsArea,
            width=self.__root.winfo_width() / 4,
            height=(self.__root.winfo_height() / 3),
            background=Controller.Master.MasterController.BACKGROUND_COLOR)
        self.__messageArea = tk.Frame(
            self.__visibleCardsArea,
            width=self.__root.winfo_width() / 4,
            height=(self.__root.winfo_height() / 3),
            background=Controller.Master.MasterController.BACKGROUND_COLOR)

        self.__cardAreaPlayerTwo.grid(row=0, column=0)
        self.__cardAreaPlayerOne.grid(row=1, column=0)
        self.__opponentInformationArea.grid(row=0, column=1)
        self.__opponentInformationArea.grid_propagate(0)
        self.__messageArea.grid(row=1, column=1)
        self.__messageArea.grid_propagate(0)

        #Area with player information, deck, and cards on hand
        self.__handArea = tk.Frame(
            self.__root,
            background=Controller.Master.MasterController.BACKGROUND_COLOR,
            width=self.__root.winfo_width(),
            height=(self.__root.winfo_height() / 3))
        self.__handArea.grid(row=1, column=0, columnspan=2, padx=0)

        #All cards on the hand not visible
        self.__handCardArea = tk.Frame(
            self.__handArea,
            height=self.__cardHeight,
            bg=Controller.Master.MasterController.BACKGROUND_COLOR)
        self.__handCardArea.pack(side=LEFT)

        #The purple square
        self.__handDeckArea = tk.Frame(self.__handArea,
                                       height=self.__cardHeight,
                                       width=self.__cardWidth)
        self.__handDeckArea.config(
            borderwidth=5,
            relief=RIDGE,
            background=Controller.Master.MasterController.DECK_COLOR)
        self.__handDeckArea.pack(side=LEFT, padx=25)
        self.__handDeckArea.bind(
            "<Enter>",
            lambda e, area=self.__handDeckArea: self.MouseEnterArea(area))
        self.__handDeckArea.bind(
            "<Leave>",
            lambda e, area=self.__handDeckArea: self.MouseLeaveArea(area))
        self.__handDeckArea.bind("<ButtonRelease-1>",
                                 lambda e: self.__controller.DrawCard())

        #AP, Cards left, etc
        self.__playerInformationArea = tk.Frame(self.__handArea,
                                                width=self.__playerInfoWidth,
                                                height=self.__cardHeight)
        self.__playerInformationArea.pack(side=RIGHT)
        self.__playerInformationArea.config(
            background=Controller.Master.MasterController.BACKGROUND_COLOR,
            borderwidth=3)
        self.__playerInformationArea.pack(side=RIGHT, padx=25)

        self.DrawCards(self.__handCardArea, player.hand, player.MAX_HAND_SIZE)

        self.DrawCards(self.__cardAreaPlayerOne, player.VisibleCards,
                       player.MAX_VISIBLE_CARDS)

        self.DrawCards(self.__cardAreaPlayerTwo, opponent.VisibleCards,
                       opponent.MAX_VISIBLE_CARDS)

        self.PutPlayerInformation(player)
        self.PutOpponentInformation(opponent)
コード例 #13
0
ファイル: Board.py プロジェクト: zu-ctrl/ITSecCardGame
 def ResetInformation(self):
     GlobalFunc.RemoveAllChildren(self.__messageArea)
     self.__messageArea.config(
         background=Controller.Master.MasterController.BACKGROUND_COLOR)
コード例 #14
0
ファイル: Game.py プロジェクト: zu-ctrl/ITSecCardGame
 def StartNewGame(self, player=None, opponent=None):
     GlobalFunc.RemoveAllChildren(self.__root)
     self.__boardView = Board(self.__root, self.__controller, player,
                              opponent)
コード例 #15
0
ファイル: Menu.py プロジェクト: zu-ctrl/ITSecCardGame
 def OpenMainMenu(self, root):
     GlobalFunc.RemoveAllChildren(root)
     self.__menuView.DisplayMenu()