Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions Mage.Sets/src/mage/cards/f/FractalTender.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package mage.cards.f;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.constants.SubType;
import mage.constants.TargetController;
import mage.constants.WatcherScope;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.FractalToken;
import mage.watchers.Watcher;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.hint.ConditionHint;
import mage.abilities.hint.Hint;
import mage.abilities.keyword.WardAbility;
import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility;
import mage.abilities.keyword.IncrementAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;

/**
*
* @author muz
*/
public final class FractalTender extends CardImpl {

public FractalTender(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}{U}");

this.subtype.add(SubType.ELF);
this.subtype.add(SubType.WIZARD);
this.power = new MageInt(3);
this.toughness = new MageInt(3);

// Ward {2}
this.addAbility(new WardAbility(new ManaCostsImpl<>("{2}")));

// Increment
this.addAbility(new IncrementAbility());

// At the beginning of each end step, if you put a counter on this creature this turn, create a 0/0 green and blue Fractal creature token and put three +1/+1 counters on it.
this.addAbility(new BeginningOfEndStepTriggeredAbility(
TargetController.ANY,
FractalToken.getEffect(StaticValue.get(3), "and put three +1/+1 counters on it"),
false,
FractalTenderCondition.instance
).addHint(FractalTenderCondition.getHint()), new FractalTenderWatcher());
}

private FractalTender(final FractalTender card) {
super(card);
}

@Override
public FractalTender copy() {
return new FractalTender(this);
}
}

enum FractalTenderCondition implements Condition {
instance;
private static final Hint hint = new ConditionHint(instance);

public static Hint getHint() {
return hint;
}

@Override
public boolean apply(Game game, Ability source) {
return FractalTenderWatcher.check(source.getSourceId(), source.getControllerId(), game);
}

@Override
public String toString() {
return "you put a counter on this creature this turn";
}
}

class FractalTenderWatcher extends Watcher {

private final Map<UUID, Set<UUID>> map = new HashMap<>();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should use MageObjectReferences for the permanent


FractalTenderWatcher() {
super(WatcherScope.GAME);
}

@Override
public void watch(GameEvent event, Game game) {
if (event.getType() != GameEvent.EventType.COUNTER_ADDED || event.getAmount() < 1) {
return;
}
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && permanent.isCreature(game)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need to check for it being a creature

map.computeIfAbsent(event.getTargetId(), k -> new HashSet<>()).add(event.getPlayerId());
}
}

@Override
public void reset() {
super.reset();
map.clear();
}

static boolean check(UUID permanentId, UUID playerId, Game game) {
Set<UUID> players = game
.getState()
.getWatcher(FractalTenderWatcher.class)
.map
.get(permanentId);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use getOrDefault(__,Collections.emptySet()) so you don't have to null check

return players != null && players.contains(playerId);
}
}
1 change: 1 addition & 0 deletions Mage.Sets/src/mage/sets/SecretsOfStrixhaven.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private SecretsOfStrixhaven() {
cards.add(new SetCardInfo("Forum of Amity", 256, Rarity.COMMON, mage.cards.f.ForumOfAmity.class));
cards.add(new SetCardInfo("Fractal Anomaly", 50, Rarity.UNCOMMON, mage.cards.f.FractalAnomaly.class));
cards.add(new SetCardInfo("Fractal Mascot", 189, Rarity.COMMON, mage.cards.f.FractalMascot.class));
cards.add(new SetCardInfo("Fractal Tender", 190, Rarity.UNCOMMON, mage.cards.f.FractalTender.class));
cards.add(new SetCardInfo("Garrison Excavator", 116, Rarity.UNCOMMON, mage.cards.g.GarrisonExcavator.class));
cards.add(new SetCardInfo("Graduation Day", 16, Rarity.UNCOMMON, mage.cards.g.GraduationDay.class));
cards.add(new SetCardInfo("Grapple with Death", 192, Rarity.COMMON, mage.cards.g.GrappleWithDeath.class));
Expand Down
Loading