mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
[KHM] Implemented Doomskar Oracle
This commit is contained in:
parent
924663f27e
commit
91c8e1f5b5
7 changed files with 151 additions and 194 deletions
|
|
@ -0,0 +1,78 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.hint.Hint;
|
||||
import mage.abilities.hint.ValueHint;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.watchers.common.CastSpellLastTurnWatcher;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class CastSecondSpellTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private static final Hint hint = new ValueHint("Spells you cast this turn", SpellCastValue.instance);
|
||||
|
||||
public CastSecondSpellTriggeredAbility(Effect effect) {
|
||||
this(Zone.BATTLEFIELD, effect, false);
|
||||
}
|
||||
|
||||
public CastSecondSpellTriggeredAbility(Zone zone, Effect effect, boolean optional) {
|
||||
super(zone, effect, optional);
|
||||
this.addWatcher(new CastSpellLastTurnWatcher());
|
||||
this.addHint(hint);
|
||||
}
|
||||
|
||||
private CastSecondSpellTriggeredAbility(final CastSecondSpellTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.SPELL_CAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (!isControlledBy(event.getPlayerId())) {
|
||||
return false;
|
||||
}
|
||||
CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class);
|
||||
return watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever you cast your second spell each turn, " + super.getRule();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CastSecondSpellTriggeredAbility copy() {
|
||||
return new CastSecondSpellTriggeredAbility(this);
|
||||
}
|
||||
}
|
||||
|
||||
enum SpellCastValue implements DynamicValue {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class);
|
||||
return watcher != null ? watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(sourceAbility.getControllerId()) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellCastValue copy() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue