예제 #1
0
 def highlight_targets(self):
     old_highlighted = self.highlighted
     self.highlighted = []
     # Get targets
     targets = self.stack_gui.focused.ability.targets
     for t in targets:
         if not isinstance(t, MultipleTargets):
             t = [
                 t.get_targeted()
             ]  # or isinstance(t, AllPermanentTargets) or isinstance(t, AllPlayerTargets)): t = [t.target]
         else:
             t = t.get_targeted()
         for i, tt in enumerate(t):
             if tt == None:
                 continue  # For delayed targeting abilities, like champion
             if isPlayer(tt):
                 for status in [self.window.mainplayer_status, self.window.otherplayer_status]:
                     if tt == status.player:
                         status.animate("life")
             elif isPermanent(tt):
                 for play in [self.window.mainplay, self.window.otherplay]:
                     guicard = play.get_card(tt)
                     if guicard:
                         self.highlighted.append(guicard)
                         if guicard in old_highlighted:
                             old_highlighted.remove(guicard)
                         guicard.highlight()
             # elif isStackAbility(tt):
             #    guicard = self.stack_gui.get_card(tt)
             #    if guicard:
             #        self.highlighted.append(guicard)
             #        if guicard in old_highlighted: old_highlighted.remove(guicard)
             #        guicard.highlight()
     for obj in old_highlighted:
         obj.unhighlight()
예제 #2
0
 def card_damage(self, sender, to, amount):
     if not isPlayer(to):
         zone = self.play_zones[to.controller]
         guicard = zone.get_card(to)
         start_pos = self.project_to_window(*tuple(zone.pos+guicard.pos))+euclid.Vector3(0,10,0)
         end_pos = start_pos + euclid.Vector3(0,40,0)
         self.sparks.add_number_spark(amount, start_pos, end_pos, color=(1,0,0,1), dt=1.0, dim=2)
예제 #3
0
    def get(self, source):
        if isinstance(self.selector, str):
            if self.selector == "opponent": selector = source.controller.choose_opponent()
            elif self.selector == "active_player":
                import engine.GameKeeper
                selector = engine.GameKeeper.Keeper.active_player
            else: selector = source.controller
        if isPlayer(self.selector): selector = self.selector
        else: selector = source.controller
        i = 0
        targets = []
        while i < self.number:
            target = selector.getTarget(self.target_types,zone=self.zone,from_player=self.player,required=False,prompt=self.get_prompt(i, source.name))
            if target == False:
                if not self.up_to or len(targets) == 0: return False
                else: break
            elif target.canBeTargetedBy(source) and not target in targets:
                targets.append(target)
                i += 1
            else: selector.send(InvalidTargetEvent(), target=target)

        # Now distribute among them if we need to
        if self.distribute > 0:
            self.distribution = selector.getDistribution(amount=self.distribute, targets=targets, prompt="Distribute %d %s among targets"%(self.distribute, self.distribute_type))

        # Got our targets, now save info:
        for target in targets:
            target.isTargetedBy(source)
        self.target = targets
        return True
예제 #4
0
 def effects(controller, source):
     yield NoTarget()
     if not isPlayer(source.opponent):
         opponent = source.opponent.controller
     else:
         opponent = source.opponent
     opponent.force_sacrifice(number=number)
     yield
예제 #5
0
 def check_target(self, source):
     # Remove any targets no longer in the correct zone, or no longer matching the original condition
     final_targets = []
     for target in self.target:
         if (not isinstance(target, InvalidTarget) and
            (isPlayer(target) or not target.is_LKI) and
            self.match_type(target) and
            target.canBeTargetedBy(source)): final_targets.append(target)
         else: final_targets.append(InvalidTarget(target))
     self.target = final_targets
     return len(self.target) == 0 or any([True for target in self.target if not isinstance(target, InvalidTarget)])
예제 #6
0
 def card_damage(self, sender, to, amount):
     if not isPlayer(to):
         zone = self.play_zones[to.controller]
         guicard = zone.get_card(to)
         start_pos = self.project_to_window(
             *tuple(zone.pos + guicard.pos)) + euclid.Vector3(0, 10, 0)
         end_pos = start_pos + euclid.Vector3(0, 40, 0)
         self.sparks.add_number_spark(amount,
                                      start_pos,
                                      end_pos,
                                      color=(1, 0, 0, 1),
                                      dt=1.0,
                                      dim=2)
예제 #7
0
 def targeted_by(self, sender, targeter):
     color =  (0.5,0.71,0.94, 1.0)
     dt = 2.0
     if isPlayer(sender):
         pstatus = self.player_status[sender]
         avatar = pstatus.avatar
         pos = pstatus.pos + avatar.pos
         self.sparks.add_star_spark(pos, pos, dt=dt, color=color, dim=2)
     if isPermanent(sender):
         zone = self.play_zones[sender.controller]
         guicard = zone.get_card(sender)
         start_pos = self.project_to_window(*tuple(zone.pos+guicard.pos))
         self.sparks.add_star_spark(start_pos, start_pos, dt=dt, color=color, dim=2)
예제 #8
0
 def invalid_target(self, sender, target):
     if isPlayer(target):
         pstatus = self.player_status[target]
         avatar = pstatus.avatar
         if avatar.shaking == 0:
             avatar.shaking = 1
             avatar._pos.set_transition(dt=0.25, method=lambda t: anim.oscillate_n(t, 4))
             avatar.pos += euclid.Vector3(10, 0, 0)
             clock.schedule_once(lambda t: setattr(avatar, "shaking", 0), 0.5)
     elif isPermanent(target):
         zone = self.play_zones[target.controller]
         guicard = zone.get_card(target)
         guicard.shake()
         clock.schedule_once(lambda t: guicard.unshake(), 0.25)
예제 #9
0
    def get_prompt(self, curr, source):
        number = self.number-curr
        if curr > 0: another = "another "
        else: another = ""
        if self.up_to: another = "up to "+another

        if self.zone == "battlefield":
            if isPlayer(self.player): zl = " %s controls"%self.player
            elif self.player == None: zl = ""
            elif self.player == "you": zl = " you control"
            else: zl = " opponent controls"
        else:
            if isPlayer(self.player): zl = " in %s's %s"%(self.player, self.zone)
            elif self.player == None: zl = " in any %s"%self.zone
            elif self.player == "you": zl = " in your %s"%self.zone
            else: zl = " in opponent's %s"%self.zone

        if self.msg:
            if curr <= len(self.msg): prompt=self.msg[curr]
            else: prompt = self.msg[-1]
        elif self.target_types: prompt="Target %s%d %s(s) %s for %s"%(another,number, ' or '.join([str(t) for t in self.target_types]),zl,source)
        else: prompt = "Select %s%d target(s) %s for %s"%(another,number,zl,source)
        return prompt
예제 #10
0
 def invalid_target(self, sender, target):
     if isPlayer(target):
         pstatus = self.player_status[target]
         avatar = pstatus.avatar
         if avatar.shaking == 0:
             avatar.shaking = 1
             avatar._pos.set_transition(
                 dt=0.25, method=lambda t: anim.oscillate_n(t, 4))
             avatar.pos += euclid.Vector3(10, 0, 0)
             clock.schedule_once(lambda t: setattr(avatar, "shaking", 0),
                                 0.5)
     elif isPermanent(target):
         zone = self.play_zones[target.controller]
         guicard = zone.get_card(target)
         guicard.shake()
         clock.schedule_once(lambda t: guicard.unshake(), 0.25)
예제 #11
0
 def targeted_by(self, sender, targeter):
     color = (0.5, 0.71, 0.94, 1.0)
     dt = 2.0
     if isPlayer(sender):
         pstatus = self.player_status[sender]
         avatar = pstatus.avatar
         pos = pstatus.pos + avatar.pos
         self.sparks.add_star_spark(pos, pos, dt=dt, color=color, dim=2)
     if isPermanent(sender):
         zone = self.play_zones[sender.controller]
         guicard = zone.get_card(sender)
         start_pos = self.project_to_window(*tuple(zone.pos + guicard.pos))
         self.sparks.add_star_spark(start_pos,
                                    start_pos,
                                    dt=dt,
                                    color=color,
                                    dim=2)
예제 #12
0
 def highlight_targets(self):
     old_highlighted = self.highlighted
     self.highlighted = []
     # Get targets
     targets = self.stack_gui.focused.ability.targets
     for t in targets:
         if not isinstance(t, MultipleTargets):
             t = [
                 t.get_targeted()
             ]  #or isinstance(t, AllPermanentTargets) or isinstance(t, AllPlayerTargets)): t = [t.target]
         else:
             t = t.get_targeted()
         for i, tt in enumerate(t):
             if tt == None:
                 continue  # For delayed targeting abilities, like champion
             if isPlayer(tt):
                 for status in [
                         self.window.mainplayer_status,
                         self.window.otherplayer_status
                 ]:
                     if tt == status.player:
                         status.animate("life")
             elif isPermanent(tt):
                 for play in [self.window.mainplay, self.window.otherplay]:
                     guicard = play.get_card(tt)
                     if guicard:
                         self.highlighted.append(guicard)
                         if guicard in old_highlighted:
                             old_highlighted.remove(guicard)
                         guicard.highlight()
             #elif isStackAbility(tt):
             #    guicard = self.stack_gui.get_card(tt)
             #    if guicard:
             #        self.highlighted.append(guicard)
             #        if guicard in old_highlighted: old_highlighted.remove(guicard)
             #        guicard.highlight()
     for obj in old_highlighted:
         obj.unhighlight()
예제 #13
0
 def canBeBlocked(self):
     if isPlayer(self.opponent): other_battlefield = self.opponent.battlefield
     else: other_battlefield = self.opponent.controller.battlefield # planeswalker
     return len(other_battlefield.get(isLand.with_condition(condition))) == 0
예제 #14
0
 def check_target(self, source):
     # Make sure the target is still in the correct zone (only for cards (and tokens), not players) and still matches original condition
     if not isPlayer(self.target):
         self.is_valid = (not self.target.is_LKI and self.match_types(self.target) and self.target.canBeTargetedBy(source))
     else: self.is_valid = self.target.canBeTargetedBy(source)
     return self.is_valid
예제 #15
0
 def dealt(self, sender, to, amount, combat):
     if combat and isPlayer(to):
         self.prowl_damage.add((sender.controller, set(sender.subtypes)))