* Arachnuns Web - Fixed condition handling. Some renaming.

This commit is contained in:
LevelX2 2017-03-12 10:36:51 +01:00
parent 105ef6e571
commit 1b2636d0cd
26 changed files with 95 additions and 113 deletions

View file

@ -34,17 +34,16 @@ import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
* Describes condition when equipped permanent has superType
*
* @author LevelX
*/
public class EquippedMatchesFilterCondition implements Condition {
public class AttachedToMatchesFilterCondition implements Condition {
private final FilterPermanent filter;
public EquippedMatchesFilterCondition(FilterPermanent filter) {
public AttachedToMatchesFilterCondition(FilterPermanent filter) {
this.filter = filter;
}
@ -57,7 +56,7 @@ public class EquippedMatchesFilterCondition implements Condition {
attachedTo = (Permanent) game.getLastKnownInformation(permanent.getAttachedTo(), Zone.BATTLEFIELD);
}
if (attachedTo != null) {
if (filter.match(attachedTo, attachedTo.getId(),attachedTo.getControllerId(), game)) {
if (filter.match(attachedTo, attachedTo.getId(), attachedTo.getControllerId(), game)) {
return true;
}
@ -65,4 +64,10 @@ public class EquippedMatchesFilterCondition implements Condition {
}
return false;
}
@Override
public String toString() {
return filter.getMessage();
}
}

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.condition.common;
import mage.abilities.Ability;
@ -40,13 +39,11 @@ import mage.game.permanent.Permanent;
*
* @author fireshoes
*/
public class EnchantedCreatureSubtypeCondition implements Condition {
private final FilterPermanent filter = new FilterCreaturePermanent();
public EnchantedCreatureSubtypeCondition(String string){
public EnchantedCreatureSubtypeCondition(String string) {
filter.add(new SubtypePredicate(string));
}
@ -56,11 +53,17 @@ public class EnchantedCreatureSubtypeCondition implements Condition {
if (enchantment != null) {
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
if (creature != null) {
if(filter.match(creature, source.getSourceId(), enchantment.getControllerId(), game)){
if (filter.match(creature, source.getSourceId(), enchantment.getControllerId(), game)) {
return true;
}
}
}
return false;
}
@Override
public String toString() {
return filter.getMessage();
}
}

View file

@ -37,40 +37,40 @@ import mage.game.permanent.Permanent;
*
* @author LoneFox
*/
public class DestroyAttachedEffect extends OneShotEffect {
public class DestroyAttachedToEffect extends OneShotEffect {
private final boolean noRegen;
public DestroyAttachedEffect(String description) {
public DestroyAttachedToEffect(String description) {
this(description, false);
}
public DestroyAttachedEffect(String description, boolean noRegen) {
public DestroyAttachedToEffect(String description, boolean noRegen) {
super(Outcome.DestroyPermanent);
this.noRegen = noRegen;
this.staticText = "destroy " + description;
if(noRegen) {
if (noRegen) {
this.staticText += ". It can't be regenerated";
}
}
public DestroyAttachedEffect(final DestroyAttachedEffect effect) {
public DestroyAttachedToEffect(final DestroyAttachedToEffect effect) {
super(effect);
this.noRegen = effect.noRegen;
}
@Override
public DestroyAttachedEffect copy() {
return new DestroyAttachedEffect(this);
public DestroyAttachedToEffect copy() {
return new DestroyAttachedToEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
if(enchantment != null) {
Permanent enchanted = game.getPermanent(enchantment.getAttachedTo());
if(enchanted != null) {
return enchanted.destroy(source.getSourceId(), game, noRegen);
Permanent attachment = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (attachment != null && attachment.getAttachedTo() != null) {
Permanent attachedTo = game.getPermanent(attachment.getAttachedTo());
if (attachedTo != null) {
return attachedTo.destroy(source.getSourceId(), game, noRegen);
}
}
return false;

View file

@ -1,16 +1,16 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,17 +20,16 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.effects.common;
import mage.constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -49,7 +48,7 @@ public class DestroySourceEffect extends OneShotEffect {
public DestroySourceEffect(boolean noRegen) {
super(Outcome.DestroyPermanent);
this.noRegen = noRegen;
staticText = "Destroy {this}";
staticText = "destroy {this}";
}
public DestroySourceEffect(final DestroySourceEffect effect) {