mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 21:42:07 -08:00
* Jeweled Lotus - fixed that mana can't be used to cast commanders without normal mana (#7272);
This commit is contained in:
parent
736901efcf
commit
347a3b1e1a
5 changed files with 104 additions and 9 deletions
|
|
@ -16,6 +16,7 @@ import mage.abilities.mana.builder.ConditionalManaBuilder;
|
|||
import mage.cards.Card;
|
||||
import mage.filter.FilterSpell;
|
||||
import mage.game.Game;
|
||||
import mage.game.command.Commander;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
|
||||
|
|
@ -65,13 +66,20 @@ class SpellCastManaCondition extends ManaCondition implements Condition {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
if (source instanceof SpellAbility) {
|
||||
MageObject object = game.getObject(source.getSourceId());
|
||||
if (game.inCheckPlayableState() && object instanceof Card) {
|
||||
Spell spell = new Spell((Card) object, (SpellAbility) source, source.getControllerId(), game.getState().getZone(source.getSourceId()), game);
|
||||
return filter.match(spell, source.getSourceId(), source.getControllerId(), game);
|
||||
}
|
||||
if ((object instanceof StackObject)) {
|
||||
return filter.match((StackObject) object, source.getSourceId(), source.getControllerId(), game);
|
||||
}
|
||||
|
||||
// checking mana without real cast
|
||||
if (game.inCheckPlayableState()) {
|
||||
Spell spell = null;
|
||||
if (object instanceof Card) {
|
||||
spell = new Spell((Card) object, (SpellAbility) source, source.getControllerId(), game.getState().getZone(source.getSourceId()), game);
|
||||
} else if (object instanceof Commander) {
|
||||
spell = new Spell(((Commander) object).getSourceObject(), (SpellAbility) source, source.getControllerId(), game.getState().getZone(source.getSourceId()), game);
|
||||
}
|
||||
return spell != null && filter.match(spell, source.getSourceId(), source.getControllerId(), game);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ public enum CommanderPredicate implements Predicate<MageObject> {
|
|||
|
||||
@Override
|
||||
public boolean apply(MageObject input, Game game) {
|
||||
Player owner = game.getPlayer(game.getOwnerId(input.getId()));
|
||||
return owner != null && game.getCommandersIds(owner).contains(input.getId());
|
||||
Player owner = game.getPlayer(game.getOwnerId(input));
|
||||
return owner != null && game.isCommanderObject(owner, input);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import mage.choices.Choice;
|
|||
import mage.constants.*;
|
||||
import mage.counters.Counters;
|
||||
import mage.game.combat.Combat;
|
||||
import mage.game.command.CommandObject;
|
||||
import mage.game.command.Commander;
|
||||
import mage.game.command.Emblem;
|
||||
import mage.game.command.Plane;
|
||||
|
|
@ -519,6 +520,27 @@ public interface Game extends MageItem, Serializable {
|
|||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds is it a commander card/object (use it in conditional and other things)
|
||||
*
|
||||
* @param player
|
||||
* @param object
|
||||
* @return
|
||||
*/
|
||||
default boolean isCommanderObject(Player player, MageObject object) {
|
||||
UUID idToCheck = null;
|
||||
if (object instanceof Spell) {
|
||||
idToCheck = ((Spell) object).getCard().getId();
|
||||
}
|
||||
if (object instanceof CommandObject) {
|
||||
idToCheck = object.getId();
|
||||
}
|
||||
if (object instanceof Card) {
|
||||
idToCheck = ((Card) object).getMainCard().getId();
|
||||
}
|
||||
return idToCheck != null && this.getCommandersIds(player).contains(idToCheck);
|
||||
}
|
||||
|
||||
void setGameStopped(boolean gameStopped);
|
||||
|
||||
boolean isGameStopped();
|
||||
|
|
|
|||
|
|
@ -436,19 +436,23 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
|
||||
@Override
|
||||
public UUID getOwnerId(MageObject object) {
|
||||
if (object instanceof Card) {
|
||||
return ((Card) object).getOwnerId();
|
||||
}
|
||||
if (object instanceof Spell) {
|
||||
return ((Spell) object).getOwnerId();
|
||||
}
|
||||
|
||||
if (object instanceof StackObject) {
|
||||
// maybe this is not correct in all cases?
|
||||
return ((StackObject) object).getControllerId();
|
||||
}
|
||||
|
||||
if (object instanceof CommandObject) {
|
||||
return ((CommandObject) object).getControllerId();
|
||||
}
|
||||
|
||||
if (object instanceof Card) {
|
||||
return ((Card) object).getOwnerId();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue