Merge pull request #5178 from magefree/yuriko

Implemented Yuriko, the Tiger's Shadow
This commit is contained in:
LevelX2 2018-08-15 08:09:40 +02:00 committed by GitHub
commit 6e242fb11f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 137 additions and 8 deletions

View file

@ -1,4 +1,3 @@
package mage.abilities.keyword;
import java.util.UUID;
@ -16,6 +15,7 @@ import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.permanent.UnblockedPredicate;
import mage.game.Game;
import mage.game.command.CommandObject;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetControlledCreaturePermanent;
@ -43,6 +43,7 @@ import mage.target.common.TargetControlledPermanent;
*/
public class NinjutsuAbility extends ActivatedAbilityImpl {
private final boolean commander;
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("unblocked attacker you control");
static {
@ -54,13 +55,19 @@ public class NinjutsuAbility extends ActivatedAbilityImpl {
* @param manaCost ninjutsu mana cost
*/
public NinjutsuAbility(ManaCost manaCost) {
super(Zone.HAND, new NinjutsuEffect(), manaCost);
this.addCost(new RevealNinjutsuCardCost());
this(manaCost, false);
}
public NinjutsuAbility(ManaCost manaCost, boolean commander) {
super(commander ? Zone.ALL : Zone.HAND, new NinjutsuEffect(), manaCost);
this.addCost(new RevealNinjutsuCardCost(commander));
this.addCost(new ReturnAttackerToHandTargetCost(new TargetControlledCreaturePermanent(1, 1, filter, true)));
this.commander = commander;
}
public NinjutsuAbility(NinjutsuAbility ability) {
super(ability);
this.commander = ability.commander;
}
@Override
@ -70,9 +77,13 @@ public class NinjutsuAbility extends ActivatedAbilityImpl {
@Override
public String getRule() {
return new StringBuilder("Ninjutsu ").append(getManaCostsToPay().getText()).append(" <i>(")
.append(getManaCostsToPay().getText())
.append(" Return an unblocked attacker you control to hand: Put this card onto the battlefield from your hand tapped and attacking.)</i>").toString();
return (commander ? "Commander n" : "N") + "injutsu "
+ getManaCostsToPay().getText() + " <i>("
+ getManaCostsToPay().getText()
+ " Return an unblocked attacker you control to hand: "
+ "Put this card onto the battlefield from your hand"
+ (commander ? " or the command zone " : " ")
+ "tapped and attacking.)</i>";
}
}
@ -80,7 +91,8 @@ class NinjutsuEffect extends OneShotEffect {
public NinjutsuEffect() {
super(Outcome.PutCreatureInPlay);
this.staticText = "Put this card onto the battlefield from your hand tapped and attacking";
this.staticText = "Put this card onto the battlefield "
+ "from your hand tapped and attacking";
}
public NinjutsuEffect(final NinjutsuEffect effect) {
@ -165,12 +177,16 @@ class ReturnAttackerToHandTargetCost extends CostImpl {
class RevealNinjutsuCardCost extends CostImpl {
public RevealNinjutsuCardCost() {
private final boolean commander;
public RevealNinjutsuCardCost(boolean commander) {
this.text = "reveal ninjutsu card";
this.commander = commander;
}
public RevealNinjutsuCardCost(RevealNinjutsuCardCost cost) {
super(cost);
this.commander = cost.commander;
}
@Override
@ -178,6 +194,15 @@ class RevealNinjutsuCardCost extends CostImpl {
Player player = game.getPlayer(controllerId);
Card card = player.getHand().get(ability.getSourceId(), game);
if (card == null && commander
&& player.getCommandersIds().contains(ability.getSourceId())) {
for (CommandObject coj : game.getState().getCommand()) {
if (coj != null && coj.getId().equals(ability.getSourceId())) {
card = game.getCard(ability.getSourceId());
}
break;
}
}
if (card != null) {
Cards cards = new CardsImpl(card);
player.revealCards("Ninjutsu", cards, game);