mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
[PIP] Implement Sentinel Sarah Lyons; The Prydwen, Steel Flagship; add common watcher + condition (#12250)
* [PIP] Implement Sentinel Sarah Lyons * Create common watcher and condition for artifacts entering * [PIP] Implement The Prydwen, Steel Flagship * Use common classes in Akal Pakal, First Among Equals; string correction * Add warning about watcher to ArtifactEnteredUnderYourControlCondition * Add tests * Move test file * Test with opponent casting artifact during your turn * Use checkPT(), don't call execute() multiple times * Check final assertion at upkeep instead of untap step
This commit is contained in:
parent
08f48be745
commit
0f858fe3c3
9 changed files with 355 additions and 107 deletions
|
|
@ -0,0 +1,25 @@
|
|||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.game.Game;
|
||||
import mage.watchers.common.ArtifactEnteredControllerWatcher;
|
||||
|
||||
/**
|
||||
* /!\ You need to add ArtifactEnteredControllerWatcher to any card using this condition
|
||||
*
|
||||
* @author Cguy7777
|
||||
*/
|
||||
public enum ArtifactEnteredUnderYourControlCondition implements Condition {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return ArtifactEnteredControllerWatcher.enteredArtifactForPlayer(source.getControllerId(), game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "an artifact entered the battlefield under your control this turn";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package mage.game.permanent.token;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.condition.common.ArtifactEnteredUnderYourControlCondition;
|
||||
import mage.abilities.decorator.ConditionalContinuousEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostSourceEffect;
|
||||
import mage.abilities.hint.ConditionHint;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.SubType;
|
||||
|
||||
/**
|
||||
* @author Cguy7777
|
||||
*/
|
||||
public class ThePrydwenSteelFlagshipHumanKnightToken extends TokenImpl {
|
||||
|
||||
/**
|
||||
* /!\ You need to add ArtifactEnteredControllerWatcher to any card using this token
|
||||
*/
|
||||
public ThePrydwenSteelFlagshipHumanKnightToken() {
|
||||
super("Human Knight Token", "2/2 white Human Knight creature token with \"This creature " +
|
||||
"gets +2/+2 as long as an artifact entered the battlefield under your control this turn.\"");
|
||||
cardType.add(CardType.CREATURE);
|
||||
color.setWhite(true);
|
||||
subtype.add(SubType.HUMAN, SubType.KNIGHT);
|
||||
power = new MageInt(2);
|
||||
toughness = new MageInt(2);
|
||||
|
||||
this.addAbility(new SimpleStaticAbility(new ConditionalContinuousEffect(
|
||||
new BoostSourceEffect(2, 2, Duration.WhileOnBattlefield),
|
||||
ArtifactEnteredUnderYourControlCondition.instance,
|
||||
"This creature gets +2/+2 as long as an artifact entered the battlefield under your control this turn"))
|
||||
.addHint(new ConditionHint(ArtifactEnteredUnderYourControlCondition.instance)));
|
||||
}
|
||||
|
||||
private ThePrydwenSteelFlagshipHumanKnightToken(final ThePrydwenSteelFlagshipHumanKnightToken token) {
|
||||
super(token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThePrydwenSteelFlagshipHumanKnightToken copy() {
|
||||
return new ThePrydwenSteelFlagshipHumanKnightToken(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
package mage.watchers.common;
|
||||
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.EntersTheBattlefieldEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Cguy7777
|
||||
*/
|
||||
public class ArtifactEnteredControllerWatcher extends Watcher {
|
||||
|
||||
private final Set<UUID> players = new HashSet<>();
|
||||
|
||||
public ArtifactEnteredControllerWatcher() {
|
||||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() != GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntersTheBattlefieldEvent eEvent = (EntersTheBattlefieldEvent) event;
|
||||
if (eEvent.getTarget() != null && eEvent.getTarget().isArtifact(game)) {
|
||||
players.add(eEvent.getTarget().getControllerId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
players.clear();
|
||||
}
|
||||
|
||||
public static boolean enteredArtifactForPlayer(UUID playerId, Game game) {
|
||||
return game
|
||||
.getState()
|
||||
.getWatcher(ArtifactEnteredControllerWatcher.class)
|
||||
.players
|
||||
.contains(playerId);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue