Files
forge/src/main/java/forge/card/trigger/TriggerAttackersDeclared.java

71 lines
2.2 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 java.util.List;
import java.util.Map;
import forge.Card;
import forge.card.spellability.SpellAbility;
/**
* TODO Write javadoc for this type.
*
*/
public class TriggerAttackersDeclared extends Trigger {
/**
* Instantiates a new trigger_ attackers declared.
*
* @param params
* the params
* @param host
* the host
* @param intrinsic
* the intrinsic
*/
public TriggerAttackersDeclared(final java.util.Map<String, String> params, final Card host, final boolean intrinsic) {
super(params, host, intrinsic);
}
/** {@inheritDoc} */
@Override
public final boolean performTest(final Map<String, Object> runParams2) {
if (this.mapParams.containsKey("SingleAttacker")) {
@SuppressWarnings("unchecked")
final List<Card> attackers = (List<Card>) runParams2.get("Attackers");
if (attackers.size() != 1) {
return false;
}
}
if (this.mapParams.containsKey("AttackingPlayer")) {
if (!matchesValid(runParams2.get("AttackingPlayer"),
this.mapParams.get("AttackingPlayer").split(","), this.getHostCard())) {
return false;
}
}
return true;
}
/** {@inheritDoc} */
@Override
public final void setTriggeringObjects(final SpellAbility sa) {
sa.setTriggeringObject("Attackers", this.getRunParams().get("Attackers"));
}
}