def begin(self, playerTrainer, oppTrainer):
     """ Starts showing the Battle Screen and initializes the Battle """
     self.battle = Battle(playerTrainer, oppTrainer)
     self.screen = ConsoleBattleScreen(self.battle)
     
     # Set the Player Trainer to use the screen
     playerTrainer.screen = self.screen
     
     # Introduce the Battle Environment
     self.screen.introduce()
     messages = self.battle.sendOutPkmnToStart()
     self.screen.reportMessages(messages)
     
     # Start the Game Loop
     self.gameLoop()
class BattleViewController:
    """ Controls the interaction between the visible Screen and a battle 
    between two Trainers """
    
    def __init__(self):
        """  """
        
        
    def begin(self, playerTrainer, oppTrainer):
        """ Starts showing the Battle Screen and initializes the Battle """
        self.battle = Battle(playerTrainer, oppTrainer)
        self.screen = ConsoleBattleScreen(self.battle)
        
        # Set the Player Trainer to use the screen
        playerTrainer.screen = self.screen
        
        # Introduce the Battle Environment
        self.screen.introduce()
        messages = self.battle.sendOutPkmnToStart()
        self.screen.reportMessages(messages)
        
        # Start the Game Loop
        self.gameLoop()
        
    def gameLoop(self):
        """ Runs through one iteration if the game """
        while not self.battle.over:
            # Pick action
            #actions = self.battle.getActionsInOrder()
            #self.performActions(actions)
            #messages = self.battle.refillSides()
            #self.screen.reportAction(messages)
            messageQueue = self.battle.performRound()
            while len(messageQueue) > 0:
                messages = messageQueue.popleft()
                self.screen.reportAction(messages)
                
            messages = self.battle.refillSides()
            self.screen.reportAction(messages)
                    
    def performActions(self, actions):
        """ Perform all the given actions """
        for action in actions:
            messages = []
            messages += self.battle.act(action)
            messages += self.battle.afterTurn(action.user)
            
            self.screen.reportAction(messages)
            
        self.battle.betweenRounds()
        
    def checkOver(self):
        """ Checks if the Battle is over """
        return self.battle.over
        
예제 #3
0
 def __init__(self, playerTrainer, oppTrainer):
     """ Builds the Battle Controller """
     self.battle = Battle(playerTrainer, oppTrainer)
     screen = BattleScreen(self.battle)
     PygameController.__init__(self, screen)