mirror of
https://github.com/correl/mage.git
synced 2024-12-25 19:25:41 +00:00
- Fixed #6220
This commit is contained in:
parent
fbcdda16d1
commit
3510ac0957
1 changed files with 27 additions and 16 deletions
|
@ -4,7 +4,7 @@ package mage.cards.c;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.MageObject;
|
import mage.Mana;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.SpellAbility;
|
import mage.abilities.SpellAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
@ -18,7 +18,6 @@ import mage.constants.Duration;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.SpellAbilityCastMode;
|
import mage.constants.SpellAbilityCastMode;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import static mage.filter.predicate.permanent.ControllerControlsIslandPredicate.filter;
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
|
@ -63,22 +62,34 @@ class CatalystStoneCostReductionEffect extends CostModificationEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(abilityToModify.getControllerId());
|
||||||
if (controller != null) {
|
if (controller != null) {
|
||||||
int generic = abilityToModify.getManaCostsToPay().getMana().getGeneric();
|
Mana mana = abilityToModify.getManaCostsToPay().getMana();
|
||||||
if (generic > 0) {
|
int reduceMax = mana.getGeneric();
|
||||||
ChoiceImpl choice = new ChoiceImpl(false);
|
if (reduceMax > 2) {
|
||||||
Set<String> set = new LinkedHashSet<>();
|
reduceMax = 2;
|
||||||
for (int i = 0; i <= Math.min(2, generic); i++) {
|
}
|
||||||
set.add(String.valueOf(i));
|
if (reduceMax > 0) {
|
||||||
|
int reduce;
|
||||||
|
if (game.inCheckPlayableState()) {
|
||||||
|
reduce = reduceMax;
|
||||||
|
} else {
|
||||||
|
ChoiceImpl choice = new ChoiceImpl(true);
|
||||||
|
Set<String> set = new LinkedHashSet<>();
|
||||||
|
|
||||||
|
for (int i = 0; i <= reduceMax; i++) {
|
||||||
|
set.add(String.valueOf(i));
|
||||||
|
}
|
||||||
|
choice.setChoices(set);
|
||||||
|
choice.setMessage("Reduce flashback cost");
|
||||||
|
|
||||||
|
if (controller.choose(Outcome.Benefit, choice, game)) {
|
||||||
|
reduce = Integer.parseInt(choice.getChoice());
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
choice.setChoices(set);
|
CardUtil.reduceCost(abilityToModify, reduce);
|
||||||
MageObject mageObject = game.getObject(abilityToModify.getSourceId());
|
|
||||||
choice.setMessage("Reduce cost of " + (mageObject != null ? mageObject.getIdName() : filter.getMessage()));
|
|
||||||
if (controller.choose(Outcome.Benefit, choice, game)) {
|
|
||||||
generic = Integer.parseInt(choice.getChoice());
|
|
||||||
}
|
|
||||||
CardUtil.reduceCost(abilityToModify, generic);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue