mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
- Added Research // Development, Tainted Specter, and Uba Mask
This commit is contained in:
@@ -320,9 +320,9 @@ public class Cost {
|
||||
return new CostExiledMoveToGrave(splitStr[0], splitStr[1], description);
|
||||
}
|
||||
|
||||
if (parse.startsWith("DrawYou<")) {
|
||||
final String[] splitStr = abCostParse(parse, 1);
|
||||
return new CostDraw(splitStr[0], "You");
|
||||
if (parse.startsWith("Draw<")) {
|
||||
final String[] splitStr = abCostParse(parse, 2);
|
||||
return new CostDraw(splitStr[0], splitStr[1]);
|
||||
}
|
||||
|
||||
if (parse.startsWith("PutCardToLibFromHand<")) {
|
||||
|
||||
@@ -58,16 +58,12 @@ public class CostDraw extends CostPart {
|
||||
* @param payer
|
||||
* @param source
|
||||
*/
|
||||
private List<Player> getPotentialPlayers(final Player payer, final SpellAbility ability) {
|
||||
private List<Player> getPotentialPlayers(final Player payer, final Card source) {
|
||||
List<Player> res = new ArrayList<Player>();
|
||||
String type = this.getType();
|
||||
if ("Activator".equals(type)) {
|
||||
res.add(ability.getActivatingPlayer());
|
||||
} else {
|
||||
for (Player p : payer.getGame().getPlayers()) {
|
||||
if (p.isValid(type, payer, ability.getSourceCard())) {
|
||||
res.add(p);
|
||||
}
|
||||
for (Player p : payer.getGame().getPlayers()) {
|
||||
if (p.isValid(type, payer, source) && p.canDraw()) {
|
||||
res.add(p);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
@@ -82,7 +78,7 @@ public class CostDraw extends CostPart {
|
||||
*/
|
||||
@Override
|
||||
public final boolean canPay(final SpellAbility ability) {
|
||||
List<Player> potentials = getPotentialPlayers(ability.getActivatingPlayer(), ability);
|
||||
List<Player> potentials = getPotentialPlayers(ability.getActivatingPlayer(), ability.getSourceCard());
|
||||
return !potentials.isEmpty();
|
||||
}
|
||||
|
||||
@@ -94,7 +90,7 @@ public class CostDraw extends CostPart {
|
||||
*/
|
||||
@Override
|
||||
public final void payAI(final PaymentDecision decision, final Player ai, SpellAbility ability, Card source) {
|
||||
for (final Player p : getPotentialPlayers(ai, ability)) {
|
||||
for (final Player p : getPotentialPlayers(ai, ability.getSourceCard())) {
|
||||
p.drawCards(decision.c);
|
||||
}
|
||||
}
|
||||
@@ -109,7 +105,7 @@ public class CostDraw extends CostPart {
|
||||
@Override
|
||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
||||
final String amount = this.getAmount();
|
||||
final List<Player> players = getPotentialPlayers(ability.getActivatingPlayer(), ability);
|
||||
final List<Player> players = getPotentialPlayers(ability.getActivatingPlayer(), ability.getSourceCard());
|
||||
final Card source = ability.getSourceCard();
|
||||
|
||||
Integer c = this.convertAmount();
|
||||
|
||||
@@ -170,7 +170,7 @@ public class CostExiledMoveToGrave extends CostPartWithList {
|
||||
|
||||
List<Card> typeList = ai.getGame().getCardsIn(ZoneType.Exile);
|
||||
|
||||
typeList = CardLists.getValidCards(typeList, this.getType().split(","), ai, source);
|
||||
typeList = CardLists.getValidCards(typeList, this.getType().split(";"), ai, source);
|
||||
|
||||
if (typeList.size() < c) {
|
||||
return null;
|
||||
|
||||
@@ -64,6 +64,15 @@ public class CostPutCardToLib extends CostPartWithList {
|
||||
return this.libPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* isSameZone.
|
||||
*
|
||||
* @return a boolean
|
||||
*/
|
||||
public final boolean isSameZone() {
|
||||
return this.sameZone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new cost CostPutCardToLib.
|
||||
*
|
||||
|
||||
@@ -487,7 +487,7 @@ public class ComputerUtil {
|
||||
} else {
|
||||
typeList = ai.getCardsIn(zone);
|
||||
}
|
||||
typeList = CardLists.getValidCards(typeList, type.split(","), activate.getController(), activate);
|
||||
typeList = CardLists.getValidCards(typeList, type.split(";"), activate.getController(), activate);
|
||||
|
||||
if ((target != null) && target.getController() == ai && typeList.contains(target)) {
|
||||
typeList.remove(target); // don't exile the card we're pumping
|
||||
@@ -527,7 +527,7 @@ public class ComputerUtil {
|
||||
final Card target, final int amount) {
|
||||
List<Card> typeList = ai.getCardsIn(zone);
|
||||
|
||||
typeList = CardLists.getValidCards(typeList, type.split(","), activate.getController(), activate);
|
||||
typeList = CardLists.getValidCards(typeList, type.split(";"), activate.getController(), activate);
|
||||
|
||||
if ((target != null) && target.getController() == ai && typeList.contains(target)) {
|
||||
typeList.remove(target); // don't move the card we're pumping
|
||||
|
||||
@@ -408,13 +408,19 @@ public class ComputerUtilCost {
|
||||
if (c == null || c.isUntapped()) {
|
||||
return false;
|
||||
}
|
||||
} else if ("MorePowerful".equals(sa.getParam("UnlessAI"))) {
|
||||
final int sourceCreatures = sa.getActivatingPlayer().getCreaturesInPlay().size();
|
||||
final int payerCreatures = payer.getCreaturesInPlay().size();
|
||||
if (payerCreatures > sourceCreatures + 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// AI will only pay when it's not already payed and only opponents abilities
|
||||
if (alreadyPaid || (payers.size() > 1 && (isMine && !payForOwnOnly))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// AI was crashing because the blank ability used to pay costs
|
||||
// Didn't have any of the data on the original SA to pay dependant costs
|
||||
|
||||
|
||||
@@ -305,7 +305,7 @@ public class HumanPlay {
|
||||
if (parts.isEmpty() || costPart.getAmount().equals("0")) {
|
||||
return GuiDialog.confirm(source, "Do you want to pay 0?" + orString);
|
||||
}
|
||||
|
||||
|
||||
//the following costs do not need inputs
|
||||
for (CostPart part : parts) {
|
||||
boolean mayRemovePart = true;
|
||||
@@ -314,24 +314,41 @@ public class HumanPlay {
|
||||
final int amount = getAmountFromPart(part, source, sourceAbility);
|
||||
if (!p.canPayLife(amount))
|
||||
return false;
|
||||
|
||||
|
||||
if (false == GuiDialog.confirm(source, "Do you want to pay " + amount + " life?" + orString))
|
||||
return false;
|
||||
|
||||
|
||||
p.payLife(amount, null);
|
||||
}
|
||||
|
||||
else if (part instanceof CostDraw) {
|
||||
final int amount = getAmountFromPart(part, source, sourceAbility);
|
||||
if (!p.canDraw()) {
|
||||
List<Player> res = new ArrayList<Player>();
|
||||
String type = part.getType();
|
||||
for (Player player : p.getGame().getPlayers()) {
|
||||
if (player.isValid(type, p, source) && player.canDraw()) {
|
||||
res.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
if (res.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (false == GuiDialog.confirm(source, "Do you want to draw " + amount + " card(s)?" + orString)) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append("Do you want to ");
|
||||
sb.append(res.contains(p) ? "" : "let that player ");
|
||||
sb.append(amount);
|
||||
sb.append(" card(s)?" + orString);
|
||||
|
||||
if (!GuiDialog.confirm(source, sb.toString())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
p.drawCards(amount);
|
||||
for (Player player : res) {
|
||||
player.drawCards(amount);
|
||||
}
|
||||
}
|
||||
|
||||
else if (part instanceof CostMill) {
|
||||
@@ -412,47 +429,60 @@ public class HumanPlay {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
else if (part instanceof CostPutCardToLib) {
|
||||
//Jotun Grunt
|
||||
int amount = Integer.parseInt(((CostPutCardToLib) part).getAmount());
|
||||
final ZoneType from = ((CostPutCardToLib) part).getFrom();
|
||||
List<Card> list = CardLists.getValidCards(p.getGame().getCardsIn(from), part.getType().split(";"), p, source);
|
||||
List<Player> players = p.getGame().getPlayers();
|
||||
List<Player> payableZone = new ArrayList<Player>();
|
||||
for (Player player : players) {
|
||||
List<Card> enoughType = CardLists.filter(list, CardPredicates.isOwner(player));
|
||||
if (enoughType.size() < amount) {
|
||||
list.removeAll(enoughType);
|
||||
} else {
|
||||
payableZone.add(player);
|
||||
}
|
||||
}
|
||||
Player chosen = GuiChoose.oneOrNone(String.format("Put cards from whose %s?",
|
||||
((CostPutCardToLib) part).getFrom()), payableZone);
|
||||
if (chosen == null) {
|
||||
return false;
|
||||
final boolean sameZone = ((CostPutCardToLib) part).isSameZone();
|
||||
List<Card> list;
|
||||
if (sameZone) {
|
||||
list = p.getGame().getCardsIn(from);
|
||||
} else {
|
||||
list = p.getCardsIn(from);
|
||||
}
|
||||
|
||||
List<Card> typeList = CardLists.filter(list, CardPredicates.isOwner(chosen));
|
||||
|
||||
for (int i = 0; i < amount; i++) {
|
||||
if (typeList.isEmpty()) {
|
||||
list = CardLists.getValidCards(list, part.getType().split(";"), p, source);
|
||||
|
||||
if (sameZone) { // Jotun Grunt
|
||||
List<Player> players = p.getGame().getPlayers();
|
||||
List<Player> payableZone = new ArrayList<Player>();
|
||||
for (Player player : players) {
|
||||
List<Card> enoughType = CardLists.filter(list, CardPredicates.isOwner(player));
|
||||
if (enoughType.size() < amount) {
|
||||
list.removeAll(enoughType);
|
||||
} else {
|
||||
payableZone.add(player);
|
||||
}
|
||||
}
|
||||
Player chosen = GuiChoose.oneOrNone(String.format("Put cards from whose %s?", from), payableZone);
|
||||
if (chosen == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Card c = GuiChoose.oneOrNone("Put cards to Library", typeList);
|
||||
|
||||
if (c != null) {
|
||||
typeList.remove(c);
|
||||
p.getGame().getAction().moveToLibrary(c, Integer.parseInt(((CostPutCardToLib) part).getLibPos()));
|
||||
} else {
|
||||
|
||||
List<Card> typeList = CardLists.filter(list, CardPredicates.isOwner(chosen));
|
||||
|
||||
for (int i = 0; i < amount; i++) {
|
||||
if (typeList.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Card c = GuiChoose.oneOrNone("Put cards to Library", typeList);
|
||||
|
||||
if (c != null) {
|
||||
typeList.remove(c);
|
||||
p.getGame().getAction().moveToLibrary(c, Integer.parseInt(((CostPutCardToLib) part).getLibPos()));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (from == ZoneType.Hand) { // Tainted Specter
|
||||
boolean hasPaid = payCostPart(sourceAbility, (CostPartWithList)part, amount, list, "put into library." + orString);
|
||||
if (!hasPaid) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
else if (part instanceof CostSacrifice) {
|
||||
int amount = Integer.parseInt(((CostSacrifice)part).getAmount());
|
||||
List<Card> list = CardLists.getValidCards(p.getCardsIn(ZoneType.Battlefield), part.getType(), p, source);
|
||||
@@ -484,8 +514,9 @@ public class HumanPlay {
|
||||
else if (part instanceof CostPartMana ) {
|
||||
if (!((CostPartMana) part).getManaToPay().isZero()) // non-zero costs require input
|
||||
mayRemovePart = false;
|
||||
} else
|
||||
} else {
|
||||
throw new RuntimeException("GameActionUtil.payCostDuringAbilityResolve - An unhandled type of cost was met: " + part.getClass());
|
||||
}
|
||||
|
||||
if( mayRemovePart )
|
||||
remainingParts.remove(part);
|
||||
|
||||
Reference in New Issue
Block a user