mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
91 lines
2.8 KiB
Java
91 lines
2.8 KiB
Java
/*
|
|
* Forge: Play Magic: the Gathering.
|
|
* Copyright (C) 2011 Forge Team
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
package forge.card.trigger;
|
|
|
|
import forge.Card;
|
|
import forge.card.spellability.SpellAbility;
|
|
|
|
/**
|
|
* <p>
|
|
* Trigger_Unequip class.
|
|
* </p>
|
|
*
|
|
* @author Forge
|
|
* @version $Id$
|
|
*/
|
|
public class TriggerUnequip extends Trigger {
|
|
|
|
/**
|
|
* <p>
|
|
* Constructor for Trigger_Unequip.
|
|
* </p>
|
|
*
|
|
* @param params
|
|
* a {@link java.util.HashMap} object.
|
|
* @param host
|
|
* a {@link forge.Card} object.
|
|
* @param intrinsic
|
|
* the intrinsic
|
|
*/
|
|
public TriggerUnequip(final java.util.Map<String, String> params, final Card host, final boolean intrinsic) {
|
|
super(params, host, intrinsic);
|
|
}
|
|
|
|
/** {@inheritDoc} */
|
|
@Override
|
|
public final boolean performTest(final java.util.Map<String, Object> runParams2) {
|
|
final Card equipped = (Card) runParams2.get("Card");
|
|
final Card equipment = (Card) runParams2.get("Equipment");
|
|
|
|
if (this.getMapParams().containsKey("ValidCard")) {
|
|
if (!equipped.isValid(this.getMapParams().get("ValidCard").split(","), this.getHostCard().getController(),
|
|
this.getHostCard())) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
if (this.getMapParams().containsKey("ValidEquipment")) {
|
|
if (!equipment.isValid(this.getMapParams().get("ValidEquipment").split(","), this.getHostCard()
|
|
.getController(), this.getHostCard())) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/** {@inheritDoc} */
|
|
@Override
|
|
public final Trigger getCopy() {
|
|
final Trigger copy = new TriggerUnequip(this.getMapParams(), this.getHostCard(), this.isIntrinsic());
|
|
if (this.getOverridingAbility() != null) {
|
|
copy.setOverridingAbility(this.getOverridingAbility());
|
|
}
|
|
|
|
copyFieldsTo(copy);
|
|
return copy;
|
|
}
|
|
|
|
/** {@inheritDoc} */
|
|
@Override
|
|
public final void setTriggeringObjects(final SpellAbility sa) {
|
|
sa.setTriggeringObject("Card", this.getRunParams().get("Card"));
|
|
sa.setTriggeringObject("Equipment", this.getRunParams().get("Equipment"));
|
|
}
|
|
}
|