Exemple #1
0
 def _layerInit(self, scene):
     self.scene = scene
     
     hadCannons = False
     self.playerMap = {}
     for p in self.scene.app.players:
         if not p.inGame:
             continue
         self.playerMap[p] = FirePhaseData(self.scene.board)
         
     # Make sure anyone CAN fire.  Also, restore the health of all TileObjs.
     for t in self.scene.board.tileObjs:
         t.health = t.HEALTH
         if not isinstance(t, Cannon):
             continue
         
         tile = self.scene.board.get(t.x, t.y)
         if tile.isTerritory:
             self.playerMap[tile.owner].cannons.append(t)
             hadCannons = True
             
     if not hadCannons:
         # Skip this phase, go straight to rebuilding - no one had cannons!
         self.remove()
         # Avoid circular dependency here
         from rebuildLayer import RebuildLayer
         self.scene.addLayer(RebuildLayer())
         return
             
     self.hasUpdated = False # Wait for ticker to clear before firing
     GamePhaseLayer._layerInit(self, scene)
Exemple #2
0
 def _layerInit(self, scene):
     self.scene = scene
     
     # Players might build over there territory, so remove that so as not
     # to confuse whether or not a player can place any cannons
     self.scene.board.territoryCheck()
     
     baseCannons = 1
     if self.scene.isFirstRound:
         # Extra cannon for round one
         baseCannons = 2
     
     castlesPerPlayer = {}
     for p in self.scene.app.players:
         castlesPerPlayer[p] = 0
         
     for to in self.scene.board.tileObjs:
         if not isinstance(to, Castle):
             continue
         t = self.scene.board.get(to.x, to.y)
         if t.isTerritory:
             castlesPerPlayer[t.owner] += 1
      
     hadCannons = False
     self.placer = pyglet.sprite.Sprite(TileObjectImages.UNKNOWN)
     self.label = pyglet.text.Label(anchor_x = 'center', anchor_y = 'center')
     self.label.bold = True
     self.placeInfo = {}
     for p in self.scene.app.players:
         if p.inGame:
             self.placeInfo[p] = PlaceCannonInfo(p,
                     baseCannons + castlesPerPlayer[p])
             if not self._checkPlayerSpace(p):
                 self.placeInfo[p].numCannons = 0
             else:
                 hadCannons = True
     
     # No cannons to place?  Skip this phase
     if not hadCannons:
         self.remove()
         self.scene.addLayer(FirePhase())
         return
      
     GamePhaseLayer._layerInit(self, scene)