mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
removed some hardcoded checks for ai player
This commit is contained in:
@@ -42,7 +42,6 @@ import forge.card.spellability.Target;
|
|||||||
import forge.game.phase.PhaseType;
|
import forge.game.phase.PhaseType;
|
||||||
import forge.game.player.ComputerUtil;
|
import forge.game.player.ComputerUtil;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.player.PlayerType;
|
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1484,7 +1483,7 @@ public class AbilityFactory {
|
|||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public static boolean playReusable(final SpellAbility sa) {
|
public static boolean playReusable(final Player ai, final SpellAbility sa) {
|
||||||
// TODO probably also consider if winter orb or similar are out
|
// TODO probably also consider if winter orb or similar are out
|
||||||
|
|
||||||
if (sa.getPayCosts() == null) {
|
if (sa.getPayCosts() == null) {
|
||||||
@@ -1499,8 +1498,8 @@ public class AbilityFactory {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.END_OF_TURN)
|
return Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.END_OF_TURN)
|
||||||
&& Singletons.getModel().getGame().getPhaseHandler().isNextTurn(PlayerType.COMPUTER));
|
&& Singletons.getModel().getGame().getNextPlayerAfter(sa.getActivatingPlayer()).equals(ai);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -383,7 +383,7 @@ public class AbilityFactoryAlterLife {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean randomReturn = r.nextFloat() <= .6667;
|
boolean randomReturn = r.nextFloat() <= .6667;
|
||||||
if (lifeCritical || AbilityFactory.playReusable(sa)) {
|
if (lifeCritical || AbilityFactory.playReusable(ai, sa)) {
|
||||||
randomReturn = true;
|
randomReturn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -808,7 +808,7 @@ public class AbilityFactoryAlterLife {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean randomReturn = r.nextFloat() <= .6667;
|
boolean randomReturn = r.nextFloat() <= .6667;
|
||||||
if (AbilityFactory.playReusable(sa) || priority) {
|
if (AbilityFactory.playReusable(ai, sa) || priority) {
|
||||||
randomReturn = true;
|
randomReturn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1728,7 +1728,7 @@ public final class AbilityFactoryChangeZone {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Blink permanents with ETB triggers
|
// Blink permanents with ETB triggers
|
||||||
else if (sa.isAbility() && (sa.getPayCosts() != null) && AbilityFactory.playReusable(sa)) {
|
else if (sa.isAbility() && (sa.getPayCosts() != null) && AbilityFactory.playReusable(ai, sa)) {
|
||||||
aiPermanents = CardLists.filter(aiPermanents, new Predicate<Card>() {
|
aiPermanents = CardLists.filter(aiPermanents, new Predicate<Card>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(final Card c) {
|
public boolean apply(final Card c) {
|
||||||
|
|||||||
@@ -1949,7 +1949,7 @@ public class AbilityFactoryCounters {
|
|||||||
chance &= subAb.chkAIDrawback();
|
chance &= subAb.chkAIDrawback();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sa.isTrigger() || sa instanceof AbilitySub || AbilityFactory.playReusable(sa)) {
|
if (sa.isTrigger() || sa instanceof AbilitySub || AbilityFactory.playReusable(ai, sa)) {
|
||||||
return chance;
|
return chance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2298,7 +2298,7 @@ public class AbilityFactoryCounters {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return AbilityFactoryCounters.moveCounterCanPlayAI(af, this);
|
return AbilityFactoryCounters.moveCounterCanPlayAI(getActivatingPlayer(), af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2336,7 +2336,7 @@ public class AbilityFactoryCounters {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return AbilityFactoryCounters.moveCounterCanPlayAI(af, this);
|
return AbilityFactoryCounters.moveCounterCanPlayAI(getActivatingPlayer(), af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2469,7 +2469,7 @@ public class AbilityFactoryCounters {
|
|||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean moveCounterCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
private static boolean moveCounterCanPlayAI(final Player ai, final AbilityFactory af, final SpellAbility sa) {
|
||||||
// AI needs to be expanded, since this function can be pretty complex
|
// AI needs to be expanded, since this function can be pretty complex
|
||||||
// based on what
|
// based on what
|
||||||
// the expected targets could be
|
// the expected targets could be
|
||||||
@@ -2493,7 +2493,7 @@ public class AbilityFactoryCounters {
|
|||||||
chance &= subAb.chkAIDrawback();
|
chance &= subAb.chkAIDrawback();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AbilityFactory.playReusable(sa)) {
|
if (AbilityFactory.playReusable(ai, sa)) {
|
||||||
return chance;
|
return chance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ public class AbilityFactoryDestroy {
|
|||||||
list = CardLists.getValidCards(list, params.get("AITgts"), sa.getActivatingPlayer(), source);
|
list = CardLists.getValidCards(list, params.get("AITgts"), sa.getActivatingPlayer(), source);
|
||||||
}
|
}
|
||||||
list = CardLists.getNotKeyword(list, "Indestructible");
|
list = CardLists.getNotKeyword(list, "Indestructible");
|
||||||
if (!AbilityFactory.playReusable(sa)) {
|
if (!AbilityFactory.playReusable(ai, sa)) {
|
||||||
list = CardLists.filter(list, new Predicate<Card>() {
|
list = CardLists.filter(list, new Predicate<Card>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(final Card c) {
|
public boolean apply(final Card c) {
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ public final class AbilityFactoryReveal {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AbilityFactory.playReusable(sa)) {
|
if (AbilityFactory.playReusable(ai, sa)) {
|
||||||
randomReturn = true;
|
randomReturn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1315,7 +1315,7 @@ public final class AbilityFactoryReveal {
|
|||||||
final Random r = MyRandom.getRandom();
|
final Random r = MyRandom.getRandom();
|
||||||
boolean randomReturn = r.nextFloat() <= Math.pow(.667, sa.getActivationsThisTurn() + 1);
|
boolean randomReturn = r.nextFloat() <= Math.pow(.667, sa.getActivationsThisTurn() + 1);
|
||||||
|
|
||||||
if (AbilityFactory.playReusable(sa)) {
|
if (AbilityFactory.playReusable(ai, sa)) {
|
||||||
randomReturn = true;
|
randomReturn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1481,7 +1481,7 @@ public final class AbilityFactoryReveal {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return AbilityFactoryReveal.scryCanPlayAI(af, this);
|
return AbilityFactoryReveal.scryCanPlayAI(getActivatingPlayer(), af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1519,7 +1519,7 @@ public final class AbilityFactoryReveal {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return AbilityFactoryReveal.scryCanPlayAI(af, this);
|
return AbilityFactoryReveal.scryCanPlayAI(getActivatingPlayer(), af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1720,7 +1720,7 @@ public final class AbilityFactoryReveal {
|
|||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean scryCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
private static boolean scryCanPlayAI(final Player ai, final AbilityFactory af, final SpellAbility sa) {
|
||||||
// Card source = sa.getSourceCard();
|
// Card source = sa.getSourceCard();
|
||||||
|
|
||||||
double chance = .4; // 40 percent chance of milling with instant speed
|
double chance = .4; // 40 percent chance of milling with instant speed
|
||||||
@@ -1732,7 +1732,7 @@ public final class AbilityFactoryReveal {
|
|||||||
final Random r = MyRandom.getRandom();
|
final Random r = MyRandom.getRandom();
|
||||||
boolean randomReturn = r.nextFloat() <= Math.pow(chance, sa.getActivationsThisTurn() + 1);
|
boolean randomReturn = r.nextFloat() <= Math.pow(chance, sa.getActivationsThisTurn() + 1);
|
||||||
|
|
||||||
if (AbilityFactory.playReusable(sa)) {
|
if (AbilityFactory.playReusable(ai, sa)) {
|
||||||
randomReturn = true;
|
randomReturn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2302,7 +2302,7 @@ public final class AbilityFactoryReveal {
|
|||||||
final Random r = MyRandom.getRandom();
|
final Random r = MyRandom.getRandom();
|
||||||
boolean randomReturn = r.nextFloat() <= Math.pow(.667, sa.getActivationsThisTurn() + 1);
|
boolean randomReturn = r.nextFloat() <= Math.pow(.667, sa.getActivationsThisTurn() + 1);
|
||||||
|
|
||||||
if (AbilityFactory.playReusable(sa)) {
|
if (AbilityFactory.playReusable(ai, sa)) {
|
||||||
randomReturn = true;
|
randomReturn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -385,7 +385,7 @@ public class AbilityFactoryToken extends AbilityFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AbilityFactory.playReusable(sa)) {
|
if (AbilityFactory.playReusable(ai, sa)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ public class AbilityFactoryZoneAffecting {
|
|||||||
randomReturn = true;
|
randomReturn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AbilityFactory.playReusable(sa)) {
|
if (AbilityFactory.playReusable(ai, sa)) {
|
||||||
randomReturn = true;
|
randomReturn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -932,7 +932,7 @@ public class AbilityFactoryZoneAffecting {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AbilityFactory.playReusable(sa)) {
|
if (AbilityFactory.playReusable(ai, sa)) {
|
||||||
randomReturn = true;
|
randomReturn = true;
|
||||||
// some other variables here, like deck size, and phase and other fun stuff
|
// some other variables here, like deck size, and phase and other fun stuff
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user