當前位置: 首頁>>代碼示例>>Python>>正文


Python Deck.insertCard方法代碼示例

本文整理匯總了Python中Deck.insertCard方法的典型用法代碼示例。如果您正苦於以下問題:Python Deck.insertCard方法的具體用法?Python Deck.insertCard怎麽用?Python Deck.insertCard使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Deck的用法示例。


在下文中一共展示了Deck.insertCard方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import Deck [as 別名]
# 或者: from Deck import insertCard [as 別名]
class Board:
    def __init__(self):
        #spots are the 14 possible spots where you can play a minion
        self.spots = ([],[])
        for i in range (0,7):
            self.spots[0].append(Spot((200*i+70,390)))
            self.spots[1].append(Spot((200*i+70,190)))
        #Hands are each player's hands
        self.hands = (Hand(),Hand())
        
        #Creates two dummy decks, which will be filled in later
        self.Deck1 = Deck("Player1", "Warlock")
        self.Deck2 = Deck("Player2", "Druid")
        
        #Effects begins null, and will hold all of the effects
        self.effects = []
        
        #Initializes the Players with their own decks and placement order
        self.player1 = Player(self.hands[0], self.Deck1, self.spots[0], 0, 0)
        self.player2 = Player(self.hands[1], self.Deck2, self.spots[1], 1, 1)
        
        #Set each player as each others enemy
        self.player1.setEnemies(self.player2)
        #Set the current player
        self.currentPlayer = self.player2
        
    #############################    
    #    Get Statements         #
    #############################        
    def getSpots(self):
        return self.spots
    
    def getCurrentPlayer(self):
        return self.currentPlayer
    
    def getSpot(self,i,j):
        return self.spots[i][j]
    
    def getHands(self):
        return self.hands
    
    def getDecks(self):
        return self.Deck1, self.Deck2
    
    def getEffects(self):
        return self.effects()
    
    def getPlayer1(self):
        return self.player1
    
    def getPlayer2(self):
        return self.player2
    
    def getEnemyPlayer(self):
        return self.currentPlayer.getEnemy()
    
    
    # SimpleDecks randomly fills two decks with 30 cards from two
    # cardlists. This is primarily used for testing, as it can take
    # a long time to create 30 card decks every time you open the app
    # cards1/cards2 : List of Cards
    # player1/player2: Players 
    def simpleDecks(self, cards1, cards2, player1, player2):
        for i in range (30):
            shuffle(cards1)
            shuffle(cards2)
            newCard1 = cards1[0].copy()
            newCard1.setPlayer(player1)
            newCard2 = cards2[0].copy()
            newCard2.setPlayer(player2)
            self.Deck1.insertCard(newCard1)
            self.Deck2.insertCard(newCard2)
        return self.Deck1, self.Deck2
    

    # Adds effect eff to the list of current effects on the board 
    # eff : effect to be added  
    def addEffect(self, eff):
        self.effects.append(eff)
        

    #Triggers all effects that happen when a card is played
    # card: the card that is played
    def playedCreature(self, card):
        for eff in self.effects:
            eff.playCreature(card)
    
    #Triggers all effects that happen when a card dies
    # card: the card that died        
    def cardDeath(self, card):
        for eff in self.effects:
            eff.killCreature(card)
            
    #  Switches who's turn it is
    def switchCurrent(self):
        self.currentPlayer = self.currentPlayer.getEnemy()
        
    def onDamage(self, card):
        for eff in self.effects:
            print eff
#.........這裏部分代碼省略.........
開發者ID:defsnot-steve,項目名稱:PythonStone,代碼行數:103,代碼來源:Board.py


注:本文中的Deck.insertCard方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。