-
Notifications
You must be signed in to change notification settings - Fork 895
[TMT] Implement Raphael, Most Attitude #14593
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
Merged
+154
−0
Merged
Changes from 1 commit
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,150 @@ | ||
| package mage.cards.r; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.UUID; | ||
| import mage.MageInt; | ||
| import mage.MageObjectReference; | ||
| import mage.constants.SubType; | ||
| import mage.constants.SuperType; | ||
| import mage.constants.WatcherScope; | ||
| import mage.game.ExileZone; | ||
| import mage.game.Game; | ||
| import mage.game.events.GameEvent; | ||
| import mage.util.CardUtil; | ||
| import mage.watchers.Watcher; | ||
| import mage.abilities.Ability; | ||
| import mage.abilities.common.AllianceAbility; | ||
| import mage.abilities.common.AttacksTriggeredAbility; | ||
| import mage.abilities.effects.AsThoughEffectImpl; | ||
| import mage.abilities.effects.common.ExileCardsFromTopOfLibraryControllerEffect; | ||
| import mage.abilities.keyword.MenaceAbility; | ||
| import mage.cards.CardImpl; | ||
| import mage.cards.CardSetInfo; | ||
| import mage.constants.AsThoughEffectType; | ||
| import mage.constants.CardType; | ||
| import mage.constants.Duration; | ||
| import mage.constants.Outcome; | ||
|
|
||
| /** | ||
| * | ||
| * @author muz | ||
| */ | ||
| public final class RaphaelMostAttitude extends CardImpl { | ||
|
|
||
| public RaphaelMostAttitude(UUID ownerId, CardSetInfo setInfo) { | ||
| super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}"); | ||
|
|
||
| this.supertype.add(SuperType.LEGENDARY); | ||
| this.subtype.add(SubType.MUTANT); | ||
| this.subtype.add(SubType.NINJA); | ||
| this.subtype.add(SubType.TURTLE); | ||
| this.power = new MageInt(4); | ||
| this.toughness = new MageInt(3); | ||
|
|
||
| // Menace | ||
| this.addAbility(new MenaceAbility()); | ||
|
|
||
| // Alliance -- Whenever another creature you control enters, you may exile the top card of your library. | ||
| this.addAbility(new AllianceAbility(new ExileCardsFromTopOfLibraryControllerEffect(1, true))); | ||
|
|
||
| // Whenever Raphael attacks, until end of turn, you may play a card exiled with Raphael. | ||
| this.addAbility(new AttacksTriggeredAbility(new RaphaelMostAttitudeEffect(), false)); | ||
| } | ||
|
|
||
| private RaphaelMostAttitude(final RaphaelMostAttitude card) { | ||
| super(card); | ||
| } | ||
|
|
||
| @Override | ||
| public RaphaelMostAttitude copy() { | ||
| return new RaphaelMostAttitude(this); | ||
| } | ||
| } | ||
|
|
||
| class RaphaelMostAttitudeEffect extends AsThoughEffectImpl { | ||
|
|
||
| RaphaelMostAttitudeEffect() { | ||
| super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.EndOfTurn, Outcome.Benefit); | ||
| staticText = "until end of turn, you may play a card exiled with {this}."; | ||
| } | ||
|
|
||
| private RaphaelMostAttitudeEffect(final RaphaelMostAttitudeEffect effect) { | ||
| super(effect); | ||
| } | ||
|
|
||
| @Override | ||
| public RaphaelMostAttitudeEffect copy() { | ||
| return new RaphaelMostAttitudeEffect(this); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean apply(Game game, Ability source) { | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| public void init(Ability source, Game game) { | ||
| super.init(source, game); | ||
| RaphaelMostAttitudeWatcher.addPlayable(source, game); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { | ||
| if (!RaphaelMostAttitudeWatcher.checkPermission(affectedControllerId, source, game)) { | ||
| return false; | ||
| } | ||
|
|
||
| ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source)); | ||
| if (exileZone == null || !exileZone.contains(sourceId)) { | ||
| return false; | ||
| } | ||
| CardUtil.makeCardPlayable(game, source, exileZone.get(sourceId, game), false, Duration.EndOfTurn, false); | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| class RaphaelMostAttitudeWatcher extends Watcher { | ||
|
|
||
| private final Map<MageObjectReference, Map<UUID, Integer>> morMap = new HashMap<>(); | ||
|
|
||
| RaphaelMostAttitudeWatcher() { | ||
| super(WatcherScope.GAME); | ||
| } | ||
|
|
||
| @Override | ||
| public void watch(GameEvent event, Game game) { | ||
| if (event.getType() == GameEvent.EventType.SPELL_CAST || event.getType() == GameEvent.EventType.PLAY_LAND) { | ||
| if (event.getApprovingObject() == null) { | ||
| return; | ||
| } | ||
| morMap.computeIfAbsent(event.getApprovingObject().getApprovingMageObjectReference(), m -> new HashMap<>()) | ||
| .compute(event.getPlayerId(), (u, i) -> i == null ? 0 : Integer.sum(i, -1)); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void reset() { | ||
| morMap.clear(); | ||
| super.reset(); | ||
| } | ||
|
|
||
| static boolean checkPermission(UUID playerId, Ability source, Game game) { | ||
| if (!playerId.equals(source.getControllerId())) { | ||
| return false; | ||
| } | ||
| MageObjectReference mor = new MageObjectReference(source); | ||
| RaphaelMostAttitudeWatcher watcher = game.getState().getWatcher(RaphaelMostAttitudeWatcher.class); | ||
| return watcher.morMap.containsKey(mor) | ||
| && watcher.morMap.get(mor).getOrDefault(playerId, 0) > 0; | ||
| } | ||
|
|
||
| static void addPlayable(Ability source, Game game) { | ||
| MageObjectReference mor = new MageObjectReference(source); | ||
| game.getState() | ||
| .getWatcher(RaphaelMostAttitudeWatcher.class) | ||
| .morMap | ||
| .computeIfAbsent(mor, m -> new HashMap<>()) | ||
| .compute(source.getControllerId(), CardUtil::setOrIncrementValue); | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.