mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
- AI improvements for AF Sacrifice with the Destroy parameter.
This commit is contained in:
@@ -2179,7 +2179,7 @@ public class CombatUtil {
|
|||||||
public void resolve() {
|
public void resolve() {
|
||||||
if (crd.getController().isHuman()) {
|
if (crd.getController().isHuman()) {
|
||||||
final CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
|
final CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
|
||||||
ComputerUtil.sacrificePermanents(a, list);
|
ComputerUtil.sacrificePermanents(a, list, false);
|
||||||
} else {
|
} else {
|
||||||
AllZone.getInputControl().setInput(PlayerUtil.inputSacrificePermanents(a));
|
AllZone.getInputControl().setInput(PlayerUtil.inputSacrificePermanents(a));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1524,7 +1524,7 @@ public class ComputerUtil {
|
|||||||
* a {@link forge.CardList} object.
|
* a {@link forge.CardList} object.
|
||||||
* @return the card list
|
* @return the card list
|
||||||
*/
|
*/
|
||||||
public static CardList sacrificePermanents(final int amount, final CardList list) {
|
public static CardList sacrificePermanents(final int amount, final CardList list, boolean destroy) {
|
||||||
final CardList sacList = new CardList();
|
final CardList sacList = new CardList();
|
||||||
// used in Annihilator and AF_Sacrifice
|
// used in Annihilator and AF_Sacrifice
|
||||||
int max = list.size();
|
int max = list.size();
|
||||||
@@ -1536,33 +1536,46 @@ public class ComputerUtil {
|
|||||||
list.reverse();
|
list.reverse();
|
||||||
|
|
||||||
for (int i = 0; i < max; i++) {
|
for (int i = 0; i < max; i++) {
|
||||||
// TODO: use getWorstPermanent() would be wayyyy better
|
Card c = null;
|
||||||
|
|
||||||
Card c;
|
if (destroy) {
|
||||||
if (list.getNotType("Creature").size() == 0) {
|
CardList indestructibles = list.getKeyword("Indestructible");
|
||||||
c = CardFactoryUtil.getWorstCreatureAI(list);
|
if (!indestructibles.isEmpty()) {
|
||||||
} else if (list.getNotType("Land").size() == 0) {
|
c = indestructibles.get(0);
|
||||||
c = CardFactoryUtil.getWorstLand(AllZone.getComputerPlayer());
|
}
|
||||||
} else {
|
} else {
|
||||||
c = list.get(0);
|
if (list.getNotType("Creature").size() == 0) {
|
||||||
}
|
c = CardFactoryUtil.getWorstCreatureAI(list);
|
||||||
|
} else if (list.getNotType("Land").size() == 0) {
|
||||||
|
c = CardFactoryUtil.getWorstLand(AllZone.getComputerPlayer());
|
||||||
|
} else {
|
||||||
|
c = CardFactoryUtil.getWorstPermanentAI(list, true, true, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
final ArrayList<Card> auras = c.getEnchantedBy();
|
final ArrayList<Card> auras = c.getEnchantedBy();
|
||||||
|
|
||||||
if (auras.size() > 0) {
|
if (auras.size() > 0) {
|
||||||
// TODO: choose "worst" controlled enchanting Aura
|
// TODO: choose "worst" controlled enchanting Aura
|
||||||
for (int j = 0; j < auras.size(); j++) {
|
for (int j = 0; j < auras.size(); j++) {
|
||||||
final Card aura = auras.get(j);
|
final Card aura = auras.get(j);
|
||||||
if (aura.getController().isPlayer(c.getController()) && list.contains(aura)) {
|
if (aura.getController().isPlayer(c.getController()) && list.contains(aura)) {
|
||||||
c = aura;
|
c = aura;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (destroy) {
|
||||||
|
if(!AllZone.getGameAction().destroy(c)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(!AllZone.getGameAction().sacrifice(c)) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list.remove(c);
|
list.remove(c);
|
||||||
sacList.add(c);
|
sacList.add(c);
|
||||||
AllZone.getGameAction().sacrifice(c);
|
|
||||||
}
|
}
|
||||||
return sacList;
|
return sacList;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,7 +214,12 @@ public class AbilityFactorySacrifice {
|
|||||||
msg = valid;
|
msg = valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append("Sacrifices ").append(amount).append(" ").append(msg).append(".");
|
if (params.containsKey("Destroy")) {
|
||||||
|
sb.append("Destroys ");
|
||||||
|
} else {
|
||||||
|
sb.append("Sacrifices ");
|
||||||
|
}
|
||||||
|
sb.append(amount).append(" ").append(msg).append(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
final AbilitySub abSub = sa.getSubAbility();
|
final AbilitySub abSub = sa.getSubAbility();
|
||||||
@@ -514,7 +519,7 @@ public class AbilityFactorySacrifice {
|
|||||||
CardList list = p.getCardsIn(Zone.Battlefield);
|
CardList list = p.getCardsIn(Zone.Battlefield);
|
||||||
list = list.getValidCards(valid.split(","), sa.getActivatingPlayer(), sa.getSourceCard());
|
list = list.getValidCards(valid.split(","), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||||
|
|
||||||
final CardList sacList = ComputerUtil.sacrificePermanents(amount, list);
|
final CardList sacList = ComputerUtil.sacrificePermanents(amount, list, destroy);
|
||||||
|
|
||||||
return sacList;
|
return sacList;
|
||||||
}
|
}
|
||||||
@@ -551,11 +556,11 @@ public class AbilityFactorySacrifice {
|
|||||||
final Card c = (Card) o;
|
final Card c = (Card) o;
|
||||||
|
|
||||||
if (destroy) {
|
if (destroy) {
|
||||||
if(!AllZone.getGameAction().destroy(c)) {
|
if (!AllZone.getGameAction().destroy(c)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(!AllZone.getGameAction().sacrifice(c)){
|
if (!AllZone.getGameAction().sacrifice(c)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user