Exemple #1
0
 def play(self, game, effectTypesToIgnore=[]):
     """ Play the card and perform any effects """
     context = PlayerContext(game, self)
     coroutine = PerformEffects(self.playEffects, context, effectTypesToIgnore=effectTypesToIgnore)
     response = yield coroutine.next()
     while True:
         response = yield coroutine.send(response)
Exemple #2
0
 def performEffects(self, context):
     """ Perform the Game Effect """
     possibleCardsPerZone = self.findPossibleCards(context)
     possibleCards = [card for cards in possibleCardsPerZone.values() for card in cards]
     
     if len(possibleCards) != 0:
         cards = None
         if len(possibleCards) == self.numberOfCards and self.AUTO_PICK:
             cards = possibleCards
         else:
             cards = yield self.buildRequest(possibleCards, context)
             
         event = self.buildEvent(cards, possibleCardsPerZone, context)
     
     coroutine = ConditionalEffect.performEffects(self, event.context)
     try:
         response = yield coroutine.next()
         while True:
             response = yield coroutine.send(response)
     except StopIteration:
         pass
     
     coroutine = PerformEffects(self.leftoverCardEffects, self.buildEvent([card for card in possibleCards if card not in cards], possibleCardsPerZone, context).context)
     try:
         response = yield coroutine.next()
         while True:
             response = yield coroutine.send(response)
     except StopIteration:
         pass
Exemple #3
0
    def performEffects(self, context):
        """ Perform the Game Effect """
        possibleCardsPerZone = self.findPossibleCards(context)
        possibleCards = [
            card for cards in possibleCardsPerZone.values() for card in cards
        ]

        if len(possibleCards) != 0:
            cards = None
            if len(possibleCards) == self.numberOfCards and self.AUTO_PICK:
                cards = possibleCards
            else:
                cards = yield self.buildRequest(possibleCards, context)

            event = self.buildEvent(cards, possibleCardsPerZone, context)

        coroutine = ConditionalEffect.performEffects(self, event.context)
        try:
            response = yield coroutine.next()
            while True:
                response = yield coroutine.send(response)
        except StopIteration:
            pass

        coroutine = PerformEffects(
            self.leftoverCardEffects,
            self.buildEvent(
                [card for card in possibleCards if card not in cards],
                possibleCardsPerZone, context).context)
        try:
            response = yield coroutine.next()
            while True:
                response = yield coroutine.send(response)
        except StopIteration:
            pass
Exemple #4
0
 def requestDefenses(self, context):
     """ Request defenses to determine who the targets are """
     self.targets = []
     self.failedAttacks = []
     for foe in context.foes:
         request = DefendRequest(context.parent, context.getPlayerContext(foe))
         defended = yield request
         if not defended:
             self.targets.append(foe)
             context.addNotification(Notification(HIT_BY_ATTACK, foe))
         else:
             self.failedAttacks.append(True)
             context.addNotification(CardsNotification(DEFENDED, foe, [defended]))
             playerContext = context.getPlayerContext(foe)
             
             coroutine = context.owner.ongoingEffects.send(DefendEvent(defended, playerContext))
             try:
                 response = yield coroutine.next()
                 while True:
                     response = yield coroutine.send(response)
             except StopIteration:
                 pass
             
             zone = playerContext.loadZone(request.findZoneFor(defended))
             event = CardsEvent([defended], zone, playerContext)
             coroutine = PerformEffects(defended.defenseEffects, event.context)
             try:
                 response = yield coroutine.next()
                 while True:
                     response = yield coroutine.send(response)
             except StopIteration:
                 pass
    def perform(self, context):
        """ Perform the Game Effect """
        newContext = context.getPlayerContext(context.previousPlayer)

        coroutine = PerformEffects(self.thenEffects, newContext)
        response = yield coroutine.next()
        while True:
            response = yield coroutine.send(response)
Exemple #6
0
 def attackTargets(self, context):
     """ Attack the Targets """
     context = context.copy()
     context.foes = self.targets
     coroutine = PerformEffects(self.thenEffects, context)
     response = yield coroutine.next()
     while True:
         response = yield coroutine.send(response)
 def performFirstAppearanceEffects(self, game):
     """ Perform the Super Villain's First Appearance Effects """
     if self.hasAppeared:
         self.hasAppeared = False
         coroutine = PerformEffects(self.topCard.appearanceEffects, SystemContext(game, self.topCard))
         response = yield coroutine.next()
         while True:
             response = yield coroutine.send(response)
 def perform(self, context):
     """ Perform the Game Effect """
     newContext = context.getPlayerContext(context.previousPlayer)
     
     coroutine = PerformEffects(self.thenEffects, newContext)
     response = yield coroutine.next()
     while True:
         response = yield coroutine.send(response)
Exemple #9
0
 def performFirstAppearanceEffects(self, game):
     """ Perform the Super Villain's First Appearance Effects """
     if self.hasAppeared:
         self.hasAppeared = False
         coroutine = PerformEffects(self.topCard.appearanceEffects,
                                    SystemContext(game, self.topCard))
         response = yield coroutine.next()
         while True:
             response = yield coroutine.send(response)
Exemple #10
0
 def gainCard(self, card, fromZone, toZone=None, game=None):
     """ Gain the provided card """
     fromZone.remove(card)
     toZone.add(card)
     event = CardsEvent([card], toZone, PlayerContext(game, card, player=self))
     coroutine = PerformEffects(card.onGainEffects, event.context)
     response = yield coroutine.next()
     while True:
         response = yield coroutine.send(response)
Exemple #11
0
 def play(self, game, effectTypesToIgnore=[]):
     """ Play the card and perform any effects """
     context = PlayerContext(game, self)
     coroutine = PerformEffects(self.playEffects,
                                context,
                                effectTypesToIgnore=effectTypesToIgnore)
     response = yield coroutine.next()
     while True:
         response = yield coroutine.send(response)
Exemple #12
0
 def perform(self, context):
     """ Perform the Game Effect """
     zone = context.loadZone(self.zoneType)
     possibleCards = self.filter.evaluate(context)
             
     event = CardsEvent(possibleCards, zone, context)
     coroutine = PerformEffects(self.thenEffects, event.context)
     response = yield coroutine.next()
     while True:
         response = yield coroutine.send(response)
Exemple #13
0
 def gainCard(self, card, fromZone, toZone=None, game=None):
     """ Gain the provided card """
     fromZone.remove(card)
     toZone.add(card)
     event = CardsEvent([card], toZone,
                        PlayerContext(game, card, player=self))
     coroutine = PerformEffects(card.onGainEffects, event.context)
     response = yield coroutine.next()
     while True:
         response = yield coroutine.send(response)
Exemple #14
0
    def perform(self, context):
        """ Perform the Game Effect """
        zone = context.loadZone(self.zoneType)
        possibleCards = self.filter.evaluate(context)

        event = CardsEvent(possibleCards, zone, context)
        coroutine = PerformEffects(self.thenEffects, event.context)
        response = yield coroutine.next()
        while True:
            response = yield coroutine.send(response)
    def perform(self, context):
        """ Perform the Game Effect """
        players = self.findHighestCostPlayers(context)

        if len(players) == 1:
            player = players[0]
            newContext = context.getPlayerContext(player)

            coroutine = PerformEffects(self.thenEffects, newContext)
            response = yield coroutine.next()
            while True:
                response = yield coroutine.send(response)
 def perform(self, context):
     """ Perform the Game Effect """
     players = self.findHighestCostPlayers(context)
     
     if len(players) == 1:
         player = players[0]
         newContext = context.getPlayerContext(player)
         
         coroutine = PerformEffects(self.thenEffects, newContext)
         response = yield coroutine.next()
         while True:
             response = yield coroutine.send(response)
Exemple #17
0
 def activate(self, context):
     """ Activate the effect """
     if self.singleUse:
         context.owner.unregisterActivatable(context.parent, self)
     
     coroutine = PerformEffects(self.effects, context)
     try:
         response = yield coroutine.next()
         while True:
             response = yield coroutine.send(response)
     except StopIteration:
         pass
 def perform(self, context):
     """ Perform the Game Effect """
     players = self.findHighestCostPlayers(context)
     
     for player in players:
         newContext = context.getPlayerContext(player)
         
         coroutine = PerformEffects(self.thenEffects, newContext)
         try:
             response = yield coroutine.next()
             while True:
                 response = yield coroutine.send(response)
         except StopIteration:
             pass
Exemple #19
0
    def perform(self, context):
        """ Perform the Game Effect """
        typeToFunction = {TOP: self.getTopCards, PICK: self.pickCards}
        function = typeToFunction[self.pickType]

        self.cardsForFoes = []
        zones = []
        for foe in context.foes:
            playerContext = context.getPlayerContext(foe)
            zone = playerContext.loadZone(self.zoneType)
            coroutine = RunCoroutineOrFunction(
                function, [playerContext, zone, self.number])
            try:
                response = yield coroutine.next()
                while True:
                    response = yield coroutine.send(response)
            except StopIteration:
                pass
            event = CardsEvent(self.cardsForFoes, zone, playerContext)
            zones.append(EventZone(event))

        event = MultiZoneEvent(zones, context)
        coroutine = PerformEffects(self.thenEffects, event.context)
        response = yield coroutine.next()
        while True:
            response = yield coroutine.send(response)
    def perform(self, context):
        """ Perform the Game Effect """
        coroutine = Attack.perform(self, context)
        try:
            response = yield coroutine.next()
            while True:
                response = yield coroutine.send(response)
        except StopIteration:
            pass

        self.failedAttacks += self.perFoeEffect.failedEffects
        if any(self.failedAttacks):
            coroutine = PerformEffects(self.anyFailedEffects, context)
            response = yield coroutine.next()
            while True:
                response = yield coroutine.send(response)
Exemple #21
0
 def perform(self, context):
     """ Perform the Game Effect """
     coroutine = Attack.perform(self, context)
     try:
         response = yield coroutine.next()
         while True:
             response = yield coroutine.send(response)
     except StopIteration:
         pass
     
     self.failedAttacks += self.perFoeEffect.failedEffects
     if any(self.failedAttacks):
         coroutine = PerformEffects(self.anyFailedEffects, context)
         response = yield coroutine.next()
         while True:
             response = yield coroutine.send(response)
Exemple #22
0
    def perform(self, context):
        """ Perform the Game Effect """
        totalCost = 0
        while totalCost < self.cost:
            zone = context.loadZone(DECK)
            if zone.availableLength() > 0:
                card = zone[0]
                totalCost += card.cost

                coroutine = PerformEffects([self.lookAtTop, Draw(1)], context)
                try:
                    response = yield coroutine.next()
                    while True:
                        response = yield coroutine.send(response)
                except StopIteration:
                    pass
            else:
                break
Exemple #23
0
 def perform(self, context):
     """ Perform the Game Effect """
     totalCost = 0
     while totalCost < self.cost:
         zone = context.loadZone(DECK)
         if zone.availableLength() > 0:
             card = zone[0]
             totalCost += card.cost
         
             coroutine = PerformEffects([self.lookAtTop, Draw(1)], context)
             try:
                 response = yield coroutine.next()
                 while True:
                     response = yield coroutine.send(response)
             except StopIteration:
                 pass
         else:
             break
 def perform(self, context):
     """ Perform the Game Effect """
     coroutine = PerformEffects(self.effects, context)
     response = yield coroutine.next()
     while True:
         response = yield coroutine.send(response)
Exemple #25
0
 def performEffects(self, context):
     """ Perform the Option's Effects """
     coroutine = PerformEffects(self.effects, context)
     response = yield coroutine.next()
     while True:
         response = yield coroutine.send(response)