This commit is contained in:
Loki 2011-02-08 23:39:21 +02:00
parent e2fd0299c7
commit 325384e73c
4 changed files with 54 additions and 54 deletions

View file

@ -38,6 +38,7 @@ import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.AttacksOrBlocksTriggeredAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.effects.common.counter.RemoveCounterSourceEffect;
@ -88,10 +89,10 @@ class ClockworkCondorEffect extends OneShotEffect<ClockworkCondorEffect> {
public boolean apply(Game game, Ability source) {
Permanent p = game.getPermanent(source.getSourceId());
if (p != null) {
ClockworkDragonDelayedTriggeredAbility delayedAbility = new ClockworkDragonDelayedTriggeredAbility();
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
game.addDelayedTriggeredAbility(delayedAbility);
AtTheEndOfCombatDelayedTriggeredAbility ability = new AtTheEndOfCombatDelayedTriggeredAbility(new RemoveCounterSourceEffect(CounterType.P1P1.createInstance()));
ability.setSourceId(source.getSourceId());
ability.setControllerId(source.getControllerId());
game.addDelayedTriggeredAbility(ability);
}
return false;
}
@ -106,26 +107,3 @@ class ClockworkCondorEffect extends OneShotEffect<ClockworkCondorEffect> {
return "remove a +1/+1 counter from Clockwork Condor at end of combat";
}
}
class ClockworkCondorDelayedTriggeredAbility extends DelayedTriggeredAbility<ClockworkCondorDelayedTriggeredAbility> {
ClockworkCondorDelayedTriggeredAbility() {
super(new RemoveCounterSourceEffect(CounterType.P1P1.createInstance()));
}
ClockworkCondorDelayedTriggeredAbility(final ClockworkCondorDelayedTriggeredAbility ability) {
super(ability);
}
@Override
public ClockworkCondorDelayedTriggeredAbility copy() {
return new ClockworkCondorDelayedTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.COMBAT_PHASE_POST) {
return true;
}
return false;
}
}

View file

@ -40,6 +40,7 @@ import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.AttacksOrBlocksTriggeredAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
@ -92,10 +93,10 @@ class ClockworkDragonEffect extends OneShotEffect<ClockworkDragonEffect> {
public boolean apply(Game game, Ability source) {
Permanent p = game.getPermanent(source.getSourceId());
if (p != null) {
ClockworkDragonDelayedTriggeredAbility delayedAbility = new ClockworkDragonDelayedTriggeredAbility();
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
game.addDelayedTriggeredAbility(delayedAbility);
AtTheEndOfCombatDelayedTriggeredAbility ability = new AtTheEndOfCombatDelayedTriggeredAbility(new RemoveCounterSourceEffect(CounterType.P1P1.createInstance()));
ability.setSourceId(source.getSourceId());
ability.setControllerId(source.getControllerId());
game.addDelayedTriggeredAbility(ability);
}
return false;
}
@ -110,26 +111,3 @@ class ClockworkDragonEffect extends OneShotEffect<ClockworkDragonEffect> {
return "remove a +1/+1 counter from Clockwork Dragon at end of combat";
}
}
class ClockworkDragonDelayedTriggeredAbility extends DelayedTriggeredAbility<ClockworkDragonDelayedTriggeredAbility> {
ClockworkDragonDelayedTriggeredAbility() {
super(new RemoveCounterSourceEffect(CounterType.P1P1.createInstance()));
}
ClockworkDragonDelayedTriggeredAbility(final ClockworkDragonDelayedTriggeredAbility ability) {
super(ability);
}
@Override
public ClockworkDragonDelayedTriggeredAbility copy() {
return new ClockworkDragonDelayedTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.COMBAT_PHASE_POST) {
return true;
}
return false;
}
}

View file

@ -0,0 +1,34 @@
package mage.abilities.common.delayed;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.game.Game;
import mage.game.events.GameEvent;
public class AtTheEndOfCombatDelayedTriggeredAbility extends DelayedTriggeredAbility<AtTheEndOfCombatDelayedTriggeredAbility> {
public AtTheEndOfCombatDelayedTriggeredAbility(Effect effect) {
super(effect);
}
public AtTheEndOfCombatDelayedTriggeredAbility(AtTheEndOfCombatDelayedTriggeredAbility ability) {
super(ability);
}
@Override
public AtTheEndOfCombatDelayedTriggeredAbility copy() {
return new AtTheEndOfCombatDelayedTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.COMBAT_PHASE_POST) {
return true;
}
return false;
}
@Override
public String getRule() {
return "At end of combat, " + effects.getText(this);
}
}

View file

@ -34,4 +34,14 @@ public class RemoveCounterSourceEffect extends OneShotEffect<RemoveCounterSource
public RemoveCounterSourceEffect copy() {
return new RemoveCounterSourceEffect(this);
}
@Override
public String getText(Ability source) {
if (counter.getCount() > 1) {
StringBuilder sb = new StringBuilder();
sb.append("remove ").append(Integer.toString(counter.getCount())).append(" ").append(counter.getName()).append(" counters from {this}");
return sb.toString();
} else
return "remove a " + counter.getName() + " counter from {this}";
}
}