mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
* Rag Dealer / Serene Reembrance - Fixed target handling for AI.
This commit is contained in:
parent
f43b3d1ee2
commit
9d5327da7a
6 changed files with 98 additions and 67 deletions
|
@ -576,6 +576,20 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
|
|||
return target.isChosen();
|
||||
}
|
||||
|
||||
if (target instanceof TargetCardInASingleGraveyard) {
|
||||
List<Card> cards = new ArrayList<Card>();
|
||||
for (Player player: game.getPlayers().values()) {
|
||||
cards.addAll(player.getGraveyard().getCards(game));
|
||||
}
|
||||
while(!target.isChosen() && !cards.isEmpty()) {
|
||||
Card pick = pickTarget(cards, outcome, target, source, game);
|
||||
if (pick != null) {
|
||||
target.addTarget(pick.getId(), source, game);
|
||||
}
|
||||
}
|
||||
return target.isChosen();
|
||||
}
|
||||
|
||||
throw new IllegalStateException("Target wasn't handled. class:" + target.getClass().toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ import mage.cards.CardImpl;
|
|||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.target.TargetCard;
|
||||
import mage.target.common.TargetCardInASingleGraveyard;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -65,7 +66,7 @@ public class RagDealer extends CardImpl<RagDealer> {
|
|||
// {2}{B}, {T}: Exile up to three target cards from a single graveyard.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new RagDealerExileEffect(), new ManaCostsImpl("{2}{B}"));
|
||||
ability.addCost(new TapSourceCost());
|
||||
ability.addTarget(new RagDealerTargetCardsInGraveyard(0, 3, new FilterCard()));
|
||||
ability.addTarget(new TargetCardInASingleGraveyard(0, 3, new FilterCard("up to three target cards from a single graveyard")));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
|
@ -80,38 +81,6 @@ public class RagDealer extends CardImpl<RagDealer> {
|
|||
|
||||
}
|
||||
|
||||
class RagDealerTargetCardsInGraveyard extends TargetCard<RagDealerTargetCardsInGraveyard> {
|
||||
|
||||
public RagDealerTargetCardsInGraveyard(int minNumTargets, int maxNumTargets, FilterCard filter) {
|
||||
super(minNumTargets, maxNumTargets, Zone.GRAVEYARD, filter);
|
||||
this.targetName = "up to three target cards from a single graveyard";
|
||||
}
|
||||
|
||||
public RagDealerTargetCardsInGraveyard(final RagDealerTargetCardsInGraveyard target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||
UUID firstTarget = this.getFirstTarget();
|
||||
if (firstTarget != null) {
|
||||
Card card = game.getCard(firstTarget);
|
||||
Card targetCard = game.getCard(id);
|
||||
if (card == null || targetCard == null
|
||||
|| !card.getOwnerId().equals(targetCard.getOwnerId())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return super.canTarget(id, source, game);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public RagDealerTargetCardsInGraveyard copy() {
|
||||
return new RagDealerTargetCardsInGraveyard(this);
|
||||
}
|
||||
}
|
||||
|
||||
class RagDealerExileEffect extends OneShotEffect<RagDealerExileEffect> {
|
||||
|
||||
public RagDealerExileEffect() {
|
||||
|
|
|
@ -41,6 +41,7 @@ import mage.filter.FilterCard;
|
|||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
import mage.target.common.TargetCardInASingleGraveyard;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -56,7 +57,7 @@ public class SereneRemembrance extends CardImpl<SereneRemembrance> {
|
|||
|
||||
// Shuffle Serene Remembrance and up to three target cards from a single graveyard into their owners' libraries.
|
||||
this.getSpellAbility().addEffect(new SereneRemembranceEffect());
|
||||
this.getSpellAbility().addTarget(new SereneRemembranceTargetCardsInGraveyard(0,3,new FilterCard()));
|
||||
this.getSpellAbility().addTarget(new TargetCardInASingleGraveyard(0,3,new FilterCard("up to three target cards from a single graveyard")));
|
||||
|
||||
}
|
||||
|
||||
|
@ -114,35 +115,3 @@ class SereneRemembranceEffect extends OneShotEffect<SereneRemembranceEffect> {
|
|||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
class SereneRemembranceTargetCardsInGraveyard extends TargetCard<SereneRemembranceTargetCardsInGraveyard> {
|
||||
|
||||
public SereneRemembranceTargetCardsInGraveyard(int minNumTargets, int maxNumTargets, FilterCard filter) {
|
||||
super(minNumTargets, maxNumTargets, Zone.GRAVEYARD, filter);
|
||||
this.targetName = "up to three target cards from a single graveyard";
|
||||
}
|
||||
|
||||
public SereneRemembranceTargetCardsInGraveyard(final SereneRemembranceTargetCardsInGraveyard target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||
UUID firstTarget = this.getFirstTarget();
|
||||
if (firstTarget != null) {
|
||||
Card card = game.getCard(firstTarget);
|
||||
Card targetCard = game.getCard(id);
|
||||
if (card == null || targetCard == null
|
||||
|| !card.getOwnerId().equals(targetCard.getOwnerId())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return super.canTarget(id, source, game);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SereneRemembranceTargetCardsInGraveyard copy() {
|
||||
return new SereneRemembranceTargetCardsInGraveyard(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,10 +71,12 @@ public class SarkhanTheMad extends CardImpl<SarkhanTheMad> {
|
|||
this.color.setRed(true);
|
||||
|
||||
this.addAbility(new LoyaltyAbility(new SarkhanTheMadRevealAndDrawEffect(), 0));
|
||||
|
||||
Target targetCreature = new TargetCreaturePermanent();
|
||||
Ability sacAbility = new LoyaltyAbility(new SarkhanTheMadSacEffect(), -2);
|
||||
sacAbility.addTarget(targetCreature);
|
||||
this.addAbility(sacAbility);
|
||||
|
||||
Ability damageAbility = new LoyaltyAbility(new SarkhanTheMadDragonDamageEffect(), -4);
|
||||
damageAbility.addTarget(new TargetPlayer());
|
||||
this.addAbility(damageAbility);
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.target.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.target.TargetCard;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
|
||||
public class TargetCardInASingleGraveyard extends TargetCard<TargetCardInASingleGraveyard> {
|
||||
|
||||
public TargetCardInASingleGraveyard(int minNumTargets, int maxNumTargets, FilterCard filter) {
|
||||
super(minNumTargets, maxNumTargets, Zone.GRAVEYARD, filter);
|
||||
this.targetName = filter.getMessage();
|
||||
}
|
||||
|
||||
public TargetCardInASingleGraveyard(final TargetCardInASingleGraveyard target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||
UUID firstTarget = this.getFirstTarget();
|
||||
if (firstTarget != null) {
|
||||
Card card = game.getCard(firstTarget);
|
||||
Card targetCard = game.getCard(id);
|
||||
if (card == null || targetCard == null
|
||||
|| !card.getOwnerId().equals(targetCard.getOwnerId())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return super.canTarget(id, source, game);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TargetCardInASingleGraveyard copy() {
|
||||
return new TargetCardInASingleGraveyard(this);
|
||||
}
|
||||
}
|
|
@ -67,8 +67,9 @@ public class TargetCardInGraveyard extends TargetCard<TargetCardInGraveyard> {
|
|||
@Override
|
||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||
Card card = game.getCard(id);
|
||||
if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD)
|
||||
if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) {
|
||||
return filter.match(card, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue