コード例 #1
0
ファイル: Field.py プロジェクト: sebastianHi/ubimedia
    def newFallingStone(self):
        
        if(self.thunderActivated):
            self.gameMenue.playSound("thunder")
            randomNumber = random.randint(0,13)
            for i in range(19):
                randomInc = random.randint(-1,1)
                if ((self.matrix[randomNumber][i] < 0) or (self.matrix[randomNumber][i] > 13)):
                    randomNumber += randomInc
                    if (randomNumber < 0):
                        randomNumber = 0
                    elif (randomNumber > 13):
                        randomNumber = 13
                    else:
                        pass
                else:
                    self.matrix[randomNumber][i] = False
                    if (self.matrixSteadyRectNodes[randomNumber][i] is not None):
                        (self.matrixSteadyRectNodes[randomNumber][i]).unlink()
                        self.matrixSteadyRectNodes[randomNumber][i] = None
                        randomNumber += randomInc
                        if (randomNumber < 0):
                            randomNumber = 0
                        elif (randomNumber > 13):
                            randomNumber = 13
                        else:
                            pass
                    else:
                        randomNumber += randomInc
                        if (randomNumber < 0):
                            randomNumber = 0
                        elif (randomNumber > 13):
                            randomNumber = 13
                        else:
                            pass
            self.thunderActivated = False
            block = self.newFallingStone()
            return block
             
        elif (self.bombActivated):
            
            bomb = BombBlock.BombBlock(self.gameMenue,self)
            a = self.checkSpawn("bomb")
            if (a):
                return bomb
            else:
                bomb.explode()
                
        elif (self.superBlock):
            a = self.checkSpawn("super")
            if (a):
                return superBlock.superBlock(self.gameMenue, self)
            else:
                if(self.id):
                    self.gameMenue.endeSpiel("Team 2 gewinnt")
                else:
                    self.gameMenue.endeSpiel("Team 1 gewinnt")

        ##if queue leer dann random sonst erstes element der queue
        elif not self.Queue:
            return self.generateRandomBlock()
        else:
            a = self.Queue.popleft()
            b = self.checkSpawn(a)
            if b:
                if (a == "cube"):
                    if(self.id == 1):
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],"cube")
                    else:
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],"cube")
                 
                    return cubeFallingBlock.cubeFallingBlock(self.gameMenue, self)
                elif (a == "I"):
                    if(self.id == 1):
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],"I")
                    else:
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],"I")
                 
                    
                    return IFallingBlock.IFallingBlock(self.gameMenue, self)
                elif (a== "L"):
                    if(self.id == 1):
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],"L")
                    else:
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],"L")
                 
                    
                    return LFallingBlock.LFallingBlock(self.gameMenue, self)
                elif (a == "Z"):
                    if(self.id == 1):
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],"Z")
                    else:
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],"Z")
                 
                    
                    return ZFallingBlock.ZFallingBlock(self.gameMenue, self)
                elif (a == "reverseL"):
                    if(self.id == 1):
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],"reverseL")
                    else:
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],"reverseL")
                 
                    
                    return reverseLFallingBlock.reverseLFallingBlock(self.gameMenue, self)
                elif (a == "reverseZ"):
                    if(self.id == 1):
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],"reverseZ")
                    else:
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],"reverseZ")
                 
                    
                    return reverseZFallingBlock.reverseZFallingBlock(self.gameMenue, self)
                elif (a == "cross"):
                    if(self.id == 1):
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],"cross")
                    else:
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],"cross")
                 
                    
                    return crossFallingBlock.crossFallingBlock(self.gameMenue,self)
                else:
                    pass
            else: 
                if(self.id == 1):
                    self.gameMenue.endeSpiel("Team 2 gewinnt")
                else:
                    self.gameMenue.endeSpiel("Team 1 gewinnt")
コード例 #2
0
ファイル: Field.py プロジェクト: sebastianHi/ubimedia
    def newFallingStone(self):

        if (self.thunderActivated):
            self.gameMenue.playSound("thunder")
            randomNumber = random.randint(0, 13)
            for i in range(19):
                randomInc = random.randint(-1, 1)
                if ((self.matrix[randomNumber][i] < 0)
                        or (self.matrix[randomNumber][i] > 13)):
                    randomNumber += randomInc
                    if (randomNumber < 0):
                        randomNumber = 0
                    elif (randomNumber > 13):
                        randomNumber = 13
                    else:
                        pass
                else:
                    self.matrix[randomNumber][i] = False
                    if (self.matrixSteadyRectNodes[randomNumber][i]
                            is not None):
                        (self.matrixSteadyRectNodes[randomNumber][i]).unlink()
                        self.matrixSteadyRectNodes[randomNumber][i] = None
                        randomNumber += randomInc
                        if (randomNumber < 0):
                            randomNumber = 0
                        elif (randomNumber > 13):
                            randomNumber = 13
                        else:
                            pass
                    else:
                        randomNumber += randomInc
                        if (randomNumber < 0):
                            randomNumber = 0
                        elif (randomNumber > 13):
                            randomNumber = 13
                        else:
                            pass
            self.thunderActivated = False
            block = self.newFallingStone()
            return block

        elif (self.bombActivated):

            bomb = BombBlock.BombBlock(self.gameMenue, self)
            a = self.checkSpawn("bomb")
            if (a):
                return bomb
            else:
                bomb.explode()

        elif (self.superBlock):
            a = self.checkSpawn("super")
            if (a):
                return superBlock.superBlock(self.gameMenue, self)
            else:
                if (self.id):
                    self.gameMenue.endeSpiel("Team 2 gewinnt")
                else:
                    self.gameMenue.endeSpiel("Team 1 gewinnt")

        ##if queue leer dann random sonst erstes element der queue
        elif not self.Queue:
            return self.generateRandomBlock()
        else:
            a = self.Queue.popleft()
            b = self.checkSpawn(a)
            if b:
                if (a == "cube"):
                    if (self.id == 1):
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],
                                              "cube")
                    else:
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],
                                              "cube")

                    return cubeFallingBlock.cubeFallingBlock(
                        self.gameMenue, self)
                elif (a == "I"):
                    if (self.id == 1):
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],
                                              "I")
                    else:
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],
                                              "I")

                    return IFallingBlock.IFallingBlock(self.gameMenue, self)
                elif (a == "L"):
                    if (self.id == 1):
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],
                                              "L")
                    else:
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],
                                              "L")

                    return LFallingBlock.LFallingBlock(self.gameMenue, self)
                elif (a == "Z"):
                    if (self.id == 1):
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],
                                              "Z")
                    else:
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],
                                              "Z")

                    return ZFallingBlock.ZFallingBlock(self.gameMenue, self)
                elif (a == "reverseL"):
                    if (self.id == 1):
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],
                                              "reverseL")
                    else:
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],
                                              "reverseL")

                    return reverseLFallingBlock.reverseLFallingBlock(
                        self.gameMenue, self)
                elif (a == "reverseZ"):
                    if (self.id == 1):
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],
                                              "reverseZ")
                    else:
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],
                                              "reverseZ")

                    return reverseZFallingBlock.reverseZFallingBlock(
                        self.gameMenue, self)
                elif (a == "cross"):
                    if (self.id == 1):
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],
                                              "cross")
                    else:
                        self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],
                                              "cross")

                    return crossFallingBlock.crossFallingBlock(
                        self.gameMenue, self)
                else:
                    pass
            else:
                if (self.id == 1):
                    self.gameMenue.endeSpiel("Team 2 gewinnt")
                else:
                    self.gameMenue.endeSpiel("Team 1 gewinnt")
コード例 #3
0
ファイル: Field.py プロジェクト: sebastianHi/ubimedia
    def generateRandomBlock(self):
        RandomNumber = random.randint(1,7)

        if (RandomNumber == 1):
            a = self.checkSpawn("cube")
            if a:
                if(self.id == 1):
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],"cube")
                else:
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],"cube")
                    
                return cubeFallingBlock.cubeFallingBlock(self.gameMenue, self)
            else:
                if(self.id == 1):
                    self.gameMenue.endeSpiel("Team 2 gewinnt")
                else:
                    self.gameMenue.endeSpiel("Team 1 gewinnt")
            
        elif (RandomNumber == 2):
            a = self.checkSpawn("I")
            if a:
                if(self.id == 1):
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],"I")
                else:
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],"I")
                    
                return IFallingBlock.IFallingBlock(self.gameMenue, self)
            else:
                if(self.id == 1):
                    self.gameMenue.endeSpiel("Team 2 gewinnt")
                else:
                    self.gameMenue.endeSpiel("Team 1 gewinnt")
          
        elif (RandomNumber == 3):
            a = self.checkSpawn("L")
            if a:
                if(self.id == 1):
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],"L")
                else:
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],"L")
                return LFallingBlock.LFallingBlock(self.gameMenue, self)
            else:
                if(self.id == 1):
                    self.gameMenue.endeSpiel("Team 2 gewinnt")
                else:
                    self.gameMenue.endeSpiel("Team 1 gewinnt")
            
        elif (RandomNumber == 4):
            a = self.checkSpawn("reverseL")
            if a:
                if(self.id == 1):
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],"reverseL")
                else:
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],"reverseL")
                    
                return reverseLFallingBlock.reverseLFallingBlock(self.gameMenue, self)
            else:
                if(self.id == 1):
                    self.gameMenue.endeSpiel("Team 2 gewinnt")
                else:
                    self.gameMenue.endeSpiel("Team 1 gewinnt")
            
        elif (RandomNumber == 5):
            a = self.checkSpawn("reverseZ")
            if a:
                if(self.id == 1):
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],"reverseZ")
                else:
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],"reverseZ")
                 
                return reverseZFallingBlock.reverseZFallingBlock(self.gameMenue, self)
            else:
                if(self.id == 1):
                    self.gameMenue.endeSpiel("Team 2 gewinnt")
                else:
                    self.gameMenue.endeSpiel("Team 1 gewinnt") 
            
        elif (RandomNumber == 6):
            a = self.checkSpawn("Z")
            if a:
                if(self.id == 1):
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],"Z")
                else:
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],"Z")
                 
                return ZFallingBlock.ZFallingBlock(self.gameMenue, self)
            else:
                if(self.id == 1):
                    self.gameMenue.endeSpiel("Team 2 gewinnt")
                else:
                    self.gameMenue.endeSpiel("Team 1 gewinnt")
        elif(RandomNumber == 7):
            a = self.checkSpawn("cross")
            if a: 
                if(self.id == 1):
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],"cross")
                else:
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],"cross")
                 
                return crossFallingBlock.crossFallingBlock(self.gameMenue, self)
            else:
                if(self.id == 1):
                    self.gameMenue.endeSpiel("Team 2 gewinnt")
                else:
                    self.gameMenue.endeSpiel("Team 1 gewinnt")
                     
        elif (RandomNumber == 8):
            self.specialsQueue.append("bomb")
            return crossFallingBlock.crossFallingBlock(self.gameMenue, self)
        
        elif (RandomNumber == 9):
            self.specialsQueue.append("rain")
            return ZFallingBlock.ZFallingBlock(self.gameMenue, self)
        
        elif (RandomNumber == 10):
            #self.specialsQueue.append("thunder")
            return reverseZFallingBlock.reverseZFallingBlock(self.gameMenue, self)
        
        else:
            #self.specialsQueue.append("super")
            return reverseLFallingBlock.reverseLFallingBlock(self.gameMenue, self)
コード例 #4
0
ファイル: Field.py プロジェクト: sebastianHi/ubimedia
    def generateRandomBlock(self):
        RandomNumber = random.randint(1, 7)

        if (RandomNumber == 1):
            a = self.checkSpawn("cube")
            if a:
                if (self.id == 1):
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],
                                          "cube")
                else:
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],
                                          "cube")

                return cubeFallingBlock.cubeFallingBlock(self.gameMenue, self)
            else:
                if (self.id == 1):
                    self.gameMenue.endeSpiel("Team 2 gewinnt")
                else:
                    self.gameMenue.endeSpiel("Team 1 gewinnt")

        elif (RandomNumber == 2):
            a = self.checkSpawn("I")
            if a:
                if (self.id == 1):
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0], "I")
                else:
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1], "I")

                return IFallingBlock.IFallingBlock(self.gameMenue, self)
            else:
                if (self.id == 1):
                    self.gameMenue.endeSpiel("Team 2 gewinnt")
                else:
                    self.gameMenue.endeSpiel("Team 1 gewinnt")

        elif (RandomNumber == 3):
            a = self.checkSpawn("L")
            if a:
                if (self.id == 1):
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0], "L")
                else:
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1], "L")
                return LFallingBlock.LFallingBlock(self.gameMenue, self)
            else:
                if (self.id == 1):
                    self.gameMenue.endeSpiel("Team 2 gewinnt")
                else:
                    self.gameMenue.endeSpiel("Team 1 gewinnt")

        elif (RandomNumber == 4):
            a = self.checkSpawn("reverseL")
            if a:
                if (self.id == 1):
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],
                                          "reverseL")
                else:
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],
                                          "reverseL")

                return reverseLFallingBlock.reverseLFallingBlock(
                    self.gameMenue, self)
            else:
                if (self.id == 1):
                    self.gameMenue.endeSpiel("Team 2 gewinnt")
                else:
                    self.gameMenue.endeSpiel("Team 1 gewinnt")

        elif (RandomNumber == 5):
            a = self.checkSpawn("reverseZ")
            if a:
                if (self.id == 1):
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],
                                          "reverseZ")
                else:
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],
                                          "reverseZ")

                return reverseZFallingBlock.reverseZFallingBlock(
                    self.gameMenue, self)
            else:
                if (self.id == 1):
                    self.gameMenue.endeSpiel("Team 2 gewinnt")
                else:
                    self.gameMenue.endeSpiel("Team 1 gewinnt")

        elif (RandomNumber == 6):
            a = self.checkSpawn("Z")
            if a:
                if (self.id == 1):
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0], "Z")
                else:
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1], "Z")

                return ZFallingBlock.ZFallingBlock(self.gameMenue, self)
            else:
                if (self.id == 1):
                    self.gameMenue.endeSpiel("Team 2 gewinnt")
                else:
                    self.gameMenue.endeSpiel("Team 1 gewinnt")
        elif (RandomNumber == 7):
            a = self.checkSpawn("cross")
            if a:
                if (self.id == 1):
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[0],
                                          "cross")
                else:
                    self.gui.sendMsgToOne(self.gui.lobbyMenu.playerIP[1],
                                          "cross")

                return crossFallingBlock.crossFallingBlock(
                    self.gameMenue, self)
            else:
                if (self.id == 1):
                    self.gameMenue.endeSpiel("Team 2 gewinnt")
                else:
                    self.gameMenue.endeSpiel("Team 1 gewinnt")

        elif (RandomNumber == 8):
            self.specialsQueue.append("bomb")
            return crossFallingBlock.crossFallingBlock(self.gameMenue, self)

        elif (RandomNumber == 9):
            self.specialsQueue.append("rain")
            return ZFallingBlock.ZFallingBlock(self.gameMenue, self)

        elif (RandomNumber == 10):
            #self.specialsQueue.append("thunder")
            return reverseZFallingBlock.reverseZFallingBlock(
                self.gameMenue, self)

        else:
            #self.specialsQueue.append("super")
            return reverseLFallingBlock.reverseLFallingBlock(
                self.gameMenue, self)