[CMR] fixed Rakshasa Debaser - class cast exception in filter on usage;

This commit is contained in:
Oleg Agafonov 2020-12-18 15:54:59 +04:00
parent d39575c24e
commit c13d07b73d
8 changed files with 62 additions and 88 deletions

View file

@ -195,7 +195,7 @@ public class Modes extends LinkedHashMap<UUID, Mode> {
* Return real affected max modes in current game. Use null params for default max modes value.
*
* @param game
* @param source
* @param source can be null for rules generation
* @return
*/
public int getMaxModes(Game game, Ability source) {

View file

@ -1,19 +1,19 @@
package mage.filter.predicate.permanent;
import mage.cards.Card;
import mage.filter.predicate.ObjectSourcePlayer;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.filter.predicate.ObjectPlayer;
import mage.filter.predicate.ObjectPlayerPredicate;
import mage.game.Game;
/**
* @author TheElk801
*/
public enum DefendingPlayerOwnsCardPredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlayer<Card>> {
public enum DefendingPlayerOwnsCardPredicate implements ObjectPlayerPredicate<ObjectPlayer<Card>> {
instance;
@Override
public boolean apply(ObjectSourcePlayer<Card> input, Game game) {
return input.getObject().isOwnedBy(game.getCombat().getDefendingPlayerId(input.getSourceId(), game));
public boolean apply(ObjectPlayer<Card> input, Game game) {
return game.getCombat().getPlayerDefenders(game, false).contains(input.getObject().getOwnerId());
}
@Override

View file

@ -50,6 +50,12 @@ public interface Target extends Serializable {
boolean canTarget(UUID id, Game game);
/**
* @param id
* @param source WARNING, it can be null for AI or other calls from events (TODO: introduce normal source in AI ComputerPlayer)
* @param game
* @return
*/
boolean canTarget(UUID id, Ability source, Game game);
boolean stillLegalTarget(UUID id, Ability source, Game game);

View file

@ -41,6 +41,7 @@ public class TargetActivatedAbility extends TargetObject {
@Override
public boolean canTarget(UUID id, Ability source, Game game) {
// 114.4. A spell or ability on the stack is an illegal target for itself.
if (source != null && source.getSourceId().equals(id)) {
return false;
}
@ -80,7 +81,7 @@ public class TargetActivatedAbility extends TargetObject {
for (StackObject stackObject : game.getStack()) {
if (stackObject.getStackAbility().getAbilityType() == AbilityType.ACTIVATED
&& game.getState().getPlayersInRange(sourceControllerId, game).contains(stackObject.getStackAbility().getControllerId())
&& filter.match(((StackAbility) stackObject), game)) {
&& filter.match(stackObject, game)) {
possibleTargets.add(stackObject.getStackAbility().getId());
}
}

View file

@ -1,9 +1,5 @@
package mage.target.common;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbility;
import mage.constants.Zone;
@ -13,8 +9,11 @@ import mage.game.Game;
import mage.game.stack.StackObject;
import mage.target.TargetObject;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
*
* @author Styxo
*/
public class TargetTriggeredAbility extends TargetObject {
@ -32,6 +31,7 @@ public class TargetTriggeredAbility extends TargetObject {
@Override
public boolean canTarget(UUID id, Ability source, Game game) {
// 114.4. A spell or ability on the stack is an illegal target for itself.
if (source != null && source.getSourceId().equals(id)) {
return false;
}