mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Implemented The Ozolith
This commit is contained in:
parent
ebfba73c61
commit
fd02d66227
3 changed files with 181 additions and 1 deletions
179
Mage.Sets/src/mage/cards/t/TheOzolith.java
Normal file
179
Mage.Sets/src/mage/cards/t/TheOzolith.java
Normal file
|
@ -0,0 +1,179 @@
|
|||
package mage.cards.t;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfCombatTriggeredAbility;
|
||||
import mage.abilities.common.LeavesBattlefieldAllTriggeredAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SuperType;
|
||||
import mage.constants.TargetController;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.Counters;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.predicate.permanent.CounterAnyPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class TheOzolith extends CardImpl {
|
||||
|
||||
public TheOzolith(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}");
|
||||
|
||||
this.addSuperType(SuperType.LEGENDARY);
|
||||
|
||||
// Whenever a creature you control leaves the battlefield, if it had counters on it, put those counters on The Ozolith.
|
||||
this.addAbility(new TheOzolithTriggeredAbility());
|
||||
|
||||
// At the beginning of combat on your turn, if The Ozolith has counters on it, you may move all counters from The Ozolith onto target creature.
|
||||
Ability ability = new ConditionalInterveningIfTriggeredAbility(
|
||||
new BeginningOfCombatTriggeredAbility(
|
||||
new TheOzolithMoveCountersEffect(), TargetController.YOU, true
|
||||
), TheOzolithCondition.instance, "At the beginning of combat on your turn, " +
|
||||
"if {this} has counters on it, you may move all counters from {this} onto target creature."
|
||||
);
|
||||
ability.addTarget(new TargetCreaturePermanent());
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
private TheOzolith(final TheOzolith card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TheOzolith copy() {
|
||||
return new TheOzolith(this);
|
||||
}
|
||||
}
|
||||
|
||||
class TheOzolithTriggeredAbility extends LeavesBattlefieldAllTriggeredAbility {
|
||||
|
||||
private static final FilterPermanent filter = new FilterControlledCreaturePermanent();
|
||||
|
||||
static {
|
||||
filter.add(CounterAnyPredicate.instance);
|
||||
}
|
||||
|
||||
TheOzolithTriggeredAbility() {
|
||||
super(null, filter);
|
||||
}
|
||||
|
||||
private TheOzolithTriggeredAbility(final TheOzolithTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
public TheOzolithTriggeredAbility copy() {
|
||||
return new TheOzolithTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (!super.checkTrigger(event, game)) {
|
||||
return false;
|
||||
}
|
||||
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
|
||||
this.getEffects().clear();
|
||||
this.addEffect(new TheOzolithLeaveEffect(permanent.getCounters(game)));
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getRule() {
|
||||
return "Whenever a creature you control leaves the battlefield, " +
|
||||
"if it had counters on it, put those counters on {this}.";
|
||||
}
|
||||
}
|
||||
|
||||
class TheOzolithLeaveEffect extends OneShotEffect {
|
||||
|
||||
private final Counters counters;
|
||||
|
||||
TheOzolithLeaveEffect(Counters counters) {
|
||||
super(Outcome.Benefit);
|
||||
this.counters = counters.copy();
|
||||
}
|
||||
|
||||
private TheOzolithLeaveEffect(final TheOzolithLeaveEffect effect) {
|
||||
super(effect);
|
||||
this.counters = effect.counters.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TheOzolithLeaveEffect copy() {
|
||||
return new TheOzolithLeaveEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent == null) {
|
||||
return false;
|
||||
}
|
||||
counters.values()
|
||||
.stream()
|
||||
.forEach(counter -> permanent.addCounters(counter, source, game));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
enum TheOzolithCondition implements Condition {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent == null) {
|
||||
return false;
|
||||
}
|
||||
return permanent != null
|
||||
&& permanent
|
||||
.getCounters(game)
|
||||
.values()
|
||||
.stream()
|
||||
.mapToInt(Counter::getCount)
|
||||
.max()
|
||||
.orElse(0) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
class TheOzolithMoveCountersEffect extends OneShotEffect {
|
||||
|
||||
TheOzolithMoveCountersEffect() {
|
||||
super(Outcome.Benefit);
|
||||
}
|
||||
|
||||
private TheOzolithMoveCountersEffect(final TheOzolithMoveCountersEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TheOzolithMoveCountersEffect copy() {
|
||||
return new TheOzolithMoveCountersEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
Permanent creature = game.getPermanent(source.getFirstTarget());
|
||||
if (permanent == null || creature == null) {
|
||||
return false;
|
||||
}
|
||||
permanent.getCounters(game)
|
||||
.values()
|
||||
.stream()
|
||||
.forEach(counter -> creature.addCounters(counter, source, game));
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -297,6 +297,7 @@ public final class IkoriaLairOfBehemoths extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Swamp", 268, Rarity.LAND, mage.cards.basiclands.Swamp.class, NON_FULL_USE_VARIOUS));
|
||||
cards.add(new SetCardInfo("Swiftwater Cliffs", 255, Rarity.COMMON, mage.cards.s.SwiftwaterCliffs.class));
|
||||
cards.add(new SetCardInfo("Tentative Connection", 138, Rarity.COMMON, mage.cards.t.TentativeConnection.class));
|
||||
cards.add(new SetCardInfo("The Ozolith", 237, Rarity.RARE, mage.cards.t.TheOzolith.class));
|
||||
cards.add(new SetCardInfo("Thieving Otter", 69, Rarity.COMMON, mage.cards.t.ThievingOtter.class));
|
||||
cards.add(new SetCardInfo("Thornwood Falls", 256, Rarity.COMMON, mage.cards.t.ThornwoodFalls.class));
|
||||
cards.add(new SetCardInfo("Thwart the Enemy", 173, Rarity.COMMON, mage.cards.t.ThwartTheEnemy.class));
|
||||
|
|
|
@ -40,7 +40,7 @@ public class LeavesBattlefieldAllTriggeredAbility extends TriggeredAbilityImpl {
|
|||
this.setTargetPointer = setTargetPointer;
|
||||
}
|
||||
|
||||
private LeavesBattlefieldAllTriggeredAbility(final LeavesBattlefieldAllTriggeredAbility ability) {
|
||||
protected LeavesBattlefieldAllTriggeredAbility(final LeavesBattlefieldAllTriggeredAbility ability) {
|
||||
super(ability);
|
||||
filter = ability.filter;
|
||||
setTargetPointer = ability.setTargetPointer;
|
||||
|
|
Loading…
Reference in a new issue