Small change to StormAbility

This commit is contained in:
North 2012-09-14 10:04:50 +03:00
parent 681be2a70c
commit 3dd3cb2b6c
2 changed files with 12 additions and 33 deletions

View file

@ -45,13 +45,9 @@ import mage.watchers.common.CastSpellLastTurnWatcher;
* *
* @author Plopman * @author Plopman
*/ */
public class StormAbility extends TriggeredAbilityImpl<StormAbility> {
public StormAbility() {
public class StormAbility extends TriggeredAbilityImpl<StormAbility>{
public StormAbility()
{
super(Constants.Zone.STACK, new StormEffect()); super(Constants.Zone.STACK, new StormEffect());
} }
@ -65,18 +61,12 @@ public class StormAbility extends TriggeredAbilityImpl<StormAbility>{
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
if(event.getType() == GameEvent.EventType.SPELL_CAST && event.getSourceId().equals(this.sourceId)) if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getSourceId().equals(this.sourceId)) {
{
StackObject spell = game.getStack().getStackObject(this.sourceId); StackObject spell = game.getStack().getStackObject(this.sourceId);
if(spell instanceof Spell) if (spell instanceof Spell) {
{ for (Effect effect : this.getEffects()) {
for(Effect effect : this.getEffects()) effect.setValue("StormSpell", spell);
{ }
if(effect instanceof StormEffect)
{
((StormEffect)effect).setSpell((Spell)spell);
}
}
return true; return true;
} }
} }
@ -87,28 +77,25 @@ public class StormAbility extends TriggeredAbilityImpl<StormAbility>{
public String getRule() { public String getRule() {
return "Storm"; return "Storm";
} }
} }
class StormEffect extends OneShotEffect<StormEffect> { class StormEffect extends OneShotEffect<StormEffect> {
private Spell spell;
public StormEffect() { public StormEffect() {
super(Constants.Outcome.Copy); super(Constants.Outcome.Copy);
} }
public StormEffect(final StormEffect effect) { public StormEffect(final StormEffect effect) {
super(effect); super(effect);
this.spell = effect.spell;
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Spell spell = (Spell) this.getValue("StormSpell");
if (spell != null) { if (spell != null) {
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get("CastSpellLastTurnWatcher"); CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get("CastSpellLastTurnWatcher");
for(int i = 0; i < watcher.getSpellOrder(spell) - 1; i++) for (int i = 0; i < watcher.getSpellOrder(spell) - 1; i++) {
{
Spell copy = spell.copySpell(); Spell copy = spell.copySpell();
copy.setControllerId(source.getControllerId()); copy.setControllerId(source.getControllerId());
copy.setCopiedSpell(true); copy.setCopiedSpell(true);
@ -124,13 +111,4 @@ class StormEffect extends OneShotEffect<StormEffect> {
public StormEffect copy() { public StormEffect copy() {
return new StormEffect(this); return new StormEffect(this);
} }
public void setSpell(Spell spell) {
this.spell = spell;
}
} }

View file

@ -19,6 +19,7 @@ Mountainwalk|new|
Persist|new| Persist|new|
Plainswalk|new| Plainswalk|new|
Rebound|new| Rebound|new|
Storm|new|
Swampwalk|new| Swampwalk|new|
Totem armor|new| Totem armor|new|
Unblockable|new| Unblockable|new|