mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
[C21] Implemented Excavation Technique
This commit is contained in:
parent
a8696cdeb4
commit
33b7fa3eda
5 changed files with 153 additions and 12 deletions
|
|
@ -9,7 +9,6 @@ import mage.game.events.GameEvent;
|
|||
import mage.game.stack.Spell;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Plopman
|
||||
*/
|
||||
public class CastSourceTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
|
@ -48,19 +47,19 @@ public class CastSourceTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getSourceId().equals(this.getSourceId())) {
|
||||
MageObject spellObject = game.getObject(sourceId);
|
||||
if ((spellObject instanceof Spell)) {
|
||||
Spell spell = (Spell) spellObject;
|
||||
if (spell.getSpellAbility() != null) {
|
||||
for (Effect effect : getEffects()) {
|
||||
effect.setValue(SOURCE_CAST_SPELL_ABILITY, spell.getSpellAbility());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!event.getSourceId().equals(this.getSourceId())) {
|
||||
return false;
|
||||
}
|
||||
MageObject spellObject = game.getObject(sourceId);
|
||||
if ((!(spellObject instanceof Spell))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
Spell spell = (Spell) spellObject;
|
||||
if (spell.getSpellAbility() != null) {
|
||||
getEffects().setValue(SOURCE_CAST_SPELL_ABILITY, spell.getSpellAbility());
|
||||
}
|
||||
getEffects().setValue("spellCast", spell);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.CastSourceTriggeredAbility;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetOpponent;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class DemonstrateAbility extends CastSourceTriggeredAbility {
|
||||
|
||||
public DemonstrateAbility() {
|
||||
super(new DemonstrateEffect(), true);
|
||||
}
|
||||
|
||||
private DemonstrateAbility(final DemonstrateAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DemonstrateAbility copy() {
|
||||
return new DemonstrateAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Demonstrate <i>(When you cast this spell, you may copy it. If you do, " +
|
||||
"choose an opponent to also copy it. Players may choose new targets for their copies.)</i>";
|
||||
}
|
||||
}
|
||||
|
||||
class DemonstrateEffect extends OneShotEffect {
|
||||
|
||||
DemonstrateEffect() {
|
||||
super(Outcome.Benefit);
|
||||
}
|
||||
|
||||
private DemonstrateEffect(final DemonstrateEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DemonstrateEffect copy() {
|
||||
return new DemonstrateEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
Spell spell = (Spell) getValue("spellCast");
|
||||
if (spell == null) {
|
||||
return false;
|
||||
}
|
||||
spell.createCopyOnStack(game, source, source.getControllerId(), true);
|
||||
TargetOpponent target = new TargetOpponent(true);
|
||||
controller.choose(outcome, target, source.getSourceId(), game);
|
||||
if (game.getPlayer(target.getFirstTarget()) != null) {
|
||||
spell.createCopyOnStack(game, source, target.getFirstTarget(), true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue