mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Checkstyle fixes in AF_Reveal
This commit is contained in:
@@ -1,6 +1,15 @@
|
|||||||
package forge.card.abilityFactory;
|
package forge.card.abilityFactory;
|
||||||
|
|
||||||
import forge.*;
|
import forge.AllZone;
|
||||||
|
import forge.AllZoneUtil;
|
||||||
|
import forge.Card;
|
||||||
|
import forge.CardList;
|
||||||
|
import forge.ComputerUtil;
|
||||||
|
import forge.Constant;
|
||||||
|
import forge.GameActionUtil;
|
||||||
|
import forge.MyRandom;
|
||||||
|
import forge.Player;
|
||||||
|
import forge.PlayerZone;
|
||||||
import forge.card.cost.Cost;
|
import forge.card.cost.Cost;
|
||||||
import forge.card.cost.CostUtil;
|
import forge.card.cost.CostUtil;
|
||||||
import forge.card.spellability.*;
|
import forge.card.spellability.*;
|
||||||
@@ -19,7 +28,11 @@ import java.util.Random;
|
|||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class AbilityFactory_Reveal {
|
public final class AbilityFactory_Reveal {
|
||||||
|
|
||||||
|
private AbilityFactory_Reveal() {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
|
||||||
// *************************************************************************
|
// *************************************************************************
|
||||||
// ************************* Dig *******************************************
|
// ************************* Dig *******************************************
|
||||||
@@ -51,7 +64,7 @@ public class AbilityFactory_Reveal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return digTriggerAI(af, this, mandatory);
|
return digTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +126,7 @@ public class AbilityFactory_Reveal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return digTriggerAI(af, this, mandatory);
|
return digTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,29 +141,33 @@ public class AbilityFactory_Reveal {
|
|||||||
* @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 digStackDescription(AbilityFactory af, SpellAbility sa) {
|
private static String digStackDescription(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();
|
||||||
int numToDig = AbilityFactory.calculateAmount(af.getHostCard(), params.get("DigNum"), sa);
|
int numToDig = AbilityFactory.calculateAmount(af.getHostCard(), params.get("DigNum"), sa);
|
||||||
|
|
||||||
if (!(sa instanceof Ability_Sub))
|
if (!(sa instanceof Ability_Sub)) {
|
||||||
sb.append(sa.getSourceCard()).append(" - ");
|
sb.append(sa.getSourceCard()).append(" - ");
|
||||||
else
|
} else {
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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);
|
||||||
|
}
|
||||||
|
|
||||||
sb.append(host.getController()).append(" looks at the top ").append(numToDig);
|
sb.append(host.getController()).append(" looks at the top ").append(numToDig);
|
||||||
sb.append(" card");
|
sb.append(" card");
|
||||||
if (numToDig != 1) sb.append("s");
|
if (numToDig != 1) {
|
||||||
|
sb.append("s");
|
||||||
|
}
|
||||||
sb.append(" of ");
|
sb.append(" of ");
|
||||||
if (tgtPlayers.contains(host.getController())) {
|
if (tgtPlayers.contains(host.getController())) {
|
||||||
sb.append("his or her ");
|
sb.append("his or her ");
|
||||||
@@ -179,8 +196,9 @@ public class AbilityFactory_Reveal {
|
|||||||
private static boolean digCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
private static boolean digCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
|
|
||||||
double chance = .4; // 40 percent chance with instant speed stuff
|
double chance = .4; // 40 percent chance with instant speed stuff
|
||||||
if (AbilityFactory.isSorcerySpeed(sa))
|
if (AbilityFactory.isSorcerySpeed(sa)) {
|
||||||
chance = .667; // 66.7% chance for sorcery speed (since it will never activate EOT)
|
chance = .667; // 66.7% chance for sorcery speed (since it will never activate EOT)
|
||||||
|
}
|
||||||
Random r = MyRandom.random;
|
Random r = MyRandom.random;
|
||||||
boolean randomReturn = r.nextFloat() <= Math.pow(chance, sa.getActivationsThisTurn() + 1);
|
boolean randomReturn = r.nextFloat() <= Math.pow(chance, sa.getActivationsThisTurn() + 1);
|
||||||
|
|
||||||
@@ -189,19 +207,22 @@ public class AbilityFactory_Reveal {
|
|||||||
|
|
||||||
if (sa.getTarget() != null) {
|
if (sa.getTarget() != null) {
|
||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
if (!AllZone.getHumanPlayer().canTarget(sa))
|
if (!AllZone.getHumanPlayer().canTarget(sa)) {
|
||||||
return false;
|
return false;
|
||||||
else
|
} else {
|
||||||
sa.getTarget().addTarget(AllZone.getHumanPlayer());
|
sa.getTarget().addTarget(AllZone.getHumanPlayer());
|
||||||
|
}
|
||||||
libraryOwner = AllZone.getHumanPlayer();
|
libraryOwner = AllZone.getHumanPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
//return false if nothing to dig into
|
//return false if nothing to dig into
|
||||||
if (AllZoneUtil.getCardsInZone(Constant.Zone.Library, libraryOwner).isEmpty())
|
if (AllZoneUtil.getCardsInZone(Constant.Zone.Library, libraryOwner).isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (AbilityFactory.playReusable(sa))
|
if (AbilityFactory.playReusable(sa)) {
|
||||||
randomReturn = true;
|
randomReturn = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (af.hasSubAbility()) {
|
if (af.hasSubAbility()) {
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
Ability_Sub abSub = sa.getSubAbility();
|
||||||
@@ -221,9 +242,10 @@ public class AbilityFactory_Reveal {
|
|||||||
* @param mandatory a boolean.
|
* @param mandatory a boolean.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean digTriggerAI(final AbilityFactory af, final SpellAbility sa, boolean mandatory) {
|
private static boolean digTriggerAI(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
|
||||||
if (!ComputerUtil.canPayCost(sa))
|
if (!ComputerUtil.canPayCost(sa)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Target tgt = sa.getTarget();
|
Target tgt = sa.getTarget();
|
||||||
|
|
||||||
@@ -263,17 +285,21 @@ public class AbilityFactory_Reveal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (params.containsKey("ChangeNum")) {
|
if (params.containsKey("ChangeNum")) {
|
||||||
if (params.get("ChangeNum").equalsIgnoreCase("All")) changeAll = true;
|
if (params.get("ChangeNum").equalsIgnoreCase("All")) {
|
||||||
else destZone1ChangeNum = Integer.parseInt(params.get("ChangeNum"));
|
changeAll = true;
|
||||||
|
} else {
|
||||||
|
destZone1ChangeNum = Integer.parseInt(params.get("ChangeNum"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
}
|
||||||
|
|
||||||
for (Player p : tgtPlayers) {
|
for (Player p : tgtPlayers) {
|
||||||
if (tgt == null || p.canTarget(sa)) {
|
if (tgt == null || p.canTarget(sa)) {
|
||||||
@@ -304,7 +330,9 @@ public class AbilityFactory_Reveal {
|
|||||||
if (mitosis) {
|
if (mitosis) {
|
||||||
valid = sharesNameWithCardOnBattlefield(top);
|
valid = sharesNameWithCardOnBattlefield(top);
|
||||||
for (Card c : top) {
|
for (Card c : top) {
|
||||||
if (!valid.contains(c)) rest.add(c);
|
if (!valid.contains(c)) {
|
||||||
|
rest.add(c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (!changeValid.equals("")) {
|
} else if (!changeValid.equals("")) {
|
||||||
if (changeValid.contains("ChosenType")) {
|
if (changeValid.contains("ChosenType")) {
|
||||||
@@ -312,7 +340,9 @@ public class AbilityFactory_Reveal {
|
|||||||
}
|
}
|
||||||
valid = top.getValidCards(changeValid.split(","), host.getController(), host);
|
valid = top.getValidCards(changeValid.split(","), host.getController(), host);
|
||||||
for (Card c : top) {
|
for (Card c : top) {
|
||||||
if (!valid.contains(c)) rest.add(c);
|
if (!valid.contains(c)) {
|
||||||
|
rest.add(c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (valid.isEmpty()) {
|
if (valid.isEmpty()) {
|
||||||
valid.add(dummy);
|
valid.add(dummy);
|
||||||
@@ -323,16 +353,19 @@ public class AbilityFactory_Reveal {
|
|||||||
|
|
||||||
if (changeAll) {
|
if (changeAll) {
|
||||||
for (Card c : valid) {
|
for (Card c : valid) {
|
||||||
if (c.equals(dummy)) continue;
|
if (c.equals(dummy)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
PlayerZone zone = AllZone.getZone(destZone1, c.getOwner());
|
PlayerZone zone = AllZone.getZone(destZone1, c.getOwner());
|
||||||
if (zone.is("Library")) {
|
if (zone.is("Library")) {
|
||||||
AllZone.getGameAction().moveToLibrary(c, libraryPosition);
|
AllZone.getGameAction().moveToLibrary(c, libraryPosition);
|
||||||
} else {
|
} else {
|
||||||
AllZone.getGameAction().moveTo(zone, c);
|
AllZone.getGameAction().moveTo(zone, c);
|
||||||
}
|
}
|
||||||
if (params.containsKey("RememberChanged"))
|
if (params.containsKey("RememberChanged")) {
|
||||||
host.addRemembered(c);
|
host.addRemembered(c);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
int j = 0;
|
int j = 0;
|
||||||
if (player.isHuman()) {
|
if (player.isHuman()) {
|
||||||
@@ -340,16 +373,20 @@ public class AbilityFactory_Reveal {
|
|||||||
//let user get choice
|
//let user get choice
|
||||||
Card chosen = null;
|
Card chosen = null;
|
||||||
String prompt = "Choose a card to put into the ";
|
String prompt = "Choose a card to put into the ";
|
||||||
if (destZone1.equals("Library") && libraryPosition == -1)
|
if (destZone1.equals("Library") && libraryPosition == -1) {
|
||||||
prompt = "Put the rest on the bottom of the ";
|
prompt = "Put the rest on the bottom of the ";
|
||||||
if (destZone1.equals("Library") && libraryPosition == 0)
|
}
|
||||||
|
if (destZone1.equals("Library") && libraryPosition == 0) {
|
||||||
prompt = "Put the rest on top of the ";
|
prompt = "Put the rest on top of the ";
|
||||||
|
}
|
||||||
if (anyNumber || optional) {
|
if (anyNumber || optional) {
|
||||||
chosen = GuiUtils.getChoiceOptional(prompt + destZone1, valid.toArray());
|
chosen = GuiUtils.getChoiceOptional(prompt + destZone1, valid.toArray());
|
||||||
} else {
|
} else {
|
||||||
chosen = GuiUtils.getChoice(prompt + destZone1, valid.toArray());
|
chosen = GuiUtils.getChoice(prompt + destZone1, valid.toArray());
|
||||||
}
|
}
|
||||||
if (chosen == null || chosen.getName().equals("[No valid cards]")) break;
|
if (chosen == null || chosen.getName().equals("[No valid cards]")) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
valid.remove(chosen);
|
valid.remove(chosen);
|
||||||
PlayerZone zone = AllZone.getZone(destZone1, chosen.getOwner());
|
PlayerZone zone = AllZone.getZone(destZone1, chosen.getOwner());
|
||||||
if (zone.is("Library")) {
|
if (zone.is("Library")) {
|
||||||
@@ -357,8 +394,11 @@ public class AbilityFactory_Reveal {
|
|||||||
AllZone.getGameAction().moveToLibrary(chosen, libraryPosition);
|
AllZone.getGameAction().moveToLibrary(chosen, libraryPosition);
|
||||||
} else {
|
} else {
|
||||||
Card c = AllZone.getGameAction().moveTo(zone, chosen);
|
Card c = AllZone.getGameAction().moveTo(zone, chosen);
|
||||||
if (destZone1.equals("Battlefield") && !keywords.isEmpty())
|
if (destZone1.equals("Battlefield") && !keywords.isEmpty()) {
|
||||||
for (String kw : keywords) c.addExtrinsicKeyword(kw);
|
for (String kw : keywords) {
|
||||||
|
c.addExtrinsicKeyword(kw);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//AllZone.getGameAction().revealToComputer() - for when this exists
|
//AllZone.getGameAction().revealToComputer() - for when this exists
|
||||||
j++;
|
j++;
|
||||||
@@ -366,28 +406,40 @@ public class AbilityFactory_Reveal {
|
|||||||
} //human
|
} //human
|
||||||
else { //computer (pick the first cards)
|
else { //computer (pick the first cards)
|
||||||
int changeNum = Math.min(destZone1ChangeNum, valid.size());
|
int changeNum = Math.min(destZone1ChangeNum, valid.size());
|
||||||
if (anyNumber) changeNum = valid.size();//always take all
|
if (anyNumber) {
|
||||||
|
changeNum = valid.size(); //always take all
|
||||||
|
}
|
||||||
for (j = 0; j < changeNum; j++) {
|
for (j = 0; j < changeNum; j++) {
|
||||||
Card chosen = valid.get(0);
|
Card chosen = valid.get(0);
|
||||||
if (chosen.equals(dummy)) break;
|
if (chosen.equals(dummy)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
PlayerZone zone = AllZone.getZone(destZone1, chosen.getOwner());
|
PlayerZone zone = AllZone.getZone(destZone1, chosen.getOwner());
|
||||||
if (zone.is("Library")) {
|
if (zone.is("Library")) {
|
||||||
AllZone.getGameAction().moveToLibrary(chosen, libraryPosition);
|
AllZone.getGameAction().moveToLibrary(chosen, libraryPosition);
|
||||||
} else {
|
} else {
|
||||||
AllZone.getGameAction().moveTo(zone, chosen);
|
AllZone.getGameAction().moveTo(zone, chosen);
|
||||||
if (destZone1.equals("Battlefield") && !keywords.isEmpty())
|
if (destZone1.equals("Battlefield") && !keywords.isEmpty()) {
|
||||||
for (String kw : keywords) chosen.addExtrinsicKeyword(kw);
|
for (String kw : keywords) {
|
||||||
|
chosen.addExtrinsicKeyword(kw);
|
||||||
}
|
}
|
||||||
if (changeValid.length() > 0)
|
}
|
||||||
|
}
|
||||||
|
if (changeValid.length() > 0) {
|
||||||
GuiUtils.getChoice("Computer picked: ", chosen);
|
GuiUtils.getChoice("Computer picked: ", chosen);
|
||||||
|
}
|
||||||
valid.remove(chosen);
|
valid.remove(chosen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//dump anything not selected from valid back into the rest
|
//dump anything not selected from valid back into the rest
|
||||||
if (!changeAll) rest.addAll(valid);
|
if (!changeAll) {
|
||||||
if (rest.contains(dummy)) rest.remove(dummy);
|
rest.addAll(valid);
|
||||||
|
}
|
||||||
|
if (rest.contains(dummy)) {
|
||||||
|
rest.remove(dummy);
|
||||||
|
}
|
||||||
|
|
||||||
//now, move the rest to destZone2
|
//now, move the rest to destZone2
|
||||||
if (destZone2.equals("Library")) {
|
if (destZone2.equals("Library")) {
|
||||||
@@ -397,8 +449,9 @@ public class AbilityFactory_Reveal {
|
|||||||
Card chosen;
|
Card chosen;
|
||||||
if (rest.size() > 1) {
|
if (rest.size() > 1) {
|
||||||
String prompt = "Put the rest on top of the library in any order";
|
String prompt = "Put the rest on top of the library in any order";
|
||||||
if (libraryPosition2 == -1)
|
if (libraryPosition2 == -1) {
|
||||||
prompt = "Put the rest on the bottom of the library in any order";
|
prompt = "Put the rest on the bottom of the library in any order";
|
||||||
|
}
|
||||||
chosen = GuiUtils.getChoice(prompt, rest.toArray());
|
chosen = GuiUtils.getChoice(prompt, rest.toArray());
|
||||||
} else {
|
} else {
|
||||||
chosen = rest.get(0);
|
chosen = rest.get(0);
|
||||||
@@ -418,7 +471,9 @@ public class AbilityFactory_Reveal {
|
|||||||
PlayerZone toZone = AllZone.getZone(destZone2, c.getOwner());
|
PlayerZone toZone = AllZone.getZone(destZone2, c.getOwner());
|
||||||
c = AllZone.getGameAction().moveTo(toZone, c);
|
c = AllZone.getGameAction().moveTo(toZone, c);
|
||||||
if (destZone2.equals("Battlefield") && !keywords.isEmpty()) {
|
if (destZone2.equals("Battlefield") && !keywords.isEmpty()) {
|
||||||
for (String kw : keywords) c.addExtrinsicKeyword(kw);
|
for (String kw : keywords) {
|
||||||
|
c.addExtrinsicKeyword(kw);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -436,12 +491,14 @@ public class AbilityFactory_Reveal {
|
|||||||
* @param list a {@link forge.CardList} object.
|
* @param list a {@link forge.CardList} object.
|
||||||
* @return a {@link forge.CardList} object.
|
* @return a {@link forge.CardList} object.
|
||||||
*/
|
*/
|
||||||
private static CardList sharesNameWithCardOnBattlefield(CardList list) {
|
private static CardList sharesNameWithCardOnBattlefield(final CardList list) {
|
||||||
CardList toReturn = new CardList();
|
CardList toReturn = new CardList();
|
||||||
CardList play = AllZoneUtil.getCardsInPlay();
|
CardList play = AllZoneUtil.getCardsInPlay();
|
||||||
for (Card c : list) {
|
for (Card c : list) {
|
||||||
for (Card p : play) {
|
for (Card p : play) {
|
||||||
if (p.getName().equals(c.getName())) toReturn.add(c);
|
if (p.getName().equals(c.getName())) {
|
||||||
|
toReturn.add(c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return toReturn;
|
return toReturn;
|
||||||
@@ -477,7 +534,7 @@ public class AbilityFactory_Reveal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return digUntilTriggerAI(af, this, mandatory);
|
return digUntilTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,7 +596,7 @@ public class AbilityFactory_Reveal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return digUntilTriggerAI(af, this, mandatory);
|
return digUntilTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -547,7 +604,6 @@ public class AbilityFactory_Reveal {
|
|||||||
return dbDig;
|
return dbDig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>digUntilStackDescription.</p>
|
* <p>digUntilStackDescription.</p>
|
||||||
*
|
*
|
||||||
@@ -555,7 +611,7 @@ public class AbilityFactory_Reveal {
|
|||||||
* @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 digUntilStackDescription(AbilityFactory af, SpellAbility sa) {
|
private static String digUntilStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
HashMap<String, String> params = af.getMapParams();
|
||||||
Card host = sa.getSourceCard();
|
Card host = sa.getSourceCard();
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
@@ -570,18 +626,20 @@ public class AbilityFactory_Reveal {
|
|||||||
untilAmount = AbilityFactory.calculateAmount(af.getHostCard(), params.get("Amount"), sa);
|
untilAmount = AbilityFactory.calculateAmount(af.getHostCard(), params.get("Amount"), sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(sa instanceof Ability_Sub))
|
if (!(sa instanceof Ability_Sub)) {
|
||||||
sb.append(host).append(" - ");
|
sb.append(host).append(" - ");
|
||||||
else
|
} else {
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
}
|
||||||
|
|
||||||
for (Player pl : tgtPlayers) {
|
for (Player pl : tgtPlayers) {
|
||||||
sb.append(pl).append(" ");
|
sb.append(pl).append(" ");
|
||||||
@@ -589,7 +647,9 @@ public class AbilityFactory_Reveal {
|
|||||||
|
|
||||||
sb.append("reveals cards from his or her library until revealing ");
|
sb.append("reveals cards from his or her library until revealing ");
|
||||||
sb.append(untilAmount).append(" ").append(desc);
|
sb.append(untilAmount).append(" ").append(desc);
|
||||||
if (untilAmount != 1) sb.append("s");
|
if (untilAmount != 1) {
|
||||||
|
sb.append("s");
|
||||||
|
}
|
||||||
sb.append(". Put ");
|
sb.append(". Put ");
|
||||||
|
|
||||||
String found = params.get("FoundDestination");
|
String found = params.get("FoundDestination");
|
||||||
@@ -632,8 +692,9 @@ public class AbilityFactory_Reveal {
|
|||||||
private static boolean digUntilCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
private static boolean digUntilCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
|
|
||||||
double chance = .4; // 40 percent chance with instant speed stuff
|
double chance = .4; // 40 percent chance with instant speed stuff
|
||||||
if (AbilityFactory.isSorcerySpeed(sa))
|
if (AbilityFactory.isSorcerySpeed(sa)) {
|
||||||
chance = .667; // 66.7% chance for sorcery speed (since it will never activate EOT)
|
chance = .667; // 66.7% chance for sorcery speed (since it will never activate EOT)
|
||||||
|
}
|
||||||
Random r = MyRandom.random;
|
Random r = MyRandom.random;
|
||||||
boolean randomReturn = r.nextFloat() <= Math.pow(chance, sa.getActivationsThisTurn() + 1);
|
boolean randomReturn = r.nextFloat() <= Math.pow(chance, sa.getActivationsThisTurn() + 1);
|
||||||
|
|
||||||
@@ -642,16 +703,18 @@ public class AbilityFactory_Reveal {
|
|||||||
|
|
||||||
if (sa.getTarget() != null) {
|
if (sa.getTarget() != null) {
|
||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
if (!AllZone.getHumanPlayer().canTarget(sa))
|
if (!AllZone.getHumanPlayer().canTarget(sa)) {
|
||||||
return false;
|
return false;
|
||||||
else
|
} else {
|
||||||
sa.getTarget().addTarget(AllZone.getHumanPlayer());
|
sa.getTarget().addTarget(AllZone.getHumanPlayer());
|
||||||
|
}
|
||||||
libraryOwner = AllZone.getHumanPlayer();
|
libraryOwner = AllZone.getHumanPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
//return false if nothing to dig into
|
//return false if nothing to dig into
|
||||||
if (AllZoneUtil.getCardsInZone(Constant.Zone.Library, libraryOwner).isEmpty())
|
if (AllZoneUtil.getCardsInZone(Constant.Zone.Library, libraryOwner).isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (af.hasSubAbility()) {
|
if (af.hasSubAbility()) {
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
Ability_Sub abSub = sa.getSubAbility();
|
||||||
@@ -671,9 +734,10 @@ public class AbilityFactory_Reveal {
|
|||||||
* @param mandatory a boolean.
|
* @param mandatory a boolean.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean digUntilTriggerAI(final AbilityFactory af, final SpellAbility sa, boolean mandatory) {
|
private static boolean digUntilTriggerAI(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
|
||||||
if (!ComputerUtil.canPayCost(sa))
|
if (!ComputerUtil.canPayCost(sa)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Target tgt = sa.getTarget();
|
Target tgt = sa.getTarget();
|
||||||
|
|
||||||
@@ -715,10 +779,12 @@ public class AbilityFactory_Reveal {
|
|||||||
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(host, params.get("Defined"), sa);
|
tgtPlayers = AbilityFactory.getDefinedPlayers(host, params.get("Defined"), sa);
|
||||||
|
}
|
||||||
|
|
||||||
String foundDest = params.get("FoundDestination");
|
String foundDest = params.get("FoundDestination");
|
||||||
int foundLibPos = AbilityFactory.calculateAmount(host, params.get("FoundLibraryPosition"), sa);
|
int foundLibPos = AbilityFactory.calculateAmount(host, params.get("FoundLibraryPosition"), sa);
|
||||||
@@ -750,7 +816,7 @@ public class AbilityFactory_Reveal {
|
|||||||
|
|
||||||
GuiUtils.getChoice(p + " revealed: ", revealed.toArray());
|
GuiUtils.getChoice(p + " revealed: ", revealed.toArray());
|
||||||
|
|
||||||
// TODO: Allow Human to choose the order
|
// TODO Allow Human to choose the order
|
||||||
if (foundDest != null) {
|
if (foundDest != null) {
|
||||||
Iterator<Card> itr = found.iterator();
|
Iterator<Card> itr = found.iterator();
|
||||||
while (itr.hasNext()) {
|
while (itr.hasNext()) {
|
||||||
@@ -799,7 +865,7 @@ public class AbilityFactory_Reveal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return revealHandTrigger(af, this, mandatory);
|
return revealHandTrigger(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -863,7 +929,7 @@ public class AbilityFactory_Reveal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return revealHandTrigger(af, this, mandatory);
|
return revealHandTrigger(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -878,28 +944,33 @@ public class AbilityFactory_Reveal {
|
|||||||
* @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 revealHandStackDescription(AbilityFactory af, SpellAbility sa) {
|
private static String revealHandStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
HashMap<String, String> params = af.getMapParams();
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
if (!(sa instanceof Ability_Sub))
|
if (!(sa instanceof Ability_Sub)) {
|
||||||
sb.append(sa.getSourceCard()).append(" - ");
|
sb.append(sa.getSourceCard()).append(" - ");
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
}
|
||||||
|
|
||||||
sb.append(sa.getActivatingPlayer()).append(" looks at ");
|
sb.append(sa.getActivatingPlayer()).append(" looks at ");
|
||||||
|
|
||||||
if (tgtPlayers.size() > 0) {
|
if (tgtPlayers.size() > 0) {
|
||||||
for (Player p : tgtPlayers)
|
for (Player p : tgtPlayers) {
|
||||||
sb.append(p.toString()).append("'s ");
|
sb.append(p.toString()).append("'s ");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
sb.append("Error - no target players for RevealHand. ");
|
sb.append("Error - no target players for RevealHand. ");
|
||||||
}
|
}
|
||||||
@@ -920,24 +991,28 @@ public class AbilityFactory_Reveal {
|
|||||||
* @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 revealHandCanPlayAI(final AbilityFactory af, SpellAbility sa) {
|
private static boolean revealHandCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
// AI cannot use this properly until he can use SAs during Humans turn
|
// AI cannot use this properly until he can use SAs during Humans turn
|
||||||
Cost abCost = sa.getPayCosts();
|
Cost abCost = sa.getPayCosts();
|
||||||
Card source = sa.getSourceCard();
|
Card source = sa.getSourceCard();
|
||||||
|
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
if (!CostUtil.checkSacrificeCost(abCost, source))
|
if (!CostUtil.checkSacrificeCost(abCost, source)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!CostUtil.checkRemoveCounterCost(abCost, source))
|
if (!CostUtil.checkRemoveCounterCost(abCost, source)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -949,12 +1024,14 @@ public class AbilityFactory_Reveal {
|
|||||||
Random r = MyRandom.random;
|
Random r = MyRandom.random;
|
||||||
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(sa)) {
|
||||||
randomReturn = true;
|
randomReturn = true;
|
||||||
|
}
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null)
|
if (subAb != null) {
|
||||||
randomReturn &= subAb.chkAI_Drawback();
|
randomReturn &= subAb.chkAI_Drawback();
|
||||||
|
}
|
||||||
return randomReturn;
|
return randomReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -967,7 +1044,9 @@ public class AbilityFactory_Reveal {
|
|||||||
* @param mandatory a boolean.
|
* @param mandatory a boolean.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean revealHandTargetAI(AbilityFactory af, SpellAbility sa, boolean primarySA, boolean mandatory) {
|
private static boolean revealHandTargetAI(final AbilityFactory af, final SpellAbility sa,
|
||||||
|
final boolean primarySA, final boolean mandatory)
|
||||||
|
{
|
||||||
Target tgt = af.getAbTgt();
|
Target tgt = af.getAbTgt();
|
||||||
|
|
||||||
int humanHandSize = AllZoneUtil.getPlayerHand(AllZone.getHumanPlayer()).size();
|
int humanHandSize = AllZoneUtil.getPlayerHand(AllZone.getHumanPlayer()).size();
|
||||||
@@ -978,10 +1057,12 @@ public class AbilityFactory_Reveal {
|
|||||||
|
|
||||||
boolean canTgtHuman = AllZone.getHumanPlayer().canTarget(sa);
|
boolean canTgtHuman = AllZone.getHumanPlayer().canTarget(sa);
|
||||||
|
|
||||||
if (!canTgtHuman || humanHandSize == 0)
|
if (!canTgtHuman || humanHandSize == 0) {
|
||||||
return false;
|
return false;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
tgt.addTarget(AllZone.getHumanPlayer());
|
tgt.addTarget(AllZone.getHumanPlayer());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
//if it's just defined, no big deal
|
//if it's just defined, no big deal
|
||||||
}
|
}
|
||||||
@@ -998,11 +1079,13 @@ public class AbilityFactory_Reveal {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean revealHandTrigger(AbilityFactory af, SpellAbility sa, boolean mandatory) {
|
private static boolean revealHandTrigger(AbilityFactory af, SpellAbility sa, boolean mandatory) {
|
||||||
if (!ComputerUtil.canPayCost(sa)) // If there is a cost payment
|
if (!ComputerUtil.canPayCost(sa)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!revealHandTargetAI(af, sa, false, mandatory))
|
if (!revealHandTargetAI(af, sa, false, mandatory)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// check SubAbilities DoTrigger?
|
// check SubAbilities DoTrigger?
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
Ability_Sub abSub = sa.getSubAbility();
|
||||||
@@ -1025,10 +1108,12 @@ public class AbilityFactory_Reveal {
|
|||||||
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);
|
||||||
|
}
|
||||||
|
|
||||||
for (Player p : tgtPlayers) {
|
for (Player p : tgtPlayers) {
|
||||||
if (tgt == null || p.canTarget(sa)) {
|
if (tgt == null || p.canTarget(sa)) {
|
||||||
@@ -1078,7 +1163,7 @@ public class AbilityFactory_Reveal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return scryTriggerAI(af, this);
|
return scryTriggerAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1117,13 +1202,12 @@ public class AbilityFactory_Reveal {
|
|||||||
/**
|
/**
|
||||||
* <p>createDrawbackScry.</p>
|
* <p>createDrawbackScry.</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 createDrawbackScry(final AbilityFactory AF) {
|
public static SpellAbility createDrawbackScry(final AbilityFactory af) {
|
||||||
final SpellAbility dbScry = new Ability_Sub(AF.getHostCard(), AF.getAbTgt()) {
|
final SpellAbility dbScry = new Ability_Sub(af.getHostCard(), af.getAbTgt()) {
|
||||||
private static final long serialVersionUID = 7763043327497404630L;
|
private static final long serialVersionUID = 7763043327497404630L;
|
||||||
final AbilityFactory af = AF;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
@@ -1142,7 +1226,7 @@ public class AbilityFactory_Reveal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return scryTriggerAI(af, this);
|
return scryTriggerAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1160,16 +1244,19 @@ public class AbilityFactory_Reveal {
|
|||||||
HashMap<String, String> params = af.getMapParams();
|
HashMap<String, String> params = af.getMapParams();
|
||||||
|
|
||||||
int num = 1;
|
int num = 1;
|
||||||
if (params.containsKey("ScryNum"))
|
if (params.containsKey("ScryNum")) {
|
||||||
num = AbilityFactory.calculateAmount(sa.getSourceCard(), params.get("ScryNum"), sa);
|
num = AbilityFactory.calculateAmount(sa.getSourceCard(), params.get("ScryNum"), sa);
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
}
|
||||||
|
|
||||||
for (Player p : tgtPlayers) {
|
for (Player p : tgtPlayers) {
|
||||||
if (tgt == null || p.canTarget(sa)) {
|
if (tgt == null || p.canTarget(sa)) {
|
||||||
@@ -1185,7 +1272,7 @@ public class AbilityFactory_Reveal {
|
|||||||
* @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 scryTargetAI(AbilityFactory af, SpellAbility sa) {
|
private static boolean scryTargetAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
Target tgt = af.getAbTgt();
|
Target tgt = af.getAbTgt();
|
||||||
|
|
||||||
if (tgt != null) { // It doesn't appear that Scry ever targets
|
if (tgt != null) { // It doesn't appear that Scry ever targets
|
||||||
@@ -1205,9 +1292,10 @@ public class AbilityFactory_Reveal {
|
|||||||
* @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 scryTriggerAI(AbilityFactory af, SpellAbility sa) {
|
private static boolean scryTriggerAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
if (!ComputerUtil.canPayCost(sa))
|
if (!ComputerUtil.canPayCost(sa)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return scryTargetAI(af, sa);
|
return scryTargetAI(af, sa);
|
||||||
} // scryTargetAI()
|
} // scryTargetAI()
|
||||||
@@ -1219,29 +1307,35 @@ public class AbilityFactory_Reveal {
|
|||||||
* @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 scryStackDescription(AbilityFactory af, SpellAbility sa) {
|
private static String scryStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
HashMap<String, String> params = af.getMapParams();
|
||||||
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(" ");
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
}
|
||||||
|
|
||||||
for (Player p : tgtPlayers)
|
for (Player p : tgtPlayers) {
|
||||||
sb.append(p.toString()).append(" ");
|
sb.append(p.toString()).append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
int num = 1;
|
int num = 1;
|
||||||
if (params.containsKey("ScryNum"))
|
if (params.containsKey("ScryNum")) {
|
||||||
num = AbilityFactory.calculateAmount(sa.getSourceCard(), params.get("ScryNum"), sa);
|
num = AbilityFactory.calculateAmount(sa.getSourceCard(), params.get("ScryNum"), sa);
|
||||||
|
}
|
||||||
|
|
||||||
sb.append("scrys (").append(num).append(").");
|
sb.append("scrys (").append(num).append(").");
|
||||||
|
|
||||||
@@ -1260,17 +1354,19 @@ public class AbilityFactory_Reveal {
|
|||||||
* @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 scryCanPlayAI(final AbilityFactory af, SpellAbility sa) {
|
private static boolean scryCanPlayAI(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 stuff
|
double chance = .4; // 40 percent chance of milling with instant speed stuff
|
||||||
if (AbilityFactory.isSorcerySpeed(sa))
|
if (AbilityFactory.isSorcerySpeed(sa)) {
|
||||||
chance = .667; // 66.7% chance for sorcery speed (since it will never activate EOT)
|
chance = .667; // 66.7% chance for sorcery speed (since it will never activate EOT)
|
||||||
|
}
|
||||||
Random r = MyRandom.random;
|
Random r = MyRandom.random;
|
||||||
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(sa)) {
|
||||||
randomReturn = true;
|
randomReturn = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (af.hasSubAbility()) {
|
if (af.hasSubAbility()) {
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
Ability_Sub abSub = sa.getSubAbility();
|
||||||
@@ -1288,16 +1384,16 @@ public class AbilityFactory_Reveal {
|
|||||||
/**
|
/**
|
||||||
* <p>createRearrangeTopOfLibraryAbility.</p>
|
* <p>createRearrangeTopOfLibraryAbility.</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 createRearrangeTopOfLibraryAbility(final AbilityFactory AF) {
|
public static SpellAbility createRearrangeTopOfLibraryAbility(final AbilityFactory af) {
|
||||||
final SpellAbility RTOLAbility = new Ability_Activated(AF.getHostCard(), AF.getAbCost(), AF.getAbTgt()) {
|
final SpellAbility rtolAbility = new Ability_Activated(af.getHostCard(), af.getAbCost(), af.getAbTgt()) {
|
||||||
private static final long serialVersionUID = -548494891203983219L;
|
private static final long serialVersionUID = -548494891203983219L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return rearrangeTopOfLibraryStackDescription(AF, this);
|
return rearrangeTopOfLibraryStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1306,33 +1402,33 @@ public class AbilityFactory_Reveal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return rearrangeTopOfLibraryTrigger(AF, this, mandatory);
|
return rearrangeTopOfLibraryTrigger(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
rearrangeTopOfLibraryResolve(AF, this);
|
rearrangeTopOfLibraryResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return RTOLAbility;
|
return rtolAbility;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>createRearrangeTopOfLibrarySpell.</p>
|
* <p>createRearrangeTopOfLibrarySpell.</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 createRearrangeTopOfLibrarySpell(final AbilityFactory AF) {
|
public static SpellAbility createRearrangeTopOfLibrarySpell(final AbilityFactory af) {
|
||||||
final SpellAbility RTOLSpell = new Spell(AF.getHostCard(), AF.getAbCost(), AF.getAbTgt()) {
|
final SpellAbility rtolSpell = new Spell(af.getHostCard(), af.getAbCost(), af.getAbTgt()) {
|
||||||
private static final long serialVersionUID = 6977502611509431864L;
|
private static final long serialVersionUID = 6977502611509431864L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return rearrangeTopOfLibraryStackDescription(AF, this);
|
return rearrangeTopOfLibraryStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1341,39 +1437,39 @@ public class AbilityFactory_Reveal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return rearrangeTopOfLibraryTrigger(AF, this, mandatory);
|
return rearrangeTopOfLibraryTrigger(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
rearrangeTopOfLibraryResolve(AF, this);
|
rearrangeTopOfLibraryResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return RTOLSpell;
|
return rtolSpell;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>createRearrangeTopOfLibraryDrawback.</p>
|
* <p>createRearrangeTopOfLibraryDrawback.</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 createRearrangeTopOfLibraryDrawback(final AbilityFactory AF) {
|
public static SpellAbility createRearrangeTopOfLibraryDrawback(final AbilityFactory af) {
|
||||||
final SpellAbility dbDraw = new Ability_Sub(AF.getHostCard(), AF.getAbTgt()) {
|
final SpellAbility dbDraw = new Ability_Sub(af.getHostCard(), af.getAbTgt()) {
|
||||||
private static final long serialVersionUID = -777856059960750319L;
|
private static final long serialVersionUID = -777856059960750319L;
|
||||||
|
|
||||||
@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
|
||||||
return rearrangeTopOfLibraryStackDescription(AF, this);
|
return rearrangeTopOfLibraryStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
rearrangeTopOfLibraryResolve(AF, this);
|
rearrangeTopOfLibraryResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1382,8 +1478,8 @@ public class AbilityFactory_Reveal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return rearrangeTopOfLibraryTrigger(AF, this, mandatory);
|
return rearrangeTopOfLibraryTrigger(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -1404,13 +1500,15 @@ public class AbilityFactory_Reveal {
|
|||||||
boolean shuffle = false;
|
boolean shuffle = false;
|
||||||
|
|
||||||
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);
|
||||||
|
}
|
||||||
|
|
||||||
numCards = AbilityFactory.calculateAmount(af.getHostCard(), params.get("NumCards"), sa);
|
numCards = AbilityFactory.calculateAmount(af.getHostCard(), params.get("NumCards"), sa);
|
||||||
shuffle = params.containsKey("MayShuffle") ? true : false;
|
shuffle = params.containsKey("MayShuffle");
|
||||||
|
|
||||||
StringBuilder ret = new StringBuilder();
|
StringBuilder ret = new StringBuilder();
|
||||||
if (!(sa instanceof Ability_Sub)) {
|
if (!(sa instanceof Ability_Sub)) {
|
||||||
@@ -1451,7 +1549,9 @@ public class AbilityFactory_Reveal {
|
|||||||
* @param mandatory a boolean.
|
* @param mandatory a boolean.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean rearrangeTopOfLibraryTrigger(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
|
private static boolean rearrangeTopOfLibraryTrigger(final AbilityFactory af,
|
||||||
|
final SpellAbility sa, final boolean mandatory)
|
||||||
|
{
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
Target tgt = af.getAbTgt();
|
||||||
|
|
||||||
@@ -1461,11 +1561,14 @@ public class AbilityFactory_Reveal {
|
|||||||
|
|
||||||
boolean canTgtHuman = AllZone.getHumanPlayer().canTarget(sa);
|
boolean canTgtHuman = AllZone.getHumanPlayer().canTarget(sa);
|
||||||
|
|
||||||
if (!canTgtHuman)
|
if (!canTgtHuman) {
|
||||||
return false;
|
return false;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
tgt.addTarget(AllZone.getHumanPlayer());
|
tgt.addTarget(AllZone.getHumanPlayer());
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
//if it's just defined, no big deal
|
//if it's just defined, no big deal
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1491,19 +1594,23 @@ public class AbilityFactory_Reveal {
|
|||||||
|
|
||||||
if (sa.getActivatingPlayer().isHuman()) {
|
if (sa.getActivatingPlayer().isHuman()) {
|
||||||
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);
|
||||||
|
}
|
||||||
|
|
||||||
numCards = AbilityFactory.calculateAmount(af.getHostCard(), params.get("NumCards"), sa);
|
numCards = AbilityFactory.calculateAmount(af.getHostCard(), params.get("NumCards"), sa);
|
||||||
shuffle = params.containsKey("MayShuffle") ? true : false;
|
shuffle = params.containsKey("MayShuffle");
|
||||||
|
|
||||||
for (Player p : tgtPlayers)
|
for (Player p : tgtPlayers) {
|
||||||
if (tgt == null || p.canTarget(sa))
|
if (tgt == null || p.canTarget(sa)) {
|
||||||
rearrangeTopOfLibrary(af.getHostCard(), p, numCards, shuffle);
|
rearrangeTopOfLibrary(af.getHostCard(), p, numCards, shuffle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* use this when Human needs to rearrange the top X cards in a player's library. You
|
* use this when Human needs to rearrange the top X cards in a player's library. You
|
||||||
@@ -1514,11 +1621,15 @@ public class AbilityFactory_Reveal {
|
|||||||
* @param numCards the number of cards from the top to rearrange
|
* @param numCards the number of cards from the top to rearrange
|
||||||
* @param mayshuffle a boolean.
|
* @param mayshuffle a boolean.
|
||||||
*/
|
*/
|
||||||
private static void rearrangeTopOfLibrary(final Card src, final Player player, final int numCards, boolean mayshuffle) {
|
private static void rearrangeTopOfLibrary(final Card src, final Player player,
|
||||||
|
final int numCards, final boolean mayshuffle)
|
||||||
|
{
|
||||||
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
|
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
|
||||||
int maxCards = lib.size();
|
int maxCards = lib.size();
|
||||||
maxCards = Math.min(maxCards, numCards);
|
maxCards = Math.min(maxCards, numCards);
|
||||||
if (maxCards == 0) return;
|
if (maxCards == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
CardList topCards = new CardList();
|
CardList topCards = new CardList();
|
||||||
//show top n cards:
|
//show top n cards:
|
||||||
for (int j = 0; j < maxCards; j++) {
|
for (int j = 0; j < maxCards; j++) {
|
||||||
@@ -1541,10 +1652,12 @@ public class AbilityFactory_Reveal {
|
|||||||
}
|
}
|
||||||
String title = "Put " + i + suffix + " from the top: ";
|
String title = "Put " + i + suffix + " from the top: ";
|
||||||
Object o = GuiUtils.getChoiceOptional(title, topCards.toArray());
|
Object o = GuiUtils.getChoiceOptional(title, topCards.toArray());
|
||||||
if (o == null) break;
|
if (o == null) {
|
||||||
Card c_1 = (Card) o;
|
break;
|
||||||
topCards.remove(c_1);
|
}
|
||||||
AllZone.getGameAction().moveToLibrary(c_1, i - 1);
|
Card c1 = (Card) o;
|
||||||
|
topCards.remove(c1);
|
||||||
|
AllZone.getGameAction().moveToLibrary(c1, i - 1);
|
||||||
}
|
}
|
||||||
if (mayshuffle) {
|
if (mayshuffle) {
|
||||||
if (GameActionUtil.showYesNoDialog(src, "Do you want to shuffle the library?")) {
|
if (GameActionUtil.showYesNoDialog(src, "Do you want to shuffle the library?")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user