mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
* Hardened Berserker - Fixed that the cost reduction did only work if no spell cast was canceled.
This commit is contained in:
parent
ab661c44f0
commit
7cac9c9e85
1 changed files with 22 additions and 3 deletions
|
@ -41,6 +41,7 @@ import mage.constants.Outcome;
|
|||
import mage.constants.Rarity;
|
||||
import mage.game.Game;
|
||||
import mage.util.CardUtil;
|
||||
import mage.watchers.common.CastSpellLastTurnWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -72,24 +73,42 @@ public class HardenedBerserker extends CardImpl {
|
|||
|
||||
class HardenedBerserkerSpellsCostReductionEffect extends CostModificationEffectImpl {
|
||||
|
||||
int spellsCast;
|
||||
|
||||
public HardenedBerserkerSpellsCostReductionEffect() {
|
||||
super(Duration.EndOfTurn, Outcome.Benefit, CostModificationType.REDUCE_COST);
|
||||
staticText = "the next spell you cast this turn costs {1} less to cast";
|
||||
}
|
||||
|
||||
protected HardenedBerserkerSpellsCostReductionEffect(HardenedBerserkerSpellsCostReductionEffect effect) {
|
||||
protected HardenedBerserkerSpellsCostReductionEffect(final HardenedBerserkerSpellsCostReductionEffect effect) {
|
||||
super(effect);
|
||||
this.spellsCast = effect.spellsCast;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get("CastSpellLastTurnWatcher");
|
||||
if (watcher != null) {
|
||||
spellsCast = watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(source.getControllerId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||
CardUtil.reduceCost(abilityToModify, 1);
|
||||
discard(); // only one use
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get("CastSpellLastTurnWatcher");
|
||||
if (watcher != null) {
|
||||
if (watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(source.getControllerId()) > spellsCast) {
|
||||
discard(); // only one use
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (abilityToModify instanceof SpellAbility) {
|
||||
return abilityToModify.getControllerId().equals(source.getControllerId());
|
||||
}
|
||||
|
@ -100,4 +119,4 @@ class HardenedBerserkerSpellsCostReductionEffect extends CostModificationEffectI
|
|||
public HardenedBerserkerSpellsCostReductionEffect copy() {
|
||||
return new HardenedBerserkerSpellsCostReductionEffect(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue