mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
checkstyle
This commit is contained in:
@@ -455,6 +455,11 @@ public final class AllZone {
|
|||||||
return Singletons.getModel().getGameState().getTriggerHandler();
|
return Singletons.getModel().getGameState().getTriggerHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the replacement handler.
|
||||||
|
*
|
||||||
|
* @return the replacement handler
|
||||||
|
*/
|
||||||
public static ReplacementHandler getReplacementHandler() {
|
public static ReplacementHandler getReplacementHandler() {
|
||||||
return Singletons.getModel().getGameState().getReplacementHandler();
|
return Singletons.getModel().getGameState().getReplacementHandler();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -397,7 +397,7 @@ public abstract class AllZoneUtil {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* matchesValid.
|
* matchesValid.
|
||||||
|
|||||||
@@ -453,7 +453,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
|
|
||||||
// hacky code below, used to limit the number of times an ability
|
// hacky code below, used to limit the number of times an ability
|
||||||
// can be used per turn like Vampire Bats
|
// can be used per turn like Vampire Bats
|
||||||
// should be put in SpellAbility, but it is put here for conveniance
|
// should be put in SpellAbility, but it is put here for convenience
|
||||||
// this is make public just to make things easy
|
// this is make public just to make things easy
|
||||||
// this code presumes that each card only has one ability that can be
|
// this code presumes that each card only has one ability that can be
|
||||||
// used a limited number of times per turn
|
// used a limited number of times per turn
|
||||||
@@ -2569,8 +2569,8 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Replacement effects
|
//Replacement effects
|
||||||
for (final ReplacementEffect RE : this.getCharacteristics().getReplacementEffects()) {
|
for (final ReplacementEffect replacementEffect : this.getCharacteristics().getReplacementEffects()) {
|
||||||
sb.append(RE.toString() + "\r\n");
|
sb.append(replacementEffect.toString() + "\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// static abilities
|
// static abilities
|
||||||
@@ -2619,7 +2619,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
sb.insert(sb.indexOf(".) ") + 3, "\r\n");
|
sb.insert(sb.indexOf(".) ") + 3, "\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// replace tripple line feeds with double line feeds
|
// replace triple line feeds with double line feeds
|
||||||
int start;
|
int start;
|
||||||
final String s = "\r\n\r\n\r\n";
|
final String s = "\r\n\r\n\r\n";
|
||||||
while (sb.toString().contains(s)) {
|
while (sb.toString().contains(s)) {
|
||||||
@@ -2670,8 +2670,8 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Replacement effects
|
//Replacement effects
|
||||||
for (final ReplacementEffect RE : this.getCharacteristics().getReplacementEffects()) {
|
for (final ReplacementEffect replacementEffect : this.getCharacteristics().getReplacementEffects()) {
|
||||||
sb.append(RE.toString() + "\r\n");
|
sb.append(replacementEffect.toString() + "\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// static abilities
|
// static abilities
|
||||||
@@ -8673,21 +8673,36 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the replacement effects.
|
||||||
|
*
|
||||||
|
* @return the replacement effects
|
||||||
|
*/
|
||||||
public ArrayList<ReplacementEffect> getReplacementEffects() {
|
public ArrayList<ReplacementEffect> getReplacementEffects() {
|
||||||
return this.getCharacteristics().getReplacementEffects();
|
return this.getCharacteristics().getReplacementEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the replacement effects.
|
||||||
|
*
|
||||||
|
* @param res the new replacement effects
|
||||||
|
*/
|
||||||
public void setReplacementEffects(ArrayList<ReplacementEffect> res) {
|
public void setReplacementEffects(ArrayList<ReplacementEffect> res) {
|
||||||
this.getCharacteristics().getReplacementEffects().clear();
|
this.getCharacteristics().getReplacementEffects().clear();
|
||||||
for (ReplacementEffect RE : res) {
|
for (ReplacementEffect replacementEffect : res) {
|
||||||
addReplacementEffect(RE);
|
addReplacementEffect(replacementEffect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addReplacementEffect(ReplacementEffect RE) {
|
/**
|
||||||
ReplacementEffect RECopy = RE.getCopy();
|
* Adds the replacement effect.
|
||||||
RECopy.setHostCard(this);
|
*
|
||||||
this.getCharacteristics().getReplacementEffects().add(RECopy);
|
* @param replacementEffect the rE
|
||||||
|
*/
|
||||||
|
public void addReplacementEffect(ReplacementEffect replacementEffect) {
|
||||||
|
ReplacementEffect replacementEffectCopy = replacementEffect.getCopy();
|
||||||
|
replacementEffectCopy.setHostCard(this);
|
||||||
|
this.getCharacteristics().getReplacementEffects().add(replacementEffectCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end Card class
|
} // end Card class
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
package forge.card.replacement;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -15,8 +32,9 @@ public class ReplaceDamage extends ReplacementEffect {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for Constructor.
|
* TODO: Write javadoc for Constructor.
|
||||||
* @param map
|
*
|
||||||
* @param host
|
* @param map the map
|
||||||
|
* @param host the host
|
||||||
*/
|
*/
|
||||||
public ReplaceDamage(HashMap<String, String> map, Card host) {
|
public ReplaceDamage(HashMap<String, String> map, Card host) {
|
||||||
super(map, host);
|
super(map, host);
|
||||||
@@ -30,33 +48,33 @@ public class ReplaceDamage extends ReplacementEffect {
|
|||||||
if (!runParams.get("Event").equals("DamageDone")) {
|
if (!runParams.get("Event").equals("DamageDone")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (mapParams.containsKey("ValidSource")) {
|
if (getMapParams().containsKey("ValidSource")) {
|
||||||
if (!AllZoneUtil.matchesValid(runParams.get("DamageSource"), mapParams.get("ValidSource").split(","), hostCard)) {
|
if (!AllZoneUtil.matchesValid(runParams.get("DamageSource"), getMapParams().get("ValidSource").split(","), getHostCard())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mapParams.containsKey("ValidTarget")) {
|
if (getMapParams().containsKey("ValidTarget")) {
|
||||||
if (!AllZoneUtil.matchesValid(runParams.get("Affected"), mapParams.get("ValidTarget").split(","), hostCard)) {
|
if (!AllZoneUtil.matchesValid(runParams.get("Affected"), getMapParams().get("ValidTarget").split(","), getHostCard())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mapParams.containsKey("DamageAmount")) {
|
if (getMapParams().containsKey("DamageAmount")) {
|
||||||
String full = mapParams.get("DamageAmount");
|
String full = getMapParams().get("DamageAmount");
|
||||||
String operator = full.substring(0, 2);
|
String operator = full.substring(0, 2);
|
||||||
String operand = full.substring(2);
|
String operand = full.substring(2);
|
||||||
int intoperand = 0;
|
int intoperand = 0;
|
||||||
try {
|
try {
|
||||||
intoperand = Integer.parseInt(operand);
|
intoperand = Integer.parseInt(operand);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
intoperand = CardFactoryUtil.xCount(hostCard, hostCard.getSVar(operand));
|
intoperand = CardFactoryUtil.xCount(getHostCard(), getHostCard().getSVar(operand));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!AllZoneUtil.compare((Integer) runParams.get("DamageAmount"), operator, intoperand)) {
|
if (!AllZoneUtil.compare((Integer) runParams.get("DamageAmount"), operator, intoperand)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mapParams.containsKey("IsCombat")) {
|
if (getMapParams().containsKey("IsCombat")) {
|
||||||
if (mapParams.get("IsCombat").equals("True")) {
|
if (getMapParams().get("IsCombat").equals("True")) {
|
||||||
if (!((Boolean) runParams.get("IsCombat"))) {
|
if (!((Boolean) runParams.get("IsCombat"))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -76,7 +94,7 @@ public class ReplaceDamage extends ReplacementEffect {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ReplacementEffect getCopy() {
|
public ReplacementEffect getCopy() {
|
||||||
return new ReplaceDamage(this.mapParams, this.hostCard);
|
return new ReplaceDamage(this.getMapParams(), this.getHostCard());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
package forge.card.replacement;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -11,6 +28,12 @@ import forge.Card;
|
|||||||
*/
|
*/
|
||||||
public class ReplaceDraw extends ReplacementEffect {
|
public class ReplaceDraw extends ReplacementEffect {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new replace draw.
|
||||||
|
*
|
||||||
|
* @param params the params
|
||||||
|
* @param host the host
|
||||||
|
*/
|
||||||
public ReplaceDraw(final HashMap<String, String> params, final Card host) {
|
public ReplaceDraw(final HashMap<String, String> params, final Card host) {
|
||||||
super(params, host);
|
super(params, host);
|
||||||
}
|
}
|
||||||
@@ -32,9 +55,12 @@ public class ReplaceDraw extends ReplacementEffect {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see forge.card.replacement.ReplacementEffect#getCopy()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ReplacementEffect getCopy() {
|
public ReplacementEffect getCopy() {
|
||||||
return new ReplaceDraw(this.getMapParams(), hostCard);
|
return new ReplaceDraw(this.getMapParams(), getHostCard());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
package forge.card.replacement;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -12,6 +29,12 @@ import forge.card.spellability.SpellAbility;
|
|||||||
*/
|
*/
|
||||||
public class ReplaceGainLife extends ReplacementEffect {
|
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) {
|
public ReplaceGainLife(HashMap<String, String> map, Card host) {
|
||||||
super(map, host);
|
super(map, host);
|
||||||
}
|
}
|
||||||
@@ -38,7 +61,7 @@ public class ReplaceGainLife extends ReplacementEffect {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ReplacementEffect getCopy() {
|
public ReplacementEffect getCopy() {
|
||||||
return new ReplaceGainLife(this.getMapParams(), hostCard);
|
return new ReplaceGainLife(this.getMapParams(), getHostCard());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
package forge.card.replacement;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -6,7 +23,6 @@ import forge.AllZoneUtil;
|
|||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardList;
|
import forge.CardList;
|
||||||
import forge.CardUtil;
|
import forge.CardUtil;
|
||||||
import forge.Player;
|
|
||||||
import forge.Constant.Zone;
|
import forge.Constant.Zone;
|
||||||
import forge.card.abilityfactory.AbilityFactory;
|
import forge.card.abilityfactory.AbilityFactory;
|
||||||
import forge.card.cardfactory.CardFactoryUtil;
|
import forge.card.cardfactory.CardFactoryUtil;
|
||||||
@@ -17,9 +33,13 @@ import forge.card.spellability.SpellAbility;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class ReplacementEffect {
|
public abstract class ReplacementEffect {
|
||||||
protected boolean hasRun = false;
|
|
||||||
|
/** The has run. */
|
||||||
|
private boolean hasRun = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Checks for run.
|
||||||
|
*
|
||||||
* @return the hasRun
|
* @return the hasRun
|
||||||
*/
|
*/
|
||||||
public final boolean hasRun() {
|
public final boolean hasRun() {
|
||||||
@@ -27,14 +47,16 @@ public abstract class ReplacementEffect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param hasRun0 the hasRun to set
|
* Sets the checks for run.
|
||||||
|
*
|
||||||
|
* @param hasRun the hasRun to set
|
||||||
*/
|
*/
|
||||||
public final void setHasRun(boolean hasRun0) {
|
public final void setHasRun(boolean hasRun) {
|
||||||
this.hasRun = hasRun0;
|
this.hasRun = hasRun;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The map params, denoting what to replace. */
|
/** The map params, denoting what to replace. */
|
||||||
protected HashMap<String, String> mapParams = new HashMap<String, String>();
|
private HashMap<String, String> mapParams = new HashMap<String, String>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -50,15 +72,15 @@ public abstract class ReplacementEffect {
|
|||||||
/**
|
/**
|
||||||
* Sets the map params.
|
* Sets the map params.
|
||||||
*
|
*
|
||||||
* @param mapParams0
|
* @param mapParams
|
||||||
* the mapParams to set
|
* the mapParams to set
|
||||||
*/
|
*/
|
||||||
public final void setMapParams(final HashMap<String, String> mapParams0) {
|
public final void setMapParams(final HashMap<String, String> mapParams) {
|
||||||
this.mapParams = mapParams0;
|
this.mapParams = mapParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The host card. */
|
/** The host card. */
|
||||||
protected Card hostCard;
|
private Card hostCard;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -83,11 +105,20 @@ public abstract class ReplacementEffect {
|
|||||||
this.hostCard = c;
|
this.hostCard = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Can replace.
|
||||||
|
*
|
||||||
|
* @param runParams the run params
|
||||||
|
* @return true, if successful
|
||||||
|
*/
|
||||||
public abstract boolean canReplace(final HashMap<String, Object> runParams);
|
public abstract boolean canReplace(final HashMap<String, Object> runParams);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a String
|
||||||
|
*/
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (mapParams.containsKey("Description")) {
|
if (getMapParams().containsKey("Description")) {
|
||||||
return mapParams.get("Description");
|
return getMapParams().get("Description");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return "";
|
return "";
|
||||||
@@ -289,14 +320,31 @@ public abstract class ReplacementEffect {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the copy.
|
||||||
|
*
|
||||||
|
* @return the copy
|
||||||
|
*/
|
||||||
public abstract ReplacementEffect getCopy();
|
public abstract ReplacementEffect getCopy();
|
||||||
|
|
||||||
public void setReplacingObjects(HashMap<String, Object> runParams, SpellAbility sa) {
|
/**
|
||||||
//Should be overriden by replacers that need it.
|
* Sets the replacing objects.
|
||||||
|
*
|
||||||
|
* @param runParams the run params
|
||||||
|
* @param spellAbility the SpellAbility
|
||||||
|
*/
|
||||||
|
public void setReplacingObjects(HashMap<String, Object> runParams, SpellAbility spellAbility) {
|
||||||
|
//Should be overridden by replacers that need it.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new replacement effect.
|
||||||
|
*
|
||||||
|
* @param map the map
|
||||||
|
* @param host the host
|
||||||
|
*/
|
||||||
public ReplacementEffect(final HashMap<String, String> map, final Card host) {
|
public ReplacementEffect(final HashMap<String, String> map, final Card host) {
|
||||||
this.mapParams = map;
|
this.setMapParams(map);
|
||||||
this.hostCard = host;
|
this.setHostCard(host);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
package forge.card.replacement;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Stack;
|
|
||||||
|
|
||||||
import forge.AllZone;
|
import forge.AllZone;
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
@@ -35,7 +51,7 @@ public class ReplacementHandler {
|
|||||||
Player decider = null;
|
Player decider = null;
|
||||||
|
|
||||||
//Figure out who decides which of multiple replacements to apply
|
//Figure out who decides which of multiple replacements to apply
|
||||||
//as well as wether or not to apply optional replacements.
|
//as well as whether or not to apply optional replacements.
|
||||||
if (affected instanceof Player) {
|
if (affected instanceof Player) {
|
||||||
decider = (Player) affected;
|
decider = (Player) affected;
|
||||||
} else {
|
} else {
|
||||||
@@ -43,19 +59,19 @@ public class ReplacementHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Round up Non-static replacement effects ("Until EOT," or "The next time you would..." etc)
|
//Round up Non-static replacement effects ("Until EOT," or "The next time you would..." etc)
|
||||||
for (ReplacementEffect RE : tmpEffects) {
|
for (ReplacementEffect replacementEffect : tmpEffects) {
|
||||||
if (!RE.hasRun() && RE.canReplace(runParams)) {
|
if (!replacementEffect.hasRun() && replacementEffect.canReplace(runParams)) {
|
||||||
possibleReplacers.add(RE);
|
possibleReplacers.add(replacementEffect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Round up Static replacement effects
|
//Round up Static replacement effects
|
||||||
for (Player p : AllZone.getPlayersInGame()) {
|
for (Player p : AllZone.getPlayersInGame()) {
|
||||||
for (Card crd : p.getCardsIn(Zone.Battlefield)) {
|
for (Card crd : p.getCardsIn(Zone.Battlefield)) {
|
||||||
for (ReplacementEffect RE : crd.getReplacementEffects()) {
|
for (ReplacementEffect replacementEffect : crd.getReplacementEffects()) {
|
||||||
if (RE.requirementsCheck()) {
|
if (replacementEffect.requirementsCheck()) {
|
||||||
if (!RE.hasRun() && RE.canReplace(runParams)) {
|
if (!replacementEffect.hasRun() && replacementEffect.canReplace(runParams)) {
|
||||||
possibleReplacers.add(RE);
|
possibleReplacers.add(replacementEffect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,7 +110,7 @@ public class ReplacementHandler {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//AI-logic for deciding wether or not to apply the optional replacement effect happens here.
|
//AI-logic for deciding whether or not to apply the optional replacement effect happens here.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
executeReplacement(runParams, chosenRE);
|
executeReplacement(runParams, chosenRE);
|
||||||
@@ -108,37 +124,37 @@ public class ReplacementHandler {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Runs a single replacement effect.
|
* Runs a single replacement effect.
|
||||||
* @param RE the replacment effect to run
|
* @param replacementEffect the replacement effect to run
|
||||||
*/
|
*/
|
||||||
private void executeReplacement(HashMap<String, Object> runParams, ReplacementEffect RE) {
|
private void executeReplacement(HashMap<String, Object> runParams, ReplacementEffect replacementEffect) {
|
||||||
|
|
||||||
HashMap<String, String> mapParams = RE.getMapParams();
|
HashMap<String, String> mapParams = replacementEffect.getMapParams();
|
||||||
RE.setHasRun(true);
|
replacementEffect.setHasRun(true);
|
||||||
|
|
||||||
if (mapParams.containsKey("Prevent")) {
|
if (mapParams.containsKey("Prevent")) {
|
||||||
if (mapParams.get("Prevent").equals("True")) {
|
if (mapParams.get("Prevent").equals("True")) {
|
||||||
RE.setHasRun(false);
|
replacementEffect.setHasRun(false);
|
||||||
return; //Nothing should replace the event.
|
return; //Nothing should replace the event.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String effectSVar = mapParams.get("ReplaceWith");
|
String effectSVar = mapParams.get("ReplaceWith");
|
||||||
String effectAbString = RE.getHostCard().getSVar(effectSVar);
|
String effectAbString = replacementEffect.getHostCard().getSVar(effectSVar);
|
||||||
|
|
||||||
AbilityFactory AF = new AbilityFactory();
|
AbilityFactory abilityFactory = new AbilityFactory();
|
||||||
|
|
||||||
SpellAbility effectSA = AF.getAbility(effectAbString, RE.getHostCard());
|
SpellAbility effectSA = abilityFactory.getAbility(effectAbString, replacementEffect.getHostCard());
|
||||||
|
|
||||||
RE.setReplacingObjects(runParams, effectSA);
|
replacementEffect.setReplacingObjects(runParams, effectSA);
|
||||||
|
|
||||||
if (RE.getHostCard().getController().isHuman()) {
|
if (replacementEffect.getHostCard().getController().isHuman()) {
|
||||||
AllZone.getGameAction().playSpellAbilityNoStack(effectSA, false);
|
AllZone.getGameAction().playSpellAbilityNoStack(effectSA, false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ComputerUtil.playNoStack(effectSA);
|
ComputerUtil.playNoStack(effectSA);
|
||||||
}
|
}
|
||||||
|
|
||||||
RE.setHasRun(false);
|
replacementEffect.setHasRun(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -964,23 +964,51 @@ public abstract class SpellAbility {
|
|||||||
this.triggeringObjects = new HashMap<String, Object>();
|
this.triggeringObjects = new HashMap<String, Object>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the replacing objects.
|
||||||
|
*
|
||||||
|
* @return the replacing objects
|
||||||
|
*/
|
||||||
public HashMap<String, Object> getReplacingObjects() {
|
public HashMap<String, Object> getReplacingObjects() {
|
||||||
return this.replacingObjects;
|
return this.replacingObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the all replacing objects.
|
||||||
|
*
|
||||||
|
* @param replacedObjects the replaced objects
|
||||||
|
*/
|
||||||
public void setAllReplacingObjects(final HashMap<String, Object> replacedObjects) {
|
public void setAllReplacingObjects(final HashMap<String, Object> replacedObjects) {
|
||||||
this.replacingObjects = replacedObjects;
|
this.replacingObjects = replacedObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the replacing object.
|
||||||
|
*
|
||||||
|
* @param type the type
|
||||||
|
* @param o the o
|
||||||
|
*/
|
||||||
public void setReplacingObject(final String type, final Object o) {
|
public void setReplacingObject(final String type, final Object o) {
|
||||||
this.replacingObjects.put(type, o);
|
this.replacingObjects.put(type, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the replacing object.
|
||||||
|
*
|
||||||
|
* @param type the type
|
||||||
|
* @return the replacing object
|
||||||
|
*/
|
||||||
public Object getReplacingObject(final String type) {
|
public Object getReplacingObject(final String type) {
|
||||||
Object res = this.replacingObjects.get(type);
|
Object res = this.replacingObjects.get(type);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks for replacing object.
|
||||||
|
*
|
||||||
|
* @param type the type
|
||||||
|
* @return true, if successful
|
||||||
|
*/
|
||||||
public boolean hasReplacingObject(final String type) {
|
public boolean hasReplacingObject(final String type) {
|
||||||
return this.replacingObjects.containsKey(type);
|
return this.replacingObjects.containsKey(type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import forge.Card;
|
|||||||
import forge.CardList;
|
import forge.CardList;
|
||||||
import forge.CardUtil;
|
import forge.CardUtil;
|
||||||
import forge.Constant.Zone;
|
import forge.Constant.Zone;
|
||||||
import forge.Player;
|
|
||||||
import forge.PlayerZone;
|
import forge.PlayerZone;
|
||||||
import forge.card.abilityfactory.AbilityFactory;
|
import forge.card.abilityfactory.AbilityFactory;
|
||||||
import forge.card.cardfactory.CardFactoryUtil;
|
import forge.card.cardfactory.CardFactoryUtil;
|
||||||
|
|||||||
Reference in New Issue
Block a user