def enchant(target_type, zone="battlefield", player=None): def effects(source): source.target_type = target_type source.target_zone = zone source.target_player = player source.attach_on_enter = None yield lambda: None return CardStaticAbility(effects, keyword="Enchant %s in %s"%(target_type, zone), zone="all")
def kicker(cost): def effects(card): card.kicked = kicked() yield ( do_override(card, "_get_additional_costs", lambda self: KickerCost(cost)), do_override( card, "modifyNewRole", lambda self, new, zone: setattr(new, "kicked", self.kicked))) return CardStaticAbility(effects, zone="stack", keyword="kicker")
def retrace(): '''Retrace appears on some instants and sorceries. It represents a static ability that functions while the card is in a player's graveyard. 'Retrace' means "You may play this card from your graveyard by discarding a land card as an additional cost to play it." ''' def retrace_effects(card): def modifyNewRole(self, new, zone): if str(zone) == "stack": override(new, "_get_additional_costs", lambda self: DiscardCost(cardtype=isLandCard)) def play_from_graveyard(self): if self.controller.you_may("Play %s using retrace" % self): override(self, "modifyNewRole", modifyNewRole) return True else: return False yield override(card, "_playable_zone", play_from_graveyard) return CardStaticAbility(effects=retrace_effects, zone="graveyard", keyword="retrace")
def prowl(prowl_cost): # You may play this for its prowl cost if you dealt combat damage to a player this turn with a [card subtypes] def prowl_effect(card): orig_spell = card.play_spell def play_prowl(controller, source): play = orig_spell.effect_generator(controller, source) cost = play.next() prowl_payed = False if prowl_tracker.check(source) and controller.you_may("play this spell for it's prowl cost (%s)"%prowl_cost): cost = prowl_cost prowl_payed = True payment = yield cost target = yield play.send(payment[:-1]) play.send(target) if prowl_played: print "Prowl played!" yield # Set up a different way to play card.play_spell = orig_spell.__class__(play_prowl, limit=orig_spell.limit, txt=orig_spell.txt, keyword=orig_spell.keyword) def restore(): card.play_spell = orig_spell yield restore return CardStaticAbility(effects=prowl_effect, zone="all", txt="Prowl %s"%prowl_cost, keyword="prowl")
def dredge(n): return CardStaticAbility(no_effects, keyword="dredge", zone="graveyard")
def epic(): return CardStaticAbility(no_effects, keyword="epic", zone="battlefield")
def offering(subtype): return CardStaticAbility(no_effects, keyword="offering", zone="non-battlefield")
def suspend(number): return CardStaticAbility(no_effects, keyword="suspend", zone="non-battlefield")
def cumulative_upkeep(cost): return CardStaticAbility(no_effects, keyword="cumulative upkeep", zone="battlefield")
def rampage(n): return CardStaticAbility(no_effects, keyword="rampage", zone="battlefield")
def transfigure(n): return CardStaticAbility(no_effects, keyword="transfigure", zone="battlefield")
def poisonous(n): return CardStaticAbility(no_effects, keyword="poisonous", zone="battlefield")
def frenzy(n): return CardStaticAbility(no_effects, keyword="frenzy", zone="battlefield")
def delve(): return CardStaticAbility(no_effects, keyword="delve", zone="stack")
def aura_swap(cost): return CardStaticAbility(no_effects, keyword="aura swap", zone="battlefield")
def affinity(types): return CardStaticAbility(no_effects, keyword="affinity", zone="stack")
def entwine(cost): return CardStaticAbility(no_effects, keyword="entwine", zone="stack")
def phasing(n): return CardStaticAbility(no_effects, keyword="phasing", zone="battlefield")
def splice(subtype, cost): return CardStaticAbility(no_effects, keyword="splice", zone="hand")
def flashback(cost): return CardStaticAbility(no_effects, keyword="flashback", zone="battlefield")
def ninjutsu(cost): return CardStaticAbility(no_effects, keyword="ninjutsu", zone="hand")
def madness(cost): return CardStaticAbility(no_effects, keyword="madness", zone="battlefield")
def convoke(): return CardStaticAbility(no_effects, keyword="convoke", zone="stack")
def morph(cost): return CardStaticAbility(no_effects, keyword="morph", zone="battlefield")
def bloodthirst(n): return CardStaticAbility(no_effects, keyword="bloodthirst", zone="non-battlefield")
def amplify(n): return CardStaticAbility(no_effects, keyword="amplify", zone="non-battlefield")
def additional_cost(cost, txt=''): if isinstance(cost, str): cost = ManaCost(cost) def effects(card): yield do_override(card, "_get_additional_costs", lambda self: cost) return CardStaticAbility(effects, zone="stack", txt=txt)
def provoke(): return CardStaticAbility(no_effects, keyword="provoke", zone="battlefield")
def horsemanship(): keyword = "horsemanship" return CardStaticAbility(effects=override_effect("canBeBlockedBy", lambda self, blocker: keyword in blocker.abilities), keyword=keyword)
def storm(): return CardStaticAbility(no_effects, keyword="storm", zone="stack")