mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
checkstyle cleanup in AF_Combat
This commit is contained in:
@@ -22,6 +22,11 @@ import forge.card.spellability.Target;
|
|||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class AbilityFactory_Combat {
|
public class AbilityFactory_Combat {
|
||||||
|
|
||||||
|
private AbilityFactory_Combat() {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
|
||||||
//**************************************************************
|
//**************************************************************
|
||||||
// ****************************** FOG **************************
|
// ****************************** FOG **************************
|
||||||
//**************************************************************
|
//**************************************************************
|
||||||
@@ -29,15 +34,13 @@ public class AbilityFactory_Combat {
|
|||||||
/**
|
/**
|
||||||
* <p>createAbilityFog.</p>
|
* <p>createAbilityFog.</p>
|
||||||
*
|
*
|
||||||
* @param AF a {@link forge.card.abilityFactory.AbilityFactory} object.
|
* @param af a {@link forge.card.abilityFactory.AbilityFactory} object.
|
||||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public static SpellAbility createAbilityFog(final AbilityFactory AF) {
|
public static SpellAbility createAbilityFog(final AbilityFactory af) {
|
||||||
final SpellAbility abFog = new Ability_Activated(AF.getHostCard(), AF.getAbCost(), AF.getAbTgt()) {
|
final SpellAbility abFog = new Ability_Activated(af.getHostCard(), af.getAbCost(), af.getAbTgt()) {
|
||||||
private static final long serialVersionUID = -1933592438783630254L;
|
private static final long serialVersionUID = -1933592438783630254L;
|
||||||
|
|
||||||
final AbilityFactory af = AF;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
// when getStackDesc is called, just build exactly what is happening
|
// when getStackDesc is called, just build exactly what is happening
|
||||||
@@ -54,7 +57,7 @@ public class AbilityFactory_Combat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return fogDoTriggerAI(af, this, mandatory);
|
return fogDoTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,15 +68,13 @@ public class AbilityFactory_Combat {
|
|||||||
/**
|
/**
|
||||||
* <p>createSpellFog.</p>
|
* <p>createSpellFog.</p>
|
||||||
*
|
*
|
||||||
* @param AF a {@link forge.card.abilityFactory.AbilityFactory} object.
|
* @param af a {@link forge.card.abilityFactory.AbilityFactory} object.
|
||||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public static SpellAbility createSpellFog(final AbilityFactory AF) {
|
public static SpellAbility createSpellFog(final AbilityFactory af) {
|
||||||
final SpellAbility spFog = new Spell(AF.getHostCard(), AF.getAbCost(), AF.getAbTgt()) {
|
final SpellAbility spFog = new Spell(af.getHostCard(), af.getAbCost(), af.getAbTgt()) {
|
||||||
private static final long serialVersionUID = -5141246507533353605L;
|
private static final long serialVersionUID = -5141246507533353605L;
|
||||||
|
|
||||||
final AbilityFactory af = AF;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
// when getStackDesc is called, just build exactly what is happening
|
// when getStackDesc is called, just build exactly what is happening
|
||||||
@@ -96,15 +97,13 @@ public class AbilityFactory_Combat {
|
|||||||
/**
|
/**
|
||||||
* <p>createDrawbackFog.</p>
|
* <p>createDrawbackFog.</p>
|
||||||
*
|
*
|
||||||
* @param AF a {@link forge.card.abilityFactory.AbilityFactory} object.
|
* @param af a {@link forge.card.abilityFactory.AbilityFactory} object.
|
||||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public static SpellAbility createDrawbackFog(final AbilityFactory AF) {
|
public static SpellAbility createDrawbackFog(final AbilityFactory af) {
|
||||||
final SpellAbility dbFog = new Ability_Sub(AF.getHostCard(), AF.getAbTgt()) {
|
final SpellAbility dbFog = new Ability_Sub(af.getHostCard(), af.getAbTgt()) {
|
||||||
private static final long serialVersionUID = -5141246507533353605L;
|
private static final long serialVersionUID = -5141246507533353605L;
|
||||||
|
|
||||||
final AbilityFactory af = AF;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
fogResolve(af, this);
|
fogResolve(af, this);
|
||||||
@@ -116,7 +115,7 @@ public class AbilityFactory_Combat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return fogDoTriggerAI(af, this, mandatory);
|
return fogDoTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,13 +130,14 @@ public class AbilityFactory_Combat {
|
|||||||
* @param sa a {@link forge.card.spellability.SpellAbility} object.
|
* @param sa a {@link forge.card.spellability.SpellAbility} object.
|
||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
public static String fogStackDescription(AbilityFactory af, SpellAbility sa) {
|
public static String fogStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
if (!(sa instanceof Ability_Sub))
|
if (!(sa instanceof Ability_Sub)) {
|
||||||
sb.append(sa.getSourceCard().getName()).append(" - ");
|
sb.append(sa.getSourceCard().getName()).append(" - ");
|
||||||
else
|
} else {
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
sb.append(sa.getSourceCard().getController());
|
sb.append(sa.getSourceCard().getController());
|
||||||
sb.append(" prevents all combat damage this turn.");
|
sb.append(" prevents all combat damage this turn.");
|
||||||
@@ -157,20 +157,31 @@ public class AbilityFactory_Combat {
|
|||||||
* @param sa a {@link forge.card.spellability.SpellAbility} object.
|
* @param sa a {@link forge.card.spellability.SpellAbility} object.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public static boolean fogCanPlayAI(final AbilityFactory af, SpellAbility sa) {
|
public static boolean fogCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
// AI should only activate this during Human's Declare Blockers phase
|
// AI should only activate this during Human's Declare Blockers phase
|
||||||
if (AllZone.getPhase().isPlayerTurn(sa.getActivatingPlayer())) return false;
|
if (AllZone.getPhase().isPlayerTurn(sa.getActivatingPlayer())) {
|
||||||
if (!AllZone.getPhase().is(Constant.Phase.Combat_Declare_Blockers_InstantAbility)) return false;
|
return false;
|
||||||
|
}
|
||||||
|
if (!AllZone.getPhase().is(Constant.Phase.Combat_Declare_Blockers_InstantAbility)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Only cast when Stack is empty, so Human uses spells/abilities first
|
// Only cast when Stack is empty, so Human uses spells/abilities first
|
||||||
if (AllZone.getStack().size() != 0) return false;
|
if (AllZone.getStack().size() != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Don't cast it, if the effect is already in place
|
// Don't cast it, if the effect is already in place
|
||||||
if (AllZone.getPhase().isPreventCombatDamageThisTurn()) return false;
|
if (AllZone.getPhase().isPreventCombatDamageThisTurn()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null)
|
if (subAb != null) {
|
||||||
if (!subAb.chkAI_Drawback()) return false;
|
if (!subAb.chkAI_Drawback()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Cast it if life is in danger
|
// Cast it if life is in danger
|
||||||
return CombatUtil.lifeInDanger(AllZone.getCombat());
|
return CombatUtil.lifeInDanger(AllZone.getCombat());
|
||||||
@@ -183,17 +194,19 @@ public class AbilityFactory_Combat {
|
|||||||
* @param sa a {@link forge.card.spellability.SpellAbility} object.
|
* @param sa a {@link forge.card.spellability.SpellAbility} object.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public static boolean fogPlayDrawbackAI(final AbilityFactory af, SpellAbility sa) {
|
public static boolean fogPlayDrawbackAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
// AI should only activate this during Human's turn
|
// AI should only activate this during Human's turn
|
||||||
boolean chance;
|
boolean chance;
|
||||||
if (AllZone.getPhase().isPlayerTurn(sa.getActivatingPlayer().getOpponent()))
|
if (AllZone.getPhase().isPlayerTurn(sa.getActivatingPlayer().getOpponent())) {
|
||||||
chance = AllZone.getPhase().isBefore(Constant.Phase.Combat_FirstStrikeDamage);
|
chance = AllZone.getPhase().isBefore(Constant.Phase.Combat_FirstStrikeDamage);
|
||||||
else
|
} else {
|
||||||
chance = AllZone.getPhase().isAfter(Constant.Phase.Combat_Damage);
|
chance = AllZone.getPhase().isAfter(Constant.Phase.Combat_Damage);
|
||||||
|
}
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null)
|
if (subAb != null) {
|
||||||
chance &= subAb.chkAI_Drawback();
|
chance &= subAb.chkAI_Drawback();
|
||||||
|
}
|
||||||
|
|
||||||
return chance;
|
return chance;
|
||||||
}
|
}
|
||||||
@@ -206,15 +219,18 @@ public class AbilityFactory_Combat {
|
|||||||
* @param mandatory a boolean.
|
* @param mandatory a boolean.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public static boolean fogDoTriggerAI(AbilityFactory af, SpellAbility sa, boolean mandatory) {
|
public static boolean fogDoTriggerAI(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
|
||||||
if (!ComputerUtil.canPayCost(sa) && !mandatory) // If there is a cost payment it's usually not mandatory
|
// If there is a cost payment it's usually not mandatory
|
||||||
|
if (!ComputerUtil.canPayCost(sa) && !mandatory) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
boolean chance;
|
boolean chance;
|
||||||
if (AllZone.getPhase().isPlayerTurn(sa.getActivatingPlayer().getOpponent()))
|
if (AllZone.getPhase().isPlayerTurn(sa.getActivatingPlayer().getOpponent())) {
|
||||||
chance = AllZone.getPhase().isBefore(Constant.Phase.Combat_FirstStrikeDamage);
|
chance = AllZone.getPhase().isBefore(Constant.Phase.Combat_FirstStrikeDamage);
|
||||||
else
|
} else {
|
||||||
chance = AllZone.getPhase().isAfter(Constant.Phase.Combat_Damage);
|
chance = AllZone.getPhase().isAfter(Constant.Phase.Combat_Damage);
|
||||||
|
}
|
||||||
|
|
||||||
// check SubAbilities DoTrigger?
|
// check SubAbilities DoTrigger?
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
Ability_Sub abSub = sa.getSubAbility();
|
||||||
@@ -244,7 +260,7 @@ public class AbilityFactory_Combat {
|
|||||||
//AB$ MustAttack | Cost$ R T | ValidTgts$ Opponent | TgtPrompt$ Select target opponent | Defender$ Self | SpellDescription$ ...
|
//AB$ MustAttack | Cost$ R T | ValidTgts$ Opponent | TgtPrompt$ Select target opponent | Defender$ Self | SpellDescription$ ...
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>createAbilityMustAttack</p>
|
* <p>createAbilityMustAttack.</p>
|
||||||
*
|
*
|
||||||
* @param af a {@link forge.card.abilityFactory.AbilityFactory} object.
|
* @param af a {@link forge.card.abilityFactory.AbilityFactory} object.
|
||||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||||
@@ -271,7 +287,7 @@ public class AbilityFactory_Combat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return mustAttackDoTriggerAI(af, this, mandatory);
|
return mustAttackDoTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,7 +345,7 @@ public class AbilityFactory_Combat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return mustAttackDoTriggerAI(af, this, mandatory);
|
return mustAttackDoTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,25 +353,27 @@ public class AbilityFactory_Combat {
|
|||||||
return dbMustAttack;
|
return dbMustAttack;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String mustAttackStackDescription(AbilityFactory af, SpellAbility sa) {
|
private static String mustAttackStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
HashMap<String, String> params = af.getMapParams();
|
||||||
Card host = af.getHostCard();
|
Card host = af.getHostCard();
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
if(sa instanceof Ability_Sub)
|
if (sa instanceof Ability_Sub) {
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
else
|
} else {
|
||||||
sb.append(sa.getSourceCard()).append(" - ");
|
sb.append(sa.getSourceCard()).append(" - ");
|
||||||
|
}
|
||||||
|
|
||||||
//end standard pre-
|
//end standard pre-
|
||||||
|
|
||||||
ArrayList<Player> tgtPlayers;
|
ArrayList<Player> tgtPlayers;
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
Target tgt = af.getAbTgt();
|
||||||
if (tgt != null)
|
if (tgt != null) {
|
||||||
tgtPlayers = tgt.getTargetPlayers();
|
tgtPlayers = tgt.getTargetPlayers();
|
||||||
else
|
} else {
|
||||||
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
|
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
|
||||||
|
}
|
||||||
|
|
||||||
String defender = null;
|
String defender = null;
|
||||||
if (params.get("Defender").equals("Self")) {
|
if (params.get("Defender").equals("Self")) {
|
||||||
@@ -366,7 +384,8 @@ public class AbilityFactory_Combat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Player player : tgtPlayers) {
|
for (Player player : tgtPlayers) {
|
||||||
sb.append("Creatures ").append(player).append(" controls attack ").append(defender).append(" during his or her next turn.");
|
sb.append("Creatures ").append(player).append(" controls attack ");
|
||||||
|
sb.append(defender).append(" during his or her next turn.");
|
||||||
}
|
}
|
||||||
|
|
||||||
//begin standard post-
|
//begin standard post-
|
||||||
@@ -378,12 +397,12 @@ public class AbilityFactory_Combat {
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean mustAttackCanPlayAI(final AbilityFactory af, SpellAbility sa) {
|
private static boolean mustAttackCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
//disabled for the AI for now. Only for Gideon Jura at this time.
|
//disabled for the AI for now. Only for Gideon Jura at this time.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean mustAttackPlayDrawbackAI(final AbilityFactory af, SpellAbility sa) {
|
private static boolean mustAttackPlayDrawbackAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
// AI should only activate this during Human's turn
|
// AI should only activate this during Human's turn
|
||||||
boolean chance;
|
boolean chance;
|
||||||
|
|
||||||
@@ -391,15 +410,20 @@ public class AbilityFactory_Combat {
|
|||||||
chance = false;
|
chance = false;
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null)
|
if (subAb != null) {
|
||||||
chance &= subAb.chkAI_Drawback();
|
chance &= subAb.chkAI_Drawback();
|
||||||
|
}
|
||||||
|
|
||||||
return chance;
|
return chance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean mustAttackDoTriggerAI(AbilityFactory af, SpellAbility sa, boolean mandatory) {
|
private static boolean mustAttackDoTriggerAI(final AbilityFactory af, final SpellAbility sa,
|
||||||
if (!ComputerUtil.canPayCost(sa) && !mandatory) // If there is a cost payment it's usually not mandatory
|
final boolean mandatory)
|
||||||
|
{
|
||||||
|
// If there is a cost payment it's usually not mandatory
|
||||||
|
if (!ComputerUtil.canPayCost(sa) && !mandatory) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
boolean chance;
|
boolean chance;
|
||||||
|
|
||||||
@@ -421,10 +445,11 @@ public class AbilityFactory_Combat {
|
|||||||
ArrayList<Player> tgtPlayers;
|
ArrayList<Player> tgtPlayers;
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
Target tgt = af.getAbTgt();
|
||||||
if (tgt != null && !params.containsKey("Defined"))
|
if (tgt != null && !params.containsKey("Defined")) {
|
||||||
tgtPlayers = tgt.getTargetPlayers();
|
tgtPlayers = tgt.getTargetPlayers();
|
||||||
else
|
} else {
|
||||||
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
|
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
|
||||||
|
}
|
||||||
|
|
||||||
for (final Player p : tgtPlayers) {
|
for (final Player p : tgtPlayers) {
|
||||||
if (tgt == null || p.canTarget(sa)) {
|
if (tgt == null || p.canTarget(sa)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user