示例#1
0
    def effects(controller, source):
        yield cost
        yield NoTarget()
        source = source.move_to(controller.battlefield)
        yield
        source.abilities.add(haste())

        # Exile at end of turn
        @source.delayed
        def ability():
            def condition(source):
                return str(source.zone) == "battlefield"

            def effects(controller, source):
                '''Exile this from the game at end of turn'''
                yield NoTarget()
                source.move_to("exile")
                yield

            return PhaseTrigger(EndTurnStepEvent(), condition), effects

        # Exile if it leaves play
        leave_battlefield_condition = lambda self, zone, position="top": str(
            self.zone) == "battlefield"

        def move_to(self, zone, position="top"):
            return self.move_to("exile")

        until_end_of_turn(
            do_replace(source,
                       "move_to",
                       move_to,
                       condition=leave_battlefield_condition,
                       msg="%s - exile from game" % source.name))
        yield
示例#2
0
def redirect_damage(from_target, to_target, amount, next=True, txt='', condition=None):
    if not txt:
        txt = 'Redirect %s%s damage from %s to %s'%("the next " if next else '', str(amount) if not amount == -1 else "all", from_target, to_target)
    def redirectDamage(self, amt, source, combat=False):
        dmg = 0
        if redirectDamage.curr_amt != -1:
            if next:
                redirected = min([amt,redirectDamage.curr_amt])
                redirectDamage.curr_amt -= amt
                if redirectDamage.curr_amt <= 0:
                    dmg = self.assignDamage(-1*redirectDamage.curr_amt, source, combat)
                    redirectDamage.curr_amt = 0
                    redirectDamage.expire()
            else:
                redirected = redirectDamage.curr_amt
                amt -= redirectDamage.curr_amt
                if amt > 0: dmg = self.assignDamage(amt, source, combat)
        else:
            redirected = amt
        # XXX Make sure the target is on the battlefield, otherwise the damage isn't redirected
        dmg += to_target.assignDamage(redirected, source, combat)
        #self.send(DamageRedirectedEvent(),amt=redirected)
        return dmg
    redirectDamage.curr_amt = amount
    return do_replace(from_target, "assignDamage", redirectDamage, msg=txt, condition=condition)
示例#3
0
    def effects(controller, source):
        yield cost
        yield NoTarget()
        source = source.move_to(controller.battlefield)
        yield
        source.abilities.add(haste())

        # Exile at end of turn
        @source.delayed
        def ability():
            def condition(source):
                return str(source.zone) == "battlefield"
            def effects(controller, source):
                '''Exile this from the game at end of turn'''
                yield NoTarget()
                source.move_to("exile")
                yield
            return PhaseTrigger(EndTurnStepEvent(), condition), effects

        # Exile if it leaves play
        leave_battlefield_condition = lambda self, zone, position="top": str(self.zone) == "battlefield"
        def move_to(self, zone, position="top"):
            return self.move_to("exile")
        until_end_of_turn(do_replace(source, "move_to", move_to,
            condition=leave_battlefield_condition,
            msg="%s - exile from game"%source.name))
        yield
示例#4
0
def regenerate(target, txt="Regenerate", condition=None):
    def canDestroy(self):
        if self.canBeTapped(): self.tap()
        if isCreature(self):
            self.clearDamage()
            self.clearCombatState()
        # expire it
        canDestroy.expire()
        #self.send(RegenerationEvent())
        return False
    return until_end_of_turn(do_replace(target, "canDestroy", canDestroy, msg=txt, condition=condition))
示例#5
0
def prevent_all_noncombat_damage():
    def condition(self, amt, source, combat=False):
        return not combat

    msg = "~ - prevent all noncombat damage"
    return combine(
        do_replace(CreatureType,
                   "assignDamage",
                   preventAll,
                   msg=msg,
                   condition=condition),
        do_replace(Player,
                   "assignDamage",
                   preventAll,
                   msg=msg,
                   condition=condition),
        do_replace(PlaneswalkerType,
                   "assignDamage",
                   preventAll,
                   msg=msg,
                   condition=condition))
示例#6
0
def CiP(obj, during, before=no_before, condition=None, txt=''):
    if not txt and hasattr(during, "__doc__"): msg = during.__doc__
    else: msg = txt

    def move_to(self, zone, position="top"):
        # Now move to the battlefield
        if before(self):
            perm = self.move_to(zone, position)
            # At this point the card hasn't actually moved (it will on the next timestep event), so we can modify it's enteringZone function. This basically relies on the fact that entering battlefield is batched and done on the timestep.
            if not perm == self: # We weren't prevented from moving
                remove_entering = do_override(perm, "modifyEntering", lambda self: during(self))
            return perm
        else:
            # Don't actually move the card
            return self

    battlefield_condition = lambda self, zone, position="top": str(zone) == "battlefield"
    if condition: cond = lambda self, zone, position="top": battlefield_condition(self,zone,position) and condition(self,zone,position)
    else: cond = battlefield_condition

    return do_replace(obj, "move_to", move_to, msg=msg, condition=cond)
示例#7
0
def prevent_damage(target, amount, next=True, txt='', condition=None):
    if not txt:
        txt = 'Prevent %s%s damage'%("the next " if next else '', str(amount) if amount > -1 else "all")
    def shieldDamage(self, amt, source, combat=False):
        dmg = 0
        if shieldDamage.curr_amt != -1:
            if next:
                shielded = min([amt,shieldDamage.curr_amt])
                shieldDamage.curr_amt -= amt
                if shieldDamage.curr_amt <= 0:
                    shieldDamage.expire()
                    if not shieldDamage.curr_amt == 0:
                        dmg = self.assignDamage(-1*shieldDamage.curr_amt, source, combat)
            else:
                shielded = shieldDamage.curr_amt
                amt -= shieldDamage.curr_amt
                if amt > 0: dmg = self.assignDamage(amt, source, combat)
        else: shielded = amt
        #self.send(DamagePreventedEvent(),amt=shielded)
        return dmg
    shieldDamage.curr_amt = amount
    return do_replace(target, "assignDamage", shieldDamage, msg=txt, condition=condition)
示例#8
0
def prevent_all_noncombat_damage_by(dmgsource):
    def condition(self, amt, source, combat=False): return source == dmgsource and not combat
    msg = "~ - prevent all noncombat damage by %s"%dmgsource.name
    return combine(do_replace(CreatureType, "assignDamage", preventAll, msg=msg, condition=condition),
            do_replace(Player, "assignDamage", preventAll, msg=msg, condition=condition),
            do_replace(PlaneswalkerType, "assignDamage", preventAll, msg=msg, condition=condition))
示例#9
0
def prevent_all_noncombat_damage():
    def condition(self, amt, source, combat=False): return not combat
    msg = "~ - prevent all noncombat damage"
    return combine(do_replace(CreatureType, "assignDamage", preventAll, msg=msg, condition=condition),
            do_replace(Player, "assignDamage", preventAll, msg=msg, condition=condition),
            do_replace(PlaneswalkerType, "assignDamage", preventAll, msg=msg, condition=condition))
示例#10
0
def prevent_all_damage():
    msg = "~ - prevent all damage"
    return combine(do_replace(CreatureType, "assignDamage", preventAll, msg=msg),
            do_replace(Player, "assignDamage", preventAll, msg=msg),
            do_replace(PlaneswalkerType, "assignDamage", preventAll, msg=msg))
示例#11
0
def prevent_all_damage():
    msg = "~ - prevent all damage"
    return combine(
        do_replace(CreatureType, "assignDamage", preventAll, msg=msg),
        do_replace(Player, "assignDamage", preventAll, msg=msg),
        do_replace(PlaneswalkerType, "assignDamage", preventAll, msg=msg))