本文整理汇总了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()
#.........这里部分代码省略.........