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


Python Team.addSnails方法代碼示例

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


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

示例1: addTeam

# 需要導入模塊: from team import Team [as 別名]
# 或者: from team.Team import addSnails [as 別名]
 def addTeam(self, name, numberOfSnails, gravity_direction):
     """
     Add a team to the game
     @param name: The name of the team
     @param numberOfSnails: The amount of snails the team has
     @param gravity_direction: The gravity direction of the team
     """
     team = Team(name)
     team.setGravity(gravity_direction)
     team.addSnails(numberOfSnails)
     team.setTeamImage((gravity_direction+1))
     self.teams.append(team)
開發者ID:ryuken,項目名稱:gravity-snails,代碼行數:14,代碼來源:game.py

示例2: TestTeam

# 需要導入模塊: from team import Team [as 別名]
# 或者: from team.Team import addSnails [as 別名]
class TestTeam(unittest.TestCase):
    """
    A test class for the Team module.
    """

    def setUp(self):
        """
        set up data used in the tests.
        setUp is called before each test function execution.
        """        
        self.maxSnails = 3
        self.team1 = Team("team1")
        self.team2 = Team("team2")
        self.team1.setGravity(Direction.UP)
        self.team2.setGravity(Direction.DOWN)
        
    def testInitialized(self):
        """
        Test if init goes good
        """
        self.assertEqual(self.team1.name, "team1")
        self.assertEqual(self.team1.hasTurn, False)
    
    def testAddSnails(self):
        self.team1.addSnails(self.maxSnails)
        self.assertEquals(self.team1.currentSnailWithTurn, self.team1.orderedSnailList[0])
        self.assertEqual(len(self.team1.sprites()), self.maxSnails)
        self.assertEqual(len(self.team1.orderedSnailList), self.maxSnails)
        self.assertEqual(self.team1.orderedSnailList[0].hasTurn, True)
        for i in range(0, len(self.team1.orderedSnailList)):
            if i == 0:
                self.assertEqual(self.team1.orderedSnailList[i].hasTurn, True)
            else:
                self.assertEqual(self.team1.orderedSnailList[i].hasTurn, False)
        
    def testNextSnailTurn(self):
        """
        Test if the next time get's the turn
        """
        # test if the currentSnailTurn is 0
        self.team1.addSnails(self.maxSnails)
        
        # Check when all the snails had the turn, if the first snail gets turn again
        for i in range(0, self.maxSnails):
            print i
            self.assertEqual(self.team1.orderedSnailList[i].hasTurn, True)
            self.team1.nextSnailTurn()
            self.assertEqual(self.team1.orderedSnailList[i].hasTurn, False)
            
            
        # check if the first snail in the list has the turn again
        self.assertEqual(self.team1.orderedSnailList[0].hasTurn, True)
開發者ID:ryuken,項目名稱:gravity-snails,代碼行數:54,代碼來源:unittest_team.py

示例3: TestTimer

# 需要導入模塊: from team import Team [as 別名]
# 或者: from team.Team import addSnails [as 別名]
class TestTimer(unittest.TestCase):
    """
    A test class for the Timer module.
    """

    def setUp(self):
        """
        set up data used in the tests.
        setUp is called before each test function execution.
        """
        self.teams= []
        self.team1 = Team("team1")
        self.team2 = Team("team2")
        pygame.init()
        self.team1.addSnails(2)
        self.team2.addSnails(3)

        self.teams.append(self.team1)
        self.teams.append(self.team2)

        self.turnManager = TurnManager()
        self.turnManager.setTeams(self.teams)

#    def testInitialized(self):
#        """
#        Test if init goes good
#        """
#        self.assertEqual(self.turnManager.teams, self.teams)
#        self.assertEqual(self.turnManager.teams[0], self.team1)
#        self.assertEqual(self.turnManager.teams[1], self.team2)
#
#        self.assertEqual(self.turnManager.status, TurnStatus.BREAK)
#        self.assertEqual(self.turnManager.startTime, Settings.TIMER_STARTTIME)
#        self.assertEqual(self.turnManager.size, Settings.TIMER_SIZE)
#        self.assertEqual(self.turnManager.position, Settings.TIMER_POSITION)
#        self.assertEqual(self.turnManager.font_size, Settings.TIMER_FONT_SIZE)

    def testSingleton(self):
        """
        Test if the singleton works
        """
        turnmanager2 = TurnManager()
        self.assertEqual(id(self.turnManager), id(turnmanager2))
開發者ID:ryuken,項目名稱:gravity-snails,代碼行數:45,代碼來源:unittest_timerquick.py

示例4: TestWeapon

# 需要導入模塊: from team import Team [as 別名]
# 或者: from team.Team import addSnails [as 別名]
class TestWeapon(unittest.TestCase):
    """
    A test class for the Weapon module.
    """

    def setUp(self):
        """
        set up data used in the tests.
        setUp is called before each test function execution.
        """        
        self.turnManager = TurnManager()
        self.teams = []
        
        self.team = Team("Akatsuki")
        self.team.addSnails(1)
        self.teams.append(self.team)
        
        self.turnManager.setTeams(self.teams)
        
        self.snail = None
        for snail in self.team.sprites():
            self.snail = snail
        
        self.weapon = Weapon("Canon", 20)
        self.weapon.ammo = 5
        
        
    def testInitialized(self):
        """
        Test if init goes good
        """
        self.assertEqual(self.weapon.name, "Canon")
        self.assertEqual(self.weapon.power, 20)
        self.assertEqual(self.weapon.ammo, 5)
        
    def testShoot(self):
        self.weapon.shoot()
        self.assertEqual(self.weapon.ammo, 4)
開發者ID:ryuken,項目名稱:gravity-snails,代碼行數:40,代碼來源:unittest_weapon.py

示例5: TestTimer

# 需要導入模塊: from team import Team [as 別名]
# 或者: from team.Team import addSnails [as 別名]
class TestTimer(unittest.TestCase):
    """
    A test class for the Timer module.
    """

    def setUp(self):
        """
        set up data used in the tests.
        setUp is called before each test function execution.
        """
        pygame.init()
        self.teams= []
        self.team1 = Team("team1")
        self.team2 = Team("team2")

        self.team1.addSnails(3)
        self.team2.addSnails(3)

        self.teams.append(self.team1)
        self.teams.append(self.team2)

        self.turnManager = TurnManager()
        self.turnManager.setTeams(self.teams)

    def testInitialized(self):
        """
        Test if init goes good
        """
        self.assertEqual(self.turnManager.teams, self.teams)
        self.assertEqual(self.turnManager.teams[0], self.team1)
        self.assertEqual(self.turnManager.teams[1], self.team2)

        self.assertEqual(self.turnManager.status, TurnStatus.BREAK)
        self.assertEqual(self.turnManager.startTime, Settings.TIMER_STARTTIME)
        self.assertEqual(self.turnManager.size, Settings.TIMER_SIZE)
        self.assertEqual(self.turnManager.position, Settings.TIMER_POSITION)
        self.assertEqual(self.turnManager.font_size, Settings.TIMER_FONT_SIZE)

    def testSingleton(self):
        """
        Test if the singleton works
        """
        turnmanager2 = TurnManager()
        self.assertEqual(id(self.turnManager), id(turnmanager2))
        self.assertEqual(self.turnManager._instance, turnmanager2._instance)

    def testTimer(self):
        """
        Test if the turnManager's status switches from CurrentTurn to Break when counter is 0
        """
        self.assertEqual(self.turnManager.status, TurnStatus.BREAK)
        #print self.turnManager.started
        self.turnManager.startTimer()

        time.sleep(Settings.TIMER_BREAKTIME + 2)

        self.assertEqual(self.turnManager.status, TurnStatus.CURRENTTURN)

        time.sleep(Settings.TIMER_STARTTIME + 2)
        self.assertEqual(self.turnManager.status, TurnStatus.BREAK)
        self.turnManager.stopTimer()

    def testCurrentTurn(self):
        """
        Test if the turnManager's status switches from Break to CurrentTurn when counter is 0
        """
        self.assertEqual(self.turnManager.status, TurnStatus.BREAK)
        #print self.turnManager.started
        self.turnManager.startTimer()

        time.sleep(Settings.TIMER_BREAKTIME + 1)

        self.assertEqual(self.turnManager.status, TurnStatus.CURRENTTURN)
        self.turnManager.stopTimer()
    
    def testChangeTurn(self):
        self.assertEqual(self.team1.hasTurn, True)
        self.turnManager.changeTurn()
        self.assertEqual(self.team1.hasTurn, False)
        self.assertEqual(self.team2.hasTurn, True)
        se


    def testChangeTurnTeam(self):
        """
        Test if the next time get's the turn
        """
        self.turnManager.startTimer()
        self.assertEqual(self.turnManager.teams[0].hasTurn, True)

        time.sleep(Settings.TIMER_BREAKTIME + Settings.TIMER_STARTTIME + 5)

        self.assertEqual(self.turnManager.teams[0].hasTurn, False)
        self.assertEqual(self.turnManager.teams[1].hasTurn, True)
        self.turnManager.stopTimer()


    def testChangeTurnSnail(self):
        """
        Test if the next snail get's the turn
#.........這裏部分代碼省略.........
開發者ID:ryuken,項目名稱:gravity-snails,代碼行數:103,代碼來源:unittest_timer.py


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