mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
76 lines
2.4 KiB
Java
76 lines
2.4 KiB
Java
/*
|
|
* Forge: Play Magic: the Gathering.
|
|
* Copyright (C) 2011 Nate
|
|
*
|
|
* 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.replacement;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import forge.AllZoneUtil;
|
|
import forge.Card;
|
|
import forge.card.spellability.SpellAbility;
|
|
|
|
/**
|
|
* TODO: Write javadoc for this type.
|
|
*
|
|
*/
|
|
public class ReplaceGainLife extends ReplacementEffect {
|
|
|
|
/**
|
|
* Instantiates a new replace gain life.
|
|
*
|
|
* @param map the map
|
|
* @param host the host
|
|
*/
|
|
public ReplaceGainLife(HashMap<String, String> map, Card host) {
|
|
super(map, host);
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see forge.card.replacement.ReplacementEffect#canReplace(java.util.HashMap)
|
|
*/
|
|
@Override
|
|
public boolean canReplace(HashMap<String, Object> runParams) {
|
|
if (!runParams.get("Event").equals("GainLife")) {
|
|
return false;
|
|
}
|
|
if (this.getMapParams().containsKey("ValidPlayer")) {
|
|
if (!AllZoneUtil.matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidPlayer").split(","), this.getHostCard())) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see forge.card.replacement.ReplacementEffect#getCopy()
|
|
*/
|
|
@Override
|
|
public ReplacementEffect getCopy() {
|
|
return new ReplaceGainLife(this.getMapParams(), getHostCard());
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see forge.card.replacement.ReplacementEffect#setReplacingObjects(java.util.HashMap, forge.card.spellability.SpellAbility)
|
|
*/
|
|
@Override
|
|
public void setReplacingObjects(HashMap<String, Object> runParams, SpellAbility sa) {
|
|
sa.setReplacingObject("LifeGained", runParams.get("LifeGained"));
|
|
}
|
|
|
|
}
|