mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
- Added Primal Vigor
This commit is contained in:
@@ -39,7 +39,9 @@ public class AbilityUtils {
|
||||
|
||||
public static CounterType getCounterType(String name, SpellAbility sa) throws Exception {
|
||||
CounterType counterType;
|
||||
|
||||
if ("ReplacedCounterType".equals(name)) {
|
||||
name = (String) sa.getReplacingObject("CounterType");
|
||||
}
|
||||
try {
|
||||
counterType = CounterType.getType(name);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -91,7 +91,7 @@ public class CountersPutEffect extends SpellAbilityEffect {
|
||||
final Zone zone = tgtCard.getGame().getZoneOf(tgtCard);
|
||||
if (zone == null || zone.is(ZoneType.Battlefield) || zone.is(ZoneType.Stack)) {
|
||||
if (remember) {
|
||||
final int value = tgtCard.getTotalCountersToAdd(counterType, counterAmount, true);
|
||||
final int value = tgtCard.getTotalCountersToAdd();
|
||||
tgtCard.addCountersAddedBy(card, counterType, value);
|
||||
}
|
||||
tgtCard.addCounter(counterType, counterAmount, true);
|
||||
|
||||
@@ -250,6 +250,8 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
// Zone-changing spells should store card's zone here
|
||||
private Zone currentZone = null;
|
||||
|
||||
private int countersAdded = 0;
|
||||
|
||||
// Enumeration for CMC request types
|
||||
public enum SplitCMCMode {
|
||||
CurrentSideCMC,
|
||||
@@ -1128,22 +1130,37 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
return true;
|
||||
}
|
||||
|
||||
public final int getTotalCountersToAdd(final CounterType counterType, final int baseAmount, final boolean applyMultiplier) {
|
||||
if (this.canReceiveCounters(counterType)) {
|
||||
final int multiplier = applyMultiplier ? this.getController().getCounterDoublersMagnitude(counterType) : 1;
|
||||
int result = multiplier * baseAmount;
|
||||
if (counterType == CounterType.DREAM && this.hasKeyword("CARDNAME can't have more than seven dream counters on it.")) {
|
||||
result = Math.min(7 - this.getCounters(CounterType.DREAM), result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return 0;
|
||||
public final int getTotalCountersToAdd() {
|
||||
return countersAdded;
|
||||
}
|
||||
|
||||
public final void setTotalCountersToAdd(int value) {
|
||||
countersAdded = value;
|
||||
}
|
||||
|
||||
public final void addCounter(final CounterType counterType, final int n, final boolean applyMultiplier) {
|
||||
final int addAmount = getTotalCountersToAdd(counterType, n, applyMultiplier);
|
||||
if (addAmount == 0)
|
||||
int addAmount = n;
|
||||
final HashMap<String, Object> repParams = new HashMap<String, Object>();
|
||||
repParams.put("Event", "AddCounter");
|
||||
repParams.put("Affected", this);
|
||||
repParams.put("CounterType", counterType);
|
||||
repParams.put("CounterNum", addAmount);
|
||||
repParams.put("EffectOnly", applyMultiplier);
|
||||
if (this.getGame().getReplacementHandler().run(repParams) != ReplacementResult.NotReplaced) {
|
||||
return;
|
||||
}
|
||||
if (this.canReceiveCounters(counterType)) {
|
||||
if (counterType == CounterType.DREAM && this.hasKeyword("CARDNAME can't have more than seven dream counters on it.")) {
|
||||
addAmount = Math.min(7 - this.getCounters(CounterType.DREAM), addAmount);
|
||||
}
|
||||
} else {
|
||||
addAmount = 0;
|
||||
}
|
||||
|
||||
if (addAmount == 0) {
|
||||
return;
|
||||
}
|
||||
this.setTotalCountersToAdd(addAmount);
|
||||
|
||||
Integer oldValue = this.counters.get(counterType);
|
||||
int newValue = addAmount + (oldValue == null ? 0 : oldValue.intValue());
|
||||
|
||||
@@ -2857,19 +2857,11 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
return CardLists.filter(getCardsIn(ZoneType.Battlefield), CardPredicates.isColor(MagicColor.fromName(color)));
|
||||
}
|
||||
|
||||
public int getCounterDoublersMagnitude(final CounterType type) {
|
||||
int counterDoublers = getCardsIn(ZoneType.Battlefield, "Doubling Season").size()
|
||||
+ CardLists.filter(getGame().getCardsIn(ZoneType.Command),
|
||||
CardPredicates.nameEquals("Selesnya Loft Gardens")).size();
|
||||
if (type == CounterType.P1P1) {
|
||||
counterDoublers += getCardsIn(ZoneType.Battlefield, "Corpsejack Menace").size();
|
||||
}
|
||||
return 1 << counterDoublers;
|
||||
}
|
||||
|
||||
public int getTokenDoublersMagnitude() {
|
||||
final int tokenDoublers = getCardsIn(ZoneType.Battlefield, "Parallel Lives").size()
|
||||
+ getCardsIn(ZoneType.Battlefield, "Doubling Season").size()
|
||||
+ CardLists.filter(getGame().getCardsIn(ZoneType.Battlefield),
|
||||
CardPredicates.nameEquals("Primal Vigor")).size()
|
||||
+ CardLists.filter(getGame().getCardsIn(ZoneType.Command),
|
||||
CardPredicates.nameEquals("Selesnya Loft Gardens")).size();;
|
||||
return 1 << tokenDoublers; // pow(a,0) = 1; pow(a,1) = a
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package forge.game.replacement;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
public class ReplaceAddCounter extends ReplacementEffect {
|
||||
|
||||
/**
|
||||
*
|
||||
* ReplaceProduceMana.
|
||||
* @param mapParams   HashMap<String, String>
|
||||
* @param host   Card
|
||||
*/
|
||||
public ReplaceAddCounter(final Map<String, String> mapParams, final Card host, final boolean intrinsic) {
|
||||
super(mapParams, host, intrinsic);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.replacement.ReplacementEffect#canReplace(java.util.HashMap)
|
||||
*/
|
||||
@Override
|
||||
public boolean canReplace(Map<String, Object> runParams) {
|
||||
if (!runParams.get("Event").equals("AddCounter")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mapParams.containsKey("EffectOnly")) {
|
||||
final Boolean effectOnly = (Boolean) runParams.get("EffectOnly");
|
||||
if (!effectOnly) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (mapParams.containsKey("ValidCard")) {
|
||||
if (!matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidCard").split(","), this.getHostCard())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (mapParams.containsKey("ValidCounterType")) {
|
||||
String type = this.getMapParams().get("ValidCounterType");
|
||||
if (CounterType.getType(type) != runParams.get("CounterType")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.replacement.ReplacementEffect#setReplacingObjects(java.util.HashMap, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
public void setReplacingObjects(Map<String, Object> runParams, SpellAbility sa) {
|
||||
sa.setReplacingObject("CounterNum", runParams.get("CounterNum"));
|
||||
sa.setReplacingObject("CounterType", ((CounterType) runParams.get("CounterType")).getName());
|
||||
sa.setReplacingObject("Card", runParams.get("Affected"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import forge.game.card.Card;
|
||||
*
|
||||
*/
|
||||
public enum ReplacementType {
|
||||
AddCounter(ReplaceAddCounter.class),
|
||||
Counter(ReplaceCounter.class),
|
||||
DamageDone(ReplaceDamage.class),
|
||||
Destroy(ReplaceDestroy.class),
|
||||
|
||||
Reference in New Issue
Block a user