-
Notifications
You must be signed in to change notification settings - Fork 886
[SOS] Implement Fractal Tender #14674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
muz
wants to merge
2
commits into
magefree:master
Choose a base branch
from
muz:sos_fractal_tender
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+122
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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<>(); | ||
|
|
||
| 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)) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can use |
||
| return players != null && players.contains(playerId); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should use
MageObjectReferencesfor the permanent