mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 21:02:08 -08:00
[DMU] Implemented Anointed Peacekeeper (#9478)
This commit is contained in:
parent
71feacf9de
commit
a5621cf247
7 changed files with 168 additions and 60 deletions
|
|
@ -11,6 +11,7 @@ import mage.constants.Outcome;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetOpponent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.Set;
|
||||
|
|
@ -86,20 +87,47 @@ public class ChooseACardNameEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
private final TypeOfName typeOfName;
|
||||
private final boolean lookAtOpponentHand;
|
||||
|
||||
public ChooseACardNameEffect(TypeOfName typeOfName) {
|
||||
this(typeOfName, false);
|
||||
}
|
||||
|
||||
public ChooseACardNameEffect(TypeOfName typeOfName, boolean lookAtOpponentHand) {
|
||||
super(Outcome.Detriment);
|
||||
this.typeOfName = typeOfName;
|
||||
staticText = "choose " + CardUtil.addArticle(typeOfName.description);
|
||||
this.lookAtOpponentHand = lookAtOpponentHand;
|
||||
if (lookAtOpponentHand) {
|
||||
staticText = "look at an opponent's hand, then choose any " + typeOfName.description;
|
||||
} else {
|
||||
staticText = "choose " + CardUtil.addArticle(typeOfName.description);
|
||||
}
|
||||
}
|
||||
|
||||
public ChooseACardNameEffect(final ChooseACardNameEffect effect) {
|
||||
super(effect);
|
||||
this.typeOfName = effect.typeOfName;
|
||||
this.lookAtOpponentHand = effect.lookAtOpponentHand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (lookAtOpponentHand) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
TargetOpponent target = new TargetOpponent(true);
|
||||
if (player.choose(Outcome.Benefit, target, source, game)) {
|
||||
Player opponent = game.getPlayer(target.getFirstTarget());
|
||||
if (opponent != null) {
|
||||
MageObject sourceObject = game.getObject(source);
|
||||
player.lookAtCards(sourceObject != null ? sourceObject.getIdName() : null, opponent.getHand(), game);
|
||||
player.chooseUse(Outcome.Benefit, "Press Ok to name a card",
|
||||
"You won't be able to resize the window showing opponents hand once you do",
|
||||
"Ok", "", source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return typeOfName.getChoice(game, source) != null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -126,12 +126,12 @@ public class SpellsCostIncreasingAllEffect extends CostModificationEffectImpl {
|
|||
Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
|
||||
if (spell != null) {
|
||||
// real cast with put on stack
|
||||
return this.filter.match(spell, game);
|
||||
return this.filter.match(spell, sourceController.getId(), source, game);
|
||||
} else {
|
||||
// get playable and other staff without put on stack
|
||||
// used at least for flashback ability because Flashback ability doesn't use stack
|
||||
Card sourceCard = ((SpellAbility) abilityToModify).getCharacteristics(game);
|
||||
return this.filter.match(sourceCard, game);
|
||||
return this.filter.match(sourceCard, sourceController.getId(), source, game);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
package mage.filter.predicate.mageobject;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.effects.common.ChooseACardNameEffect;
|
||||
import mage.filter.predicate.ObjectSourcePlayer;
|
||||
import mage.filter.predicate.ObjectSourcePlayerPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
* To be used with ChooseACardNameEffect
|
||||
*
|
||||
* @author weirddan455
|
||||
*/
|
||||
public enum ChosenNamePredicate implements ObjectSourcePlayerPredicate<MageObject> {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(ObjectSourcePlayer<MageObject> input, Game game) {
|
||||
String cardName = (String) game.getState().getValue(
|
||||
input.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY
|
||||
);
|
||||
return CardUtil.haveSameNames(input.getObject().getName(), cardName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Chosen name";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue