mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
some Checkstyle fixes in AF_ChangeZone
This commit is contained in:
@@ -1429,15 +1429,16 @@ public class AbilityFactory_ChangeZone {
|
|||||||
* @param origin a {@link java.lang.String} object.
|
* @param origin a {@link java.lang.String} object.
|
||||||
* @return a {@link forge.CardList} object.
|
* @return a {@link forge.CardList} object.
|
||||||
*/
|
*/
|
||||||
private static CardList knownDetermineDefined(SpellAbility sa, String defined, String origin) {
|
private static CardList knownDetermineDefined(final SpellAbility sa, final String defined, final String origin) {
|
||||||
// TODO: this function should return a ArrayList<Card> and then be handled by the callees
|
// TODO this function should return a ArrayList<Card> and then be handled by the callees
|
||||||
CardList grave = AllZoneUtil.getCardsInZone(origin, sa.getActivatingPlayer());
|
CardList grave = AllZoneUtil.getCardsInZone(origin, sa.getActivatingPlayer());
|
||||||
CardList ret = new CardList();
|
CardList ret = new CardList();
|
||||||
|
|
||||||
if (defined != null && defined.equals("Top")) {
|
if (defined != null && defined.equals("Top")) {
|
||||||
// the "top" of the graveyard, is the last to be added to the graveyard list?
|
// the "top" of the graveyard, is the last to be added to the graveyard list?
|
||||||
if (grave.size() == 0)
|
if (grave.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
ret.add(grave.get(grave.size() - 1));
|
ret.add(grave.get(grave.size() - 1));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -1455,96 +1456,96 @@ public class AbilityFactory_ChangeZone {
|
|||||||
/**
|
/**
|
||||||
* <p>createAbilityChangeZoneAll.</p>
|
* <p>createAbilityChangeZoneAll.</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 createAbilityChangeZoneAll(final AbilityFactory AF) {
|
public static SpellAbility createAbilityChangeZoneAll(final AbilityFactory af) {
|
||||||
final SpellAbility abChangeZone = new Ability_Activated(AF.getHostCard(), AF.getAbCost(), AF.getAbTgt()) {
|
final SpellAbility abChangeZone = new Ability_Activated(af.getHostCard(), af.getAbCost(), af.getAbTgt()) {
|
||||||
private static final long serialVersionUID = 3728332812890211671L;
|
private static final long serialVersionUID = 3728332812890211671L;
|
||||||
|
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return changeZoneAllCanPlayAI(AF, this);
|
return changeZoneAllCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
changeZoneAllResolve(AF, this);
|
changeZoneAllResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return changeZoneAllDescription(AF, this);
|
return changeZoneAllDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return changeZoneAllCanPlayAI(AF, this);
|
return changeZoneAllCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
setMiscellaneous(AF, abChangeZone);
|
setMiscellaneous(af, abChangeZone);
|
||||||
return abChangeZone;
|
return abChangeZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>createSpellChangeZoneAll.</p>
|
* <p>createSpellChangeZoneAll.</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 createSpellChangeZoneAll(final AbilityFactory AF) {
|
public static SpellAbility createSpellChangeZoneAll(final AbilityFactory af) {
|
||||||
final SpellAbility spChangeZone = new Spell(AF.getHostCard(), AF.getAbCost(), AF.getAbTgt()) {
|
final SpellAbility spChangeZone = new Spell(af.getHostCard(), af.getAbCost(), af.getAbTgt()) {
|
||||||
private static final long serialVersionUID = 3270484211099902059L;
|
private static final long serialVersionUID = 3270484211099902059L;
|
||||||
|
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return changeZoneAllCanPlayAI(AF, this);
|
return changeZoneAllCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
changeZoneAllResolve(AF, this);
|
changeZoneAllResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return changeZoneAllDescription(AF, this);
|
return changeZoneAllDescription(af, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
setMiscellaneous(AF, spChangeZone);
|
setMiscellaneous(af, spChangeZone);
|
||||||
return spChangeZone;
|
return spChangeZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>createDrawbackChangeZoneAll.</p>
|
* <p>createDrawbackChangeZoneAll.</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 createDrawbackChangeZoneAll(final AbilityFactory AF) {
|
public static SpellAbility createDrawbackChangeZoneAll(final AbilityFactory af) {
|
||||||
final SpellAbility dbChangeZone = new Ability_Sub(AF.getHostCard(), AF.getAbTgt()) {
|
final SpellAbility dbChangeZone = new Ability_Sub(af.getHostCard(), af.getAbTgt()) {
|
||||||
private static final long serialVersionUID = 3270484211099902059L;
|
private static final long serialVersionUID = 3270484211099902059L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
changeZoneAllResolve(AF, this);
|
changeZoneAllResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean chkAI_Drawback() {
|
public boolean chkAI_Drawback() {
|
||||||
return changeZoneAllPlayDrawbackAI(AF, this);
|
return changeZoneAllPlayDrawbackAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return changeZoneAllDescription(AF, this);
|
return changeZoneAllDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return changeZoneAllCanPlayAI(AF, this);
|
return changeZoneAllCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
setMiscellaneous(AF, dbChangeZone);
|
setMiscellaneous(af, dbChangeZone);
|
||||||
return dbChangeZone;
|
return dbChangeZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1556,7 +1557,7 @@ public class AbilityFactory_ChangeZone {
|
|||||||
* @param sa a {@link forge.card.spellability.SpellAbility} object.
|
* @param sa a {@link forge.card.spellability.SpellAbility} object.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean changeZoneAllCanPlayAI(AbilityFactory af, SpellAbility sa) {
|
private static boolean changeZoneAllCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
// Change Zone All, can be any type moving from one zone to another
|
// Change Zone All, can be any type moving from one zone to another
|
||||||
Cost abCost = af.getAbCost();
|
Cost abCost = af.getAbCost();
|
||||||
Card source = sa.getSourceCard();
|
Card source = sa.getSourceCard();
|
||||||
@@ -1567,11 +1568,13 @@ public class AbilityFactory_ChangeZone {
|
|||||||
|
|
||||||
if (abCost != null) {
|
if (abCost != null) {
|
||||||
// AI currently disabled for these costs
|
// AI currently disabled for these costs
|
||||||
if (!CostUtil.checkLifeCost(abCost, source, 4))
|
if (!CostUtil.checkLifeCost(abCost, source, 4)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!CostUtil.checkDiscardCost(abCost, source))
|
if (!CostUtil.checkDiscardCost(abCost, source)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1579,7 +1582,7 @@ public class AbilityFactory_ChangeZone {
|
|||||||
// prevent run-away activations - first time will always return true
|
// prevent run-away activations - first time will always return true
|
||||||
boolean chance = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn());
|
boolean chance = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn());
|
||||||
|
|
||||||
// TODO: targeting with ChangeZoneAll
|
// TODO targeting with ChangeZoneAll
|
||||||
// really two types of targeting.
|
// really two types of targeting.
|
||||||
// Target Player has all their types change zones
|
// Target Player has all their types change zones
|
||||||
// or target permanent and do something relative to that permanent
|
// or target permanent and do something relative to that permanent
|
||||||
@@ -1591,7 +1594,7 @@ public class AbilityFactory_ChangeZone {
|
|||||||
CardList computerType = AllZoneUtil.getCardsInZone(origin, AllZone.getComputerPlayer());
|
CardList computerType = AllZoneUtil.getCardsInZone(origin, AllZone.getComputerPlayer());
|
||||||
computerType = AbilityFactory.filterListByType(computerType, params.get("ChangeType"), sa);
|
computerType = AbilityFactory.filterListByType(computerType, params.get("ChangeType"), sa);
|
||||||
|
|
||||||
// TODO: improve restrictions on when the AI would want to use this
|
// TODO improve restrictions on when the AI would want to use this
|
||||||
// spBounceAll has some AI we can compare to.
|
// spBounceAll has some AI we can compare to.
|
||||||
if (origin.equals("Hand")) {
|
if (origin.equals("Hand")) {
|
||||||
|
|
||||||
@@ -1609,13 +1612,15 @@ public class AbilityFactory_ChangeZone {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Don't cast during main1?
|
// Don't cast during main1?
|
||||||
if (AllZone.getPhase().is(Constant.Phase.Main1, AllZone.getComputerPlayer()))
|
if (AllZone.getPhase().is(Constant.Phase.Main1, AllZone.getComputerPlayer())) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
} else if (origin.equals("Graveyard")) {
|
} else if (origin.equals("Graveyard")) {
|
||||||
Target tgt = af.getAbTgt();
|
Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
if (AllZoneUtil.getPlayerGraveyard(AllZone.getHumanPlayer()).isEmpty())
|
if (AllZoneUtil.getPlayerGraveyard(AllZone.getHumanPlayer()).isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
tgt.addTarget(AllZone.getHumanPlayer());
|
tgt.addTarget(AllZone.getHumanPlayer());
|
||||||
}
|
}
|
||||||
@@ -1653,8 +1658,9 @@ public class AbilityFactory_ChangeZone {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 ((r.nextFloat() < .8 || sa.isTrigger()) && chance);
|
return ((r.nextFloat() < .8 || sa.isTrigger()) && chance);
|
||||||
}
|
}
|
||||||
@@ -1666,7 +1672,7 @@ public class AbilityFactory_ChangeZone {
|
|||||||
* @param sa a {@link forge.card.spellability.SpellAbility} object.
|
* @param sa a {@link forge.card.spellability.SpellAbility} object.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean changeZoneAllPlayDrawbackAI(AbilityFactory af, SpellAbility sa) {
|
private static boolean changeZoneAllPlayDrawbackAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
// if putting cards from hand to library and parent is drawing cards
|
// if putting cards from hand to library and parent is drawing cards
|
||||||
// make sure this will actually do something:
|
// make sure this will actually do something:
|
||||||
|
|
||||||
@@ -1681,22 +1687,24 @@ public class AbilityFactory_ChangeZone {
|
|||||||
* @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.
|
||||||
*/
|
*/
|
||||||
private static String changeZoneAllDescription(AbilityFactory af, SpellAbility sa) {
|
private static String changeZoneAllDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
// TODO: build Stack Description will need expansion as more cards are added
|
// TODO build Stack Description will need expansion as more cards are added
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
Card host = af.getHostCard();
|
Card host = af.getHostCard();
|
||||||
|
|
||||||
if (!(sa instanceof Ability_Sub))
|
if (!(sa instanceof Ability_Sub)) {
|
||||||
sb.append(host.getName()).append(" -");
|
sb.append(host.getName()).append(" -");
|
||||||
|
}
|
||||||
|
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
|
|
||||||
String[] desc = sa.getDescription().split(":");
|
String[] desc = sa.getDescription().split(":");
|
||||||
|
|
||||||
if (desc.length > 1)
|
if (desc.length > 1) {
|
||||||
sb.append(desc[1]);
|
sb.append(desc[1]);
|
||||||
else
|
} else {
|
||||||
sb.append(desc[0]);
|
sb.append(desc[0]);
|
||||||
|
}
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
@@ -1712,7 +1720,7 @@ public class AbilityFactory_ChangeZone {
|
|||||||
* @param af a {@link forge.card.abilityFactory.AbilityFactory} object.
|
* @param af a {@link forge.card.abilityFactory.AbilityFactory} object.
|
||||||
* @param sa a {@link forge.card.spellability.SpellAbility} object.
|
* @param sa a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
private static void changeZoneAllResolve(AbilityFactory af, SpellAbility sa) {
|
private static void changeZoneAllResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
HashMap<String, String> params = af.getMapParams();
|
||||||
String destination = params.get("Destination");
|
String destination = params.get("Destination");
|
||||||
String origin = params.get("Origin");
|
String origin = params.get("Origin");
|
||||||
@@ -1722,20 +1730,23 @@ public class AbilityFactory_ChangeZone {
|
|||||||
ArrayList<Player> tgtPlayers = null;
|
ArrayList<Player> tgtPlayers = null;
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
Target tgt = af.getAbTgt();
|
||||||
if (tgt != null)
|
if (tgt != null) {
|
||||||
tgtPlayers = tgt.getTargetPlayers();
|
tgtPlayers = tgt.getTargetPlayers();
|
||||||
else if (params.containsKey("Defined")) // Make sure Defined exists to use it
|
} else if (params.containsKey("Defined")) {
|
||||||
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
|
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
|
||||||
|
}
|
||||||
|
|
||||||
if (tgtPlayers == null || tgtPlayers.isEmpty())
|
if (tgtPlayers == null || tgtPlayers.isEmpty()) {
|
||||||
cards = AllZoneUtil.getCardsInZone(origin);
|
cards = AllZoneUtil.getCardsInZone(origin);
|
||||||
else
|
} else {
|
||||||
cards = AllZoneUtil.getCardsInZone(origin, tgtPlayers.get(0));
|
cards = AllZoneUtil.getCardsInZone(origin, tgtPlayers.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
cards = AbilityFactory.filterListByType(cards, params.get("ChangeType"), sa);
|
cards = AbilityFactory.filterListByType(cards, params.get("ChangeType"), sa);
|
||||||
|
|
||||||
if (params.containsKey("ForgetOtherRemembered"))
|
if (params.containsKey("ForgetOtherRemembered")) {
|
||||||
sa.getSourceCard().clearRemembered();
|
sa.getSourceCard().clearRemembered();
|
||||||
|
}
|
||||||
|
|
||||||
String remember = params.get("RememberChanged");
|
String remember = params.get("RememberChanged");
|
||||||
|
|
||||||
@@ -1746,14 +1757,15 @@ public class AbilityFactory_ChangeZone {
|
|||||||
// Auras without Candidates stay in their current location
|
// Auras without Candidates stay in their current location
|
||||||
if (c.isAura()) {
|
if (c.isAura()) {
|
||||||
SpellAbility saAura = AbilityFactory_Attach.getAttachSpellAbility(c);
|
SpellAbility saAura = AbilityFactory_Attach.getAttachSpellAbility(c);
|
||||||
if (!saAura.getTarget().hasCandidates(false))
|
if (!saAura.getTarget().hasCandidates(false)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.containsKey("Tapped")) {
|
||||||
if (params.containsKey("Tapped"))
|
|
||||||
c.tap();
|
c.tap();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (params.containsKey("GainControl")) {
|
if (params.containsKey("GainControl")) {
|
||||||
c.addController(af.getHostCard());
|
c.addController(af.getHostCard());
|
||||||
@@ -1765,18 +1777,21 @@ public class AbilityFactory_ChangeZone {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remember != null)
|
if (remember != null) {
|
||||||
sa.getSourceCard().addRemembered(c);
|
sa.getSourceCard().addRemembered(c);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if Shuffle parameter exists, and any amount of cards were owned by that player, then shuffle that library
|
// if Shuffle parameter exists, and any amount of cards were owned by that player, then shuffle that library
|
||||||
if (params.containsKey("Shuffle")) {
|
if (params.containsKey("Shuffle")) {
|
||||||
if (cards.getOwner(AllZone.getHumanPlayer()).size() > 0)
|
if (cards.getOwner(AllZone.getHumanPlayer()).size() > 0) {
|
||||||
AllZone.getHumanPlayer().shuffle();
|
AllZone.getHumanPlayer().shuffle();
|
||||||
if (cards.getOwner(AllZone.getComputerPlayer()).size() > 0)
|
}
|
||||||
|
if (cards.getOwner(AllZone.getComputerPlayer()).size() > 0) {
|
||||||
AllZone.getComputerPlayer().shuffle();
|
AllZone.getComputerPlayer().shuffle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user