-
Notifications
You must be signed in to change notification settings - Fork 783
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
Rework drawing cards, associated replacement effects, and removing cards from library; implement [WHO] River Song #12700
Merged
Merged
Changes from 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0e0fa11
remove unused scoring system code
xenohedron a558910
add test for Alms Collector replacement effect
xenohedron e363cd3
flatten draw cards into single method in PlayerImpl
xenohedron b79fc46
clarify methods for getting cards from library
xenohedron fd00c1c
implement [WHO] River Song
xenohedron 7815aed
fix error
xenohedron 8c47fe1
adjust library methods
xenohedron 83b98d9
add lots of test cases for draw replacement effects
xenohedron 24f78eb
fix #12616
xenohedron 9764265
track cards drawn this way through multi draw replacement as well
xenohedron a5202c3
add test for River Song
xenohedron 56c717d
remove redundant comment
xenohedron 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 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,134 @@ | ||
package mage.cards.r; | ||
|
||
import mage.MageInt; | ||
import mage.abilities.Ability; | ||
import mage.abilities.TriggeredAbility; | ||
import mage.abilities.TriggeredAbilityImpl; | ||
import mage.abilities.common.SimpleStaticAbility; | ||
import mage.abilities.dynamicvalue.common.SourcePermanentPowerCount; | ||
import mage.abilities.effects.Effect; | ||
import mage.abilities.effects.ReplacementEffectImpl; | ||
import mage.abilities.effects.common.DamageTargetEffect; | ||
import mage.abilities.effects.common.counter.AddCountersSourceEffect; | ||
import mage.cards.CardImpl; | ||
import mage.cards.CardSetInfo; | ||
import mage.constants.*; | ||
import mage.counters.CounterType; | ||
import mage.game.Game; | ||
import mage.game.events.DrawCardEvent; | ||
import mage.game.events.GameEvent; | ||
import mage.players.Player; | ||
import mage.target.targetpointer.FixedTarget; | ||
|
||
import java.util.UUID; | ||
|
||
/** | ||
* @author xenohedron | ||
*/ | ||
public final class RiverSong extends CardImpl { | ||
|
||
public RiverSong(UUID ownerId, CardSetInfo setInfo) { | ||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}{R}"); | ||
|
||
this.supertype.add(SuperType.LEGENDARY); | ||
this.subtype.add(SubType.HUMAN); | ||
this.subtype.add(SubType.TIME_LORD); | ||
this.subtype.add(SubType.ROGUE); | ||
this.power = new MageInt(2); | ||
this.toughness = new MageInt(2); | ||
|
||
// Meet in Reverse -- You draw cards from the bottom of your library rather than the top. | ||
this.addAbility(new SimpleStaticAbility(new RiverSongDrawFromBottomReplacementEffect()) | ||
.withFlavorWord("Meet in Reverse")); | ||
|
||
// Spoilers -- Whenever an opponent scries, surveils, or searches their library, put a +1/+1 counter on River Song. | ||
// Then River Song deals damage to that player equal to its power. | ||
TriggeredAbility trigger = new RiverSongTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance())); | ||
trigger.addEffect(new DamageTargetEffect(new SourcePermanentPowerCount(false)) | ||
.setText("Then {this} deals damage to that player equal to its power")); | ||
this.addAbility(trigger.withFlavorWord("Spoilers")); | ||
} | ||
|
||
private RiverSong(final RiverSong card) { | ||
super(card); | ||
} | ||
|
||
@Override | ||
public RiverSong copy() { | ||
return new RiverSong(this); | ||
} | ||
} | ||
|
||
class RiverSongDrawFromBottomReplacementEffect extends ReplacementEffectImpl { | ||
|
||
RiverSongDrawFromBottomReplacementEffect() { | ||
super(Duration.WhileOnBattlefield, Outcome.Neutral); | ||
staticText = "You draw cards from the bottom of your library rather than the top"; | ||
} | ||
|
||
private RiverSongDrawFromBottomReplacementEffect(final RiverSongDrawFromBottomReplacementEffect effect) { | ||
super(effect); | ||
} | ||
|
||
@Override | ||
public RiverSongDrawFromBottomReplacementEffect copy() { | ||
return new RiverSongDrawFromBottomReplacementEffect(this); | ||
} | ||
|
||
@Override | ||
public boolean replaceEvent(GameEvent event, Ability source, Game game) { | ||
((DrawCardEvent) event).setFromBottom(true); | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean checksEventType(GameEvent event, Game game) { | ||
return event.getType() == GameEvent.EventType.DRAW_CARD; | ||
} | ||
|
||
@Override | ||
public boolean applies(GameEvent event, Ability source, Game game) { | ||
return source.getControllerId().equals(event.getPlayerId()); | ||
} | ||
} | ||
|
||
class RiverSongTriggeredAbility extends TriggeredAbilityImpl { | ||
|
||
RiverSongTriggeredAbility(Effect effect) { | ||
super(Zone.BATTLEFIELD, effect); | ||
setTriggerPhrase("Whenever an opponent scries, surveils, or searches their library, "); | ||
} | ||
|
||
private RiverSongTriggeredAbility(final RiverSongTriggeredAbility ability) { | ||
super(ability); | ||
} | ||
|
||
@Override | ||
public RiverSongTriggeredAbility copy() { | ||
return new RiverSongTriggeredAbility(this); | ||
} | ||
|
||
@Override | ||
public boolean checkEventType(GameEvent event, Game game) { | ||
switch (event.getType()) { | ||
case SCRIED: | ||
case SURVEILED: | ||
case LIBRARY_SEARCHED: | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
@Override | ||
public boolean checkTrigger(GameEvent event, Game game) { | ||
Player controller = game.getPlayer(getControllerId()); | ||
if (controller != null | ||
&& controller.hasOpponent(event.getPlayerId(), game) | ||
&& event.getPlayerId().equals(event.getTargetId())) { // searches own library | ||
getEffects().setTargetPointer(new FixedTarget(event.getPlayerId())); | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
And don’t forget to add cards removing in code like that here. Maybe it’s better to keep removeFromXXX methods.