mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
Added can cast cards from graveyard flag to player.
This commit is contained in:
parent
86a6251997
commit
ab721bc1c2
4 changed files with 47 additions and 1 deletions
|
@ -35,6 +35,7 @@ import mage.constants.Zone;
|
||||||
import mage.abilities.keyword.ProtectionAbility;
|
import mage.abilities.keyword.ProtectionAbility;
|
||||||
import mage.abilities.mana.ManaAbility;
|
import mage.abilities.mana.ManaAbility;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.players.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a collection of {@link Ability Abilities}. This is the top most
|
* Represents a collection of {@link Ability Abilities}. This is the top most
|
||||||
|
@ -71,6 +72,16 @@ public interface Abilities<T extends Ability> extends List<T>, Serializable {
|
||||||
*/
|
*/
|
||||||
Abilities<ActivatedAbility> getActivatedAbilities(Zone zone);
|
Abilities<ActivatedAbility> getActivatedAbilities(Zone zone);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves all playable abilities for the given {@link Zone}.
|
||||||
|
*
|
||||||
|
* @param zone The {@link Zone} for which abilities should be retrieved.
|
||||||
|
* @return All abilities for the given {@link Zone}
|
||||||
|
*
|
||||||
|
* @see mage.cards.CardImpl#getSpellAbility()
|
||||||
|
*/
|
||||||
|
Abilities<ActivatedAbility> getPlayableAbilities(Zone zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves all {@link ManaAbility mana abilities} in the given {@link Zone}.
|
* Retrieves all {@link ManaAbility mana abilities} in the given {@link Zone}.
|
||||||
*
|
*
|
||||||
|
|
|
@ -129,6 +129,18 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
|
||||||
return zonedAbilities;
|
return zonedAbilities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Abilities<ActivatedAbility> getPlayableAbilities(Zone zone) {
|
||||||
|
Abilities<ActivatedAbility> zonedAbilities = new AbilitiesImpl<>();
|
||||||
|
for (T ability: this) {
|
||||||
|
if (((ability instanceof SpellAbility) || (ability instanceof PlayLandAbility))
|
||||||
|
&& ability.getZone().match(zone)) {
|
||||||
|
zonedAbilities.add((ActivatedAbility)ability);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return zonedAbilities;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Abilities<ManaAbility> getManaAbilities(Zone zone) {
|
public Abilities<ManaAbility> getManaAbilities(Zone zone) {
|
||||||
Abilities<ManaAbility> abilities = new AbilitiesImpl<>();
|
Abilities<ManaAbility> abilities = new AbilitiesImpl<>();
|
||||||
|
|
|
@ -102,8 +102,10 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
boolean canPaySacrificeCost();
|
boolean canPaySacrificeCost();
|
||||||
void setLifeTotalCanChange(boolean lifeTotalCanChange);
|
void setLifeTotalCanChange(boolean lifeTotalCanChange);
|
||||||
boolean isLifeTotalCanChange();
|
boolean isLifeTotalCanChange();
|
||||||
void setLoseByZeroOrLessLife(boolean LoseByZeroOrLessLife);
|
void setLoseByZeroOrLessLife(boolean loseByZeroOrLessLife);
|
||||||
boolean canLoseByZeroOrLessLife();
|
boolean canLoseByZeroOrLessLife();
|
||||||
|
void setPlayCardsFromGraveyard(boolean playCardsFromGraveyard);
|
||||||
|
boolean canPlayCardsFromGraveyard();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns alternative casting costs a player can cast spells for
|
* Returns alternative casting costs a player can cast spells for
|
||||||
|
|
|
@ -179,6 +179,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
||||||
protected boolean canPayLifeCost = true;
|
protected boolean canPayLifeCost = true;
|
||||||
protected boolean canPaySacrificeCost = true;
|
protected boolean canPaySacrificeCost = true;
|
||||||
protected boolean loseByZeroOrLessLife = true;
|
protected boolean loseByZeroOrLessLife = true;
|
||||||
|
protected boolean canPlayCardsFromGraveyard = true;
|
||||||
|
|
||||||
protected final List<AlternativeSourceCosts> alternativeSourceCosts = new ArrayList<>();
|
protected final List<AlternativeSourceCosts> alternativeSourceCosts = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -249,6 +250,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
||||||
this.canGainLife = player.canGainLife;
|
this.canGainLife = player.canGainLife;
|
||||||
this.canLoseLife = player.canLoseLife;
|
this.canLoseLife = player.canLoseLife;
|
||||||
this.loseByZeroOrLessLife = player.loseByZeroOrLessLife;
|
this.loseByZeroOrLessLife = player.loseByZeroOrLessLife;
|
||||||
|
this.canPlayCardsFromGraveyard = player.canPlayCardsFromGraveyard;
|
||||||
|
|
||||||
this.attachments.addAll(player.attachments);
|
this.attachments.addAll(player.attachments);
|
||||||
|
|
||||||
|
@ -313,6 +315,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
||||||
this.canPayLifeCost = player.canPayLifeCost();
|
this.canPayLifeCost = player.canPayLifeCost();
|
||||||
this.canPaySacrificeCost = player.canPaySacrificeCost();
|
this.canPaySacrificeCost = player.canPaySacrificeCost();
|
||||||
this.loseByZeroOrLessLife = player.canLoseByZeroOrLessLife();
|
this.loseByZeroOrLessLife = player.canLoseByZeroOrLessLife();
|
||||||
|
this.canPlayCardsFromGraveyard = player.canPlayCardsFromGraveyard();
|
||||||
this.alternativeSourceCosts.addAll(player.getAlternativeSourceCosts());
|
this.alternativeSourceCosts.addAll(player.getAlternativeSourceCosts());
|
||||||
this.storedBookmark = player.getStoredBookmark();
|
this.storedBookmark = player.getStoredBookmark();
|
||||||
|
|
||||||
|
@ -388,6 +391,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
||||||
this.canPayLifeCost = true;
|
this.canPayLifeCost = true;
|
||||||
this.canPaySacrificeCost = true;
|
this.canPaySacrificeCost = true;
|
||||||
this.loseByZeroOrLessLife = true;
|
this.loseByZeroOrLessLife = true;
|
||||||
|
this.canPlayCardsFromGraveyard = false;
|
||||||
this.topCardRevealed = false;
|
this.topCardRevealed = false;
|
||||||
this.alternativeSourceCosts.clear();
|
this.alternativeSourceCosts.clear();
|
||||||
}
|
}
|
||||||
|
@ -967,6 +971,13 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (zone != Zone.HAND) {
|
if (zone != Zone.HAND) {
|
||||||
|
if (Zone.GRAVEYARD.equals(zone) && canPlayCardsFromGraveyard()) {
|
||||||
|
for (ActivatedAbility ability: object.getAbilities().getPlayableAbilities(Zone.HAND)) {
|
||||||
|
if (ability.canActivate(playerId, game)) {
|
||||||
|
useable.put(ability.getId(), ability);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (zone != Zone.BATTLEFIELD && game.getContinuousEffects().asThough(object.getId(), AsThoughEffectType.CAST, this.getId(), game)) {
|
if (zone != Zone.BATTLEFIELD && game.getContinuousEffects().asThough(object.getId(), AsThoughEffectType.CAST, this.getId(), game)) {
|
||||||
for (Ability ability: object.getAbilities()) {
|
for (Ability ability: object.getAbilities()) {
|
||||||
ability.setControllerId(this.getId());
|
ability.setControllerId(this.getId());
|
||||||
|
@ -2117,6 +2128,16 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
||||||
this.loseByZeroOrLessLife = loseByZeroOrLessLife;
|
this.loseByZeroOrLessLife = loseByZeroOrLessLife;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canPlayCardsFromGraveyard() {
|
||||||
|
return canPlayCardsFromGraveyard;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPlayCardsFromGraveyard(boolean playCardsFromGraveyard) {
|
||||||
|
this.canPlayCardsFromGraveyard = playCardsFromGraveyard;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean autoLoseGame() {
|
public boolean autoLoseGame() {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue