mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
- Moved isNegativeCounter to ComputerUtil and improved it.
This commit is contained in:
@@ -8236,7 +8236,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
|
|
||||||
/** @return boolean */
|
/** @return boolean */
|
||||||
public boolean isInPlay() {
|
public boolean isInPlay() {
|
||||||
return this.getGame().getCardsIn(ZoneType.Battlefield).contains(this);
|
return this.isInZone(ZoneType.Battlefield);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCleanupPhase(final Player turn) {
|
public void onCleanupPhase(final Player turn) {
|
||||||
|
|||||||
@@ -307,12 +307,4 @@ public enum CounterType {
|
|||||||
final String replacedName = name.replace("/", "").replaceAll("\\+", "p").replaceAll("\\-", "m").toUpperCase();
|
final String replacedName = name.replace("/", "").replaceAll("\\+", "p").replaceAll("\\-", "m").toUpperCase();
|
||||||
return Enum.valueOf(CounterType.class, replacedName);
|
return Enum.valueOf(CounterType.class, replacedName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// although this should be in AI's code
|
|
||||||
public boolean isNegativeCounter() {
|
|
||||||
CounterType c = this;
|
|
||||||
return (c == CounterType.AGE) || (c == CounterType.BLAZE) || (c == CounterType.BRIBERY) || (c == CounterType.DOOM)
|
|
||||||
|| (c == CounterType.ICE) || (c == CounterType.M1M1) || (c == CounterType.M0M2) || (c == CounterType.M0M1)
|
|
||||||
|| (c == CounterType.TIME);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import forge.CardLists;
|
|||||||
import forge.CounterType;
|
import forge.CounterType;
|
||||||
import forge.card.ability.SpellAbilityAi;
|
import forge.card.ability.SpellAbilityAi;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
|
import forge.game.ai.ComputerUtil;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
|
|
||||||
@@ -22,7 +23,7 @@ public class CountersProliferateAi extends SpellAbilityAi {
|
|||||||
@Override
|
@Override
|
||||||
public boolean apply(final Card crd) {
|
public boolean apply(final Card crd) {
|
||||||
for (final CounterType c1 : CounterType.values()) {
|
for (final CounterType c1 : CounterType.values()) {
|
||||||
if (crd.getCounters(c1) != 0 && !c1.isNegativeCounter()) {
|
if (crd.getCounters(c1) != 0 && !ComputerUtil.isNegativeCounter(c1, crd)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,7 +35,7 @@ public class CountersProliferateAi extends SpellAbilityAi {
|
|||||||
@Override
|
@Override
|
||||||
public boolean apply(final Card crd) {
|
public boolean apply(final Card crd) {
|
||||||
for (final CounterType c1 : CounterType.values()) {
|
for (final CounterType c1 : CounterType.values()) {
|
||||||
if (crd.getCounters(c1) != 0 && c1.isNegativeCounter()) {
|
if (crd.getCounters(c1) != 0 && ComputerUtil.isNegativeCounter(c1, crd)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import forge.GameEntity;
|
|||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.ability.SpellAbilityEffect;
|
import forge.card.ability.SpellAbilityEffect;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
|
import forge.game.ai.ComputerUtil;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.gui.input.InputProliferate;
|
import forge.gui.input.InputProliferate;
|
||||||
@@ -56,10 +57,10 @@ public class CountersProliferateEffect extends SpellAbilityEffect {
|
|||||||
@Override
|
@Override
|
||||||
public boolean apply(Card crd) {
|
public boolean apply(Card crd) {
|
||||||
for (final Entry<CounterType, Integer> c1 : crd.getCounters().entrySet()) {
|
for (final Entry<CounterType, Integer> c1 : crd.getCounters().entrySet()) {
|
||||||
if (c1.getKey().isNegativeCounter() && enemies.contains(crd.getController())) {
|
if (ComputerUtil.isNegativeCounter(c1.getKey(), crd) && enemies.contains(crd.getController())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!c1.getKey().isNegativeCounter() && allies.contains(crd.getController())) {
|
if (!ComputerUtil.isNegativeCounter(c1.getKey(), crd) && allies.contains(crd.getController())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,12 +103,12 @@ public class CountersProliferateEffect extends SpellAbilityEffect {
|
|||||||
// computer
|
// computer
|
||||||
for (final Card c : cardsToProliferate) {
|
for (final Card c : cardsToProliferate) {
|
||||||
for (final Entry<CounterType, Integer> c1 : c.getCounters().entrySet()) {
|
for (final Entry<CounterType, Integer> c1 : c.getCounters().entrySet()) {
|
||||||
if (c1.getKey().isNegativeCounter() && enemies.contains(c.getController()))
|
if (ComputerUtil.isNegativeCounter(c1.getKey(), c) && enemies.contains(c.getController()))
|
||||||
{
|
{
|
||||||
c.addCounter(c1.getKey(), 1, true);
|
c.addCounter(c1.getKey(), 1, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!c1.getKey().isNegativeCounter() && allies.contains(c.getController()))
|
if (!ComputerUtil.isNegativeCounter(c1.getKey(), c) && allies.contains(c.getController()))
|
||||||
{
|
{
|
||||||
c.addCounter(c1.getKey(), 1, true);
|
c.addCounter(c1.getKey(), 1, true);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import forge.Singletons;
|
|||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
|
import forge.game.ai.ComputerUtil;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.gui.GuiChoose;
|
import forge.gui.GuiChoose;
|
||||||
@@ -183,7 +184,7 @@ public class CostRemoveAnyCounter extends CostPartWithList {
|
|||||||
}
|
}
|
||||||
Card valid = decision.cards.get(0);
|
Card valid = decision.cards.get(0);
|
||||||
for (CounterType c1 : valid.getCounters().keySet()) {
|
for (CounterType c1 : valid.getCounters().keySet()) {
|
||||||
if (valid.getCounters(c1) >= c && c1.isNegativeCounter()) {
|
if (valid.getCounters(c1) >= c && ComputerUtil.isNegativeCounter(c1, valid)) {
|
||||||
counterType = c1;
|
counterType = c1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -215,7 +216,7 @@ public class CostRemoveAnyCounter extends CostPartWithList {
|
|||||||
@Override
|
@Override
|
||||||
public boolean apply(final Card crd) {
|
public boolean apply(final Card crd) {
|
||||||
for (final CounterType c1 : CounterType.values()) {
|
for (final CounterType c1 : CounterType.values()) {
|
||||||
if (crd.getCounters(c1) >= c && c1.isNegativeCounter()) {
|
if (crd.getCounters(c1) >= c && ComputerUtil.isNegativeCounter(c1, crd)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import forge.Card;
|
|||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
import forge.CardPredicates;
|
import forge.CardPredicates;
|
||||||
import forge.Constant;
|
import forge.Constant;
|
||||||
|
import forge.CounterType;
|
||||||
import forge.CardPredicates.Presets;
|
import forge.CardPredicates.Presets;
|
||||||
import forge.CardUtil;
|
import forge.CardUtil;
|
||||||
import forge.ITargetable;
|
import forge.ITargetable;
|
||||||
@@ -1695,4 +1696,14 @@ public class ComputerUtil {
|
|||||||
});
|
});
|
||||||
return safeCards;
|
return safeCards;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// although this should be in AI's code
|
||||||
|
public static boolean isNegativeCounter(CounterType type, Card c) {
|
||||||
|
return type == CounterType.AGE || type == CounterType.BLAZE || type == CounterType.BRIBERY || type == CounterType.DOOM
|
||||||
|
|| type == CounterType.ICE || type == CounterType.M1M1 || type == CounterType.M0M2 || type == CounterType.M0M1
|
||||||
|
|| type == CounterType.M1M0 || type == CounterType.M2M1 || type == CounterType.M2M2 || type == CounterType.MUSIC
|
||||||
|
|| type == CounterType.PARALYZATION || type == CounterType.SHELL || type == CounterType.SLEEP
|
||||||
|
|| type == CounterType.SLEIGHT || (type == CounterType.TIME && !c.isInPlay()) || type == CounterType.WAGE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user