Exemple #1
0
    def __init__(self, parent, id=wx.ID_ANY):
        wx.Panel.__init__(self, parent, id)

        self.SetBackgroundColour(wx.Colour(255, 255, 255))

        ps = wx.BoxSizer(wx.VERTICAL)
        self.splitter = wx.SplitterWindow(self, wx.VERTICAL)
        ps.Add(self.splitter, 1, flag=wx.EXPAND)
        self.SetSizer(ps)

        #---------------------------------------------------------------------------------------------

        self.leftPanel = wx.Panel(self.splitter)
        bs = wx.BoxSizer(wx.VERTICAL)
        self.leftPanel.SetSizer(bs)
        self.leftPanel.SetBackgroundColour(wx.Colour(255, 255, 255))
        self.leftPanel.Bind(wx.EVT_SIZE, self.setWrappedRaceInfo)

        buttonSize = 220
        self.button = RoundButton(self.leftPanel,
                                  size=(buttonSize, buttonSize))
        self.button.SetLabel(FinishText)
        self.button.SetFontToFitLabel()
        self.button.SetForegroundColour(wx.Colour(128, 128, 128))
        self.Bind(wx.EVT_BUTTON, self.onPress, self.button)

        self.clock = Clock(self, size=(190, 190), checkFunc=self.updateClock)
        self.clock.SetBackgroundColour(wx.WHITE)

        self.raceIntro = wx.StaticText(self.leftPanel, label=u'')
        self.raceIntro.SetFont(wx.Font(20, wx.DEFAULT, wx.NORMAL, wx.NORMAL))

        self.chipTimingOptions = wx.RadioBox(
            self.leftPanel,
            label=_("Chip Timing Options"),
            majorDimension=1,
            choices=Properties.RfidProperties.choices,
            style=wx.RA_SPECIFY_COLS)

        self.Bind(wx.EVT_RADIOBOX, self.onChipTimingOptions,
                  self.chipTimingOptions)

        self.settingsButton = wx.BitmapButton(
            self.leftPanel, bitmap=Utils.GetPngBitmap('settings-icon.png'))
        self.settingsButton.SetToolTip(wx.ToolTip(_('Properties Shortcut')))
        self.settingsButton.Bind(wx.EVT_BUTTON, self.onShowProperties)

        self.startRaceTimeCheckBox = wx.CheckBox(
            self.leftPanel, label=_('Start Race Automatically at Future Time'))

        hsSettings = wx.BoxSizer(wx.HORIZONTAL)
        hsSettings.Add(self.settingsButton, flag=wx.ALIGN_CENTER_VERTICAL)
        hsSettings.Add(self.startRaceTimeCheckBox,
                       flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL,
                       border=12)

        border = 8
        hs = wx.BoxSizer(wx.HORIZONTAL)
        hs.Add(self.button, border=border, flag=wx.LEFT | wx.TOP)
        hs.Add(self.raceIntro,
               1,
               border=border,
               flag=wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND)
        bs.Add(hs, border=border, flag=wx.ALL)

        hsClock = wx.BoxSizer(wx.HORIZONTAL)
        hsClock.AddSpacer(26)
        hsClock.Add(self.clock)
        hsClock.Add(hsSettings, border=4, flag=wx.LEFT)
        bs.Add(hsClock, border=4, flag=wx.ALL)

        bs.Add(self.chipTimingOptions, border=border, flag=wx.ALL)

        #---------------------------------------------------------------------------------------------

        self.rightPanel = wx.Panel(self.splitter)
        self.rightPanel.SetBackgroundColour(wx.Colour(255, 255, 255))
        checklistTitle = wx.StaticText(self.rightPanel, label=_('Checklist:'))
        checklistTitle.SetFont(
            wx.Font(14, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_NORMAL))
        self.checklist = Checklist.Checklist(self.rightPanel)

        hsSub = wx.BoxSizer(wx.VERTICAL)
        hsSub.Add(checklistTitle, 0, flag=wx.ALL, border=4)
        hsSub.Add(self.checklist,
                  1,
                  flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
                  border=4)
        self.rightPanel.SetSizer(hsSub)

        #---------------------------------------------------------------------------------------------

        self.splitter.SplitVertically(self.leftPanel, self.rightPanel)
        self.splitter.SetMinimumPaneSize(100)
        wx.CallAfter(self.refresh)
        wx.CallAfter(self.splitter.SetSashPosition, 650)
        wx.CallAfter(self.GetSizer().Layout)
Exemple #2
0
def setupGame(characterPicked, data):
    data.time = 0
    data.numOfPlayers = 6
    data.characterPicked = characterPicked #todo
    data.current = data.numOfPlayers-1 #index in player order of current player
    data.currentSuggestion = None #todo
    data.disproveCount = None #who is disproving
    data.humanCanDisprove = False #if the human can disprove it
    data.shown = None
    data.nextTurn = False #wait before going to next turn 
    data.selectedToShow = None
    data.tellHumanToShow = False
    data.humanMoved = False
    data.pBeingMoved = False #person moved to another room
    data.winner = None
    data.disproved = True
    #initial locations: (by index in player order)   
    data.locations = [(23,7), (17,0), (0,9), (0,14), (6,23), (19,23)]
    data.checklist = Checklist(data)
    data.board = GameBoard(data)
    data.boardMap = BoardMap(data)
    data.buttons = Buttons(data)
    data.roll = 6
    data.rolled = False #hooman hasn't rolled yet
    data.moved = False
    data.gameStarted = False
    data.losers = []
    
    data.selectedCharac = None #for accusations
    data.selectedWeapon = None
    data.selectedRoom = None

    numCardsPerPlayer = data.numOfCards//data.numOfPlayers
    usedCards = [] #cards that have been assigned
    
    #places cards in envelope: 'solution'
    envelope = placingInEnvelope(data)
    data.solution = envelope
    usedCards += envelope
    print(data.solution)
    
    data.human = Human(data, characterPicked)
    #initializing 5 AI players:
    data.p1 = AIPlayer(data, 1)
    data.p2 = AIPlayer(data, 2)
    data.p3 = AIPlayer(data, 3)
    data.p4 = AIPlayer(data, 4)
    data.p5 = AIPlayer(data, 5)
    
    order = [data.p1, data.p2, data.p3, data.p4, data.p5] 
    data.playerOrder = order[:characterPicked] + [data.human] + order[characterPicked:]
    #they go in that order

    for player in data.playerOrder:
        Cards = randomAssignment(usedCards,numCardsPerPlayer,data.numOfCards)
        usedCards += Cards[0]
        player.inputInitialInfo(data, Cards[1])
        i = data.playerOrder.index(player)
        player.setInitialLocation(data, data.locations[i][0], data.locations[i][1])
        #gives different cards to each one

    data.img1 = PhotoImage(file = "imagesGIF\%d.gif" %data.human.cards[0])
    data.img2 = PhotoImage(file = "imagesGIF\%d.gif" %data.human.cards[1]) 
    data.img3 = PhotoImage(file = "imagesGIF\%d.gif" %data.human.cards[2])
    data.cardImgs = [data.img1, data.img2, data.img3]