当前位置: 首页>>代码示例>>Python>>正文


Python Deck.drawGuarantee方法代码示例

本文整理汇总了Python中Deck.Deck.drawGuarantee方法的典型用法代码示例。如果您正苦于以下问题:Python Deck.drawGuarantee方法的具体用法?Python Deck.drawGuarantee怎么用?Python Deck.drawGuarantee使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Deck.Deck的用法示例。


在下文中一共展示了Deck.drawGuarantee方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GamePlayScreen

# 需要导入模块: from Deck import Deck [as 别名]
# 或者: from Deck.Deck import drawGuarantee [as 别名]
class GamePlayScreen(Screen):
    numberofsets = NumericProperty(0)
    restart = ObjectProperty()
    screenManager = ObjectProperty()
    aiScore = NumericProperty()
    aiActivated = BooleanProperty()
    directory = StringProperty('')

    hintActivated = BooleanProperty(False)
    number_of_players = NumericProperty(1)
    name_of_players = ListProperty(['', '', '', ''])
    scores_of_players = ListProperty([0, 0, 0, 0])

    cards = ListProperty()
    displayHintTimer = NumericProperty(5)

    aiPlayed = BooleanProperty(False)
    active = BooleanProperty(False)

    def __init__(self, *args, **kwargs):
        super(GamePlayScreen, self).__init__(*args, **kwargs)
        self.rotator = Rotator()
        Clock.schedule_once(self.post_init,0)

    def post_init(self,*args):
        self.buttons = self.ids.cards_layout.children
        for i in range(12):
            self.buttons[i].bind(on_press=self.checkIfSetOnBoard)

    # Dealing with multiplayer ###
    def select_player_popup(self, *args):
        '''called when three cards are selected'''
        popup = SelectPlayersPopup(self)
        popup.open()

    def on_pre_leave(self):
        self.endscreen = self.game.get_screen('end')
        self.endscreen.aiScore = self.aiScore
        self.active = False

    def unselectAll(self):
        ''' Unselect all the toggle buttons '''
        for button in self.buttons:
            button.state = 'normal'

    def on_enter(self):
        ''' Sets the game '''
        # You can only enter the game from the intro
        self.deck = Deck()
        self.cards = self.deck.drawGuarantee(numberofcards=12)
        for i in range(len(self.scores_of_players)):
            self.scores_of_players[i] = 0
        self.ai = AI(self.directory)
        self.aiScore = 0
        self.game.active = True
        self.active = True
        self.newRound()
        self.t0 = datetime.datetime.now()

    def goToSettings(self):
        Clock.unschedule(self.AIplay)
        Clock.unschedule(self.aiMoves)
        App.get_running_app().open_settings()

    def newRound(self):
        ''' What should be done at the begining of every round '''
        self.stopRotation()
        self.updateGrid()
        self.setUpHint()
        self.unselectAll()
        self.setUpAI()

    def foundCorrect(self, down, *args):
        ''' Called once a shugou is found '''
        self.aiUpdates()
        if self.aiPlayed:
            self.aiScore += 1
            self.aiPlayed = False
        else:
            if self.number_of_players > 1:
                self.select_player_popup()
            else:
                self.scores_of_players[0] += 1

        selectedcards = {self.cards[i] for i in down}
        try:
            newcards = self.deck.drawGuarantee(
                othercards=set(self.cards) ^ selectedcards,
                numberofcards=3)
        except ValueError:  # no more shugous available
            self.game.current = 'end'
            return
        for index, i in enumerate(down):
            self.cards[i] = newcards[index]
        self.newRound()

    def checkIfSetOnBoard(self, obj):
        '''Called when a button is pressed, checks if there is a set.
        If there is one, then refill the display cards'''
        down = self.selected()
#.........这里部分代码省略.........
开发者ID:IsabellKonrad,项目名称:Shugou,代码行数:103,代码来源:gameplay.py


注:本文中的Deck.Deck.drawGuarantee方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。