mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
- Added the static ability "CostChange".
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -11766,6 +11766,7 @@ src/main/java/forge/card/staticability/StaticAbility.java svneol=native#text/pla
|
||||
src/main/java/forge/card/staticability/StaticAbilityCantBeCast.java svneol=native#text/plain
|
||||
src/main/java/forge/card/staticability/StaticAbilityCantTarget.java -text
|
||||
src/main/java/forge/card/staticability/StaticAbilityContinuous.java svneol=native#text/plain
|
||||
src/main/java/forge/card/staticability/StaticAbilityCostChange.java -text
|
||||
src/main/java/forge/card/staticability/StaticAbilityETBTapped.java -text
|
||||
src/main/java/forge/card/staticability/StaticAbilityPreventDamage.java svneol=native#text/plain
|
||||
src/main/java/forge/card/staticability/package-info.java svneol=native#text/plain
|
||||
|
||||
@@ -2408,6 +2408,13 @@ public class GameAction {
|
||||
manaCost = new ManaCost(manaC);
|
||||
}
|
||||
} // Khalni Hydra
|
||||
|
||||
for (Card c : cardsInPlay) {
|
||||
final ArrayList<StaticAbility> staticAbilities = c.getStaticAbilities();
|
||||
for (final StaticAbility stAb : staticAbilities) {
|
||||
manaCost = stAb.applyAbility("CostChange", spell, manaCost);
|
||||
}
|
||||
}
|
||||
return manaCost;
|
||||
} // GetSpellCostChange
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import forge.Card;
|
||||
import forge.GameEntity;
|
||||
import forge.Singletons;
|
||||
import forge.card.abilityfactory.AbilityFactory;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
@@ -341,6 +342,35 @@ public class StaticAbility {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply ability.
|
||||
*
|
||||
* @param mode
|
||||
* the mode
|
||||
* @param sa
|
||||
* the SpellAbility
|
||||
* @param originalCost
|
||||
* the originalCost
|
||||
* @return the modified ManaCost
|
||||
*/
|
||||
public final ManaCost applyAbility(final String mode, final SpellAbility sa, final ManaCost originalCost) {
|
||||
|
||||
// don't apply the ability if it hasn't got the right mode
|
||||
if (!this.mapParams.get("Mode").equals(mode)) {
|
||||
return originalCost;
|
||||
}
|
||||
|
||||
if (this.isSuppressed() || !this.checkConditions()) {
|
||||
return originalCost;
|
||||
}
|
||||
|
||||
if (mode.equals("CostChange")) {
|
||||
return StaticAbilityCostChange.applyCostChangeAbility(this, sa, originalCost);
|
||||
}
|
||||
|
||||
return originalCost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply ability.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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.staticability;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import forge.Card;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.player.Player;
|
||||
|
||||
/**
|
||||
* The Class StaticAbility_CantBeCast.
|
||||
*/
|
||||
public class StaticAbilityCostChange {
|
||||
|
||||
/**
|
||||
* Applies CostChange ability.
|
||||
*
|
||||
* @param staticAbility
|
||||
* a StaticAbility
|
||||
* @param sa
|
||||
* the SpellAbility
|
||||
* @param originalCost
|
||||
* a ManaCost
|
||||
*/
|
||||
public static ManaCost applyCostChangeAbility(final StaticAbility staticAbility, final SpellAbility sa
|
||||
, final ManaCost originalCost) {
|
||||
final HashMap<String, String> params = staticAbility.getMapParams();
|
||||
final Card hostCard = staticAbility.getHostCard();
|
||||
final Player activator = sa.getActivatingPlayer();
|
||||
final Card card = sa.getSourceCard();
|
||||
|
||||
if (params.containsKey("ValidCard")
|
||||
&& !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard)) {
|
||||
return originalCost;
|
||||
}
|
||||
|
||||
if (params.containsKey("Activator") && ((activator == null)
|
||||
|| !activator.isValid(params.get("Activator"), hostCard.getController(), hostCard))) {
|
||||
return originalCost;
|
||||
}
|
||||
|
||||
if (params.containsKey("Type") && params.get("Type").equals("Spell") && !sa.isSpell()) {
|
||||
return originalCost;
|
||||
}
|
||||
if (params.containsKey("Type") && params.get("Type").equals("Ability") && !sa.isAbility()) {
|
||||
return originalCost;
|
||||
}
|
||||
|
||||
//modify the cost here
|
||||
return originalCost;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user