mirror of
https://github.com/magefree/mage.git
synced 2026-01-23 11:49:56 -08:00
Add methods to get information about spells that have not yet been cast.
This commit is contained in:
parent
5a846e9343
commit
339779c8bd
1 changed files with 22 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
package mage.abilities;
|
package mage.abilities;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.MageObjectReference;
|
import mage.MageObjectReference;
|
||||||
|
|
@ -19,6 +20,7 @@ import mage.constants.TimingRule;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.stack.Spell;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -210,6 +212,26 @@ public class SpellAbility extends ActivatedAbilityImpl {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Card getCharachteristics(Game game) {
|
||||||
|
Spell spell = game.getSpell(this.getId());
|
||||||
|
if (spell != null) {
|
||||||
|
return spell;
|
||||||
|
}
|
||||||
|
return game.getCard(this.getSourceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SpellAbility getSpellAbilityFromEvent(GameEvent event, Game game) {
|
||||||
|
if (event.getType() != GameEvent.EventType.CAST_SPELL) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Card card = game.getCard(event.getSourceId());
|
||||||
|
Optional<Ability> ability = card.getAbilities(game).get(event.getTargetId());
|
||||||
|
if (ability.isPresent() && ability.get() instanceof SpellAbility) {
|
||||||
|
return (SpellAbility) ability.get();
|
||||||
|
}
|
||||||
|
return card.getSpellAbility();
|
||||||
|
}
|
||||||
|
|
||||||
public void setId(UUID idToUse) {
|
public void setId(UUID idToUse) {
|
||||||
this.id = idToUse;
|
this.id = idToUse;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue