use of mage.abilities.condition.common.OathbreakerOnBattlefieldCondition in project mage by magefree.
the class OathbreakerFreeForAll method initCommanderEffects.
@Override
public void initCommanderEffects(Card commander, Player player, Ability commanderAbility) {
// all commander effects must be independent from sourceId or controllerId (it's limitation of current commander effects)
boolean isSignatureSpell = this.playerSignatureSpells.getOrDefault(player.getId(), new HashSet<>()).contains(commander.getId());
// basic commmander restrict (oathbreaker may ask to move, signature force to move)
commanderAbility.addEffect(new CommanderReplacementEffect(commander.getId(), alsoHand, alsoLibrary, isSignatureSpell, getCommanderTypeName(commander)));
commanderAbility.addEffect(new CommanderCostModification(commander));
// signature spell restrict (spell can be casted on player's commander on battlefield)
if (isSignatureSpell) {
OathbreakerOnBattlefieldCondition condition = new OathbreakerOnBattlefieldCondition(this, player.getId(), commander.getId(), this.playerOathbreakers.getOrDefault(player.getId(), new HashSet<>()));
commanderAbility.addEffect(new SignatureSpellCastOnlyWithOathbreakerEffect(condition, commander.getId()));
// hint must be added to card, not global ability
Ability ability = new SimpleStaticAbility(new InfoEffect("Signature spell hint"));
ability.addHint(new ConditionHint(condition, "Oathbreaker on battlefield (" + condition.getCompatibleNames() + ")"));
ability.setRuleVisible(false);
commander.addAbility(ability);
}
}
Aggregations