[DMU] Implemented The Raven Man

This commit is contained in:
Daniel Bomar 2022-08-22 11:42:18 -05:00
parent aea8c82728
commit 0d705fdea6
No known key found for this signature in database
GPG key ID: C86C8658F4023918
5 changed files with 131 additions and 0 deletions

View file

@ -0,0 +1,24 @@
package mage.abilities.condition.common;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.game.Game;
import mage.watchers.common.DiscardedCardWatcher;
/**
*
* @author weirddan455
*/
public enum PlayerDiscardedThisTurnCondition implements Condition {
instance;
@Override
public boolean apply(Game game, Ability source) {
return DiscardedCardWatcher.playerInRangeDiscarded(source.getControllerId(), game);
}
@Override
public String toString() {
return "a player discarded a card this turn";
}
}

View file

@ -0,0 +1,35 @@
package mage.game.permanent.token;
import mage.MageInt;
import mage.abilities.common.CantBlockAbility;
import mage.abilities.keyword.FlyingAbility;
import mage.constants.CardType;
import mage.constants.SubType;
/**
*
* @author weirddan455
*/
public final class BlackBirdToken extends TokenImpl {
public BlackBirdToken() {
super("Bird Token", "1/1 black Bird creature token with flying and \"This creature can't block.\"");
cardType.add(CardType.CREATURE);
color.setBlack(true);
subtype.add(SubType.BIRD);
power = new MageInt(1);
toughness = new MageInt(1);
addAbility(FlyingAbility.getInstance());
addAbility(new CantBlockAbility());
}
private BlackBirdToken(final BlackBirdToken token) {
super(token);
}
@Override
public BlackBirdToken copy() {
return new BlackBirdToken(this);
}
}

View file

@ -43,4 +43,16 @@ public class DiscardedCardWatcher extends Watcher {
DiscardedCardWatcher watcher = game.getState().getWatcher(DiscardedCardWatcher.class);
return watcher == null ? 0 : watcher.playerMap.getOrDefault(playerId, 0);
}
public static boolean playerInRangeDiscarded(UUID controllerId, Game game) {
DiscardedCardWatcher watcher = game.getState().getWatcher(DiscardedCardWatcher.class);
if (watcher != null) {
for (UUID playerId : game.getState().getPlayersInRange(controllerId, game)) {
if (watcher.playerMap.getOrDefault(playerId, 0) > 0) {
return true;
}
}
}
return false;
}
}