mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
- Added some real code to proliferateShouldPlayAI.
- Fixed proliferateResolve for the AI.
This commit is contained in:
@@ -1347,12 +1347,38 @@ public class AbilityFactoryCounters {
|
|||||||
private static boolean proliferateShouldPlayAI(final SpellAbility sa) {
|
private static boolean proliferateShouldPlayAI(final SpellAbility sa) {
|
||||||
boolean chance = true;
|
boolean chance = true;
|
||||||
final AbilitySub subAb = sa.getSubAbility();
|
final AbilitySub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null && !subAb.chkAIDrawback()) {
|
||||||
chance &= subAb.chkAIDrawback();
|
return false;
|
||||||
}
|
}
|
||||||
|
CardList hperms = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
|
||||||
|
CardList cperms = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
|
||||||
|
cperms = cperms.filter(new CardListFilter() {
|
||||||
|
@Override
|
||||||
|
public boolean addCard(final Card crd) {
|
||||||
|
for (final Counters c1 : Counters.values()) {
|
||||||
|
if (crd.getCounters(c1) != 0 && !CardFactoryUtil.isNegativeCounter(c1)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// TODO Make sure Human has poison counters or there are some counters
|
hperms = hperms.filter(new CardListFilter() {
|
||||||
// we want to proliferate
|
@Override
|
||||||
|
public boolean addCard(final Card crd) {
|
||||||
|
for (final Counters c1 : Counters.values()) {
|
||||||
|
if (crd.getCounters(c1) != 0 && CardFactoryUtil.isNegativeCounter(c1)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if ((cperms.size() == 0) && (hperms.size() == 0) && (AllZone.getHumanPlayer().getPoisonCounters() == 0)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return chance;
|
return chance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1391,7 +1417,6 @@ public class AbilityFactoryCounters {
|
|||||||
*/
|
*/
|
||||||
private static void proliferateResolve(final AbilityFactory af, final SpellAbility sa) {
|
private static void proliferateResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||||
CardList hperms = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
|
CardList hperms = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
|
||||||
|
|
||||||
CardList cperms = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
|
CardList cperms = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
|
||||||
|
|
||||||
if (af.getHostCard().getController().isHuman()) {
|
if (af.getHostCard().getController().isHuman()) {
|
||||||
@@ -1458,36 +1483,28 @@ public class AbilityFactoryCounters {
|
|||||||
cperms = cperms.filter(new CardListFilter() {
|
cperms = cperms.filter(new CardListFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean addCard(final Card crd) {
|
public boolean addCard(final Card crd) {
|
||||||
int pos = 0;
|
|
||||||
int neg = 0;
|
|
||||||
for (final Counters c1 : Counters.values()) {
|
for (final Counters c1 : Counters.values()) {
|
||||||
if (crd.getCounters(c1) != 0) {
|
if (crd.getCounters(c1) != 0) {
|
||||||
if (CardFactoryUtil.isNegativeCounter(c1)) {
|
if (!CardFactoryUtil.isNegativeCounter(c1)) {
|
||||||
neg++;
|
return true;
|
||||||
} else {
|
|
||||||
pos++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pos > neg;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
hperms = hperms.filter(new CardListFilter() {
|
hperms = hperms.filter(new CardListFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean addCard(final Card crd) {
|
public boolean addCard(final Card crd) {
|
||||||
int pos = 0;
|
|
||||||
int neg = 0;
|
|
||||||
for (final Counters c1 : Counters.values()) {
|
for (final Counters c1 : Counters.values()) {
|
||||||
if (crd.getCounters(c1) != 0) {
|
if (crd.getCounters(c1) != 0) {
|
||||||
if (CardFactoryUtil.isNegativeCounter(c1)) {
|
if (CardFactoryUtil.isNegativeCounter(c1)) {
|
||||||
neg++;
|
return true;
|
||||||
} else {
|
|
||||||
pos++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pos < neg;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1518,22 +1535,24 @@ public class AbilityFactoryCounters {
|
|||||||
} // else
|
} // else
|
||||||
sb.append("</html>");
|
sb.append("</html>");
|
||||||
|
|
||||||
// add a counter for each counter type, if it would benefit the
|
// add a counter of one counter type, if it would benefit the
|
||||||
// computer
|
// computer
|
||||||
for (final Card c : cperms) {
|
for (final Card c : cperms) {
|
||||||
for (final Counters c1 : Counters.values()) {
|
for (final Counters c1 : Counters.values()) {
|
||||||
if (c.getCounters(c1) != 0) {
|
if (c.getCounters(c1) != 0 && !CardFactoryUtil.isNegativeCounter(c1)) {
|
||||||
c.addCounter(c1, 1);
|
c.addCounter(c1, 1);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add a counter for each counter type, if it would screw over the
|
// add a counter of one counter type, if it would screw over the
|
||||||
// player
|
// player
|
||||||
for (final Card c : hperms) {
|
for (final Card c : hperms) {
|
||||||
for (final Counters c1 : Counters.values()) {
|
for (final Counters c1 : Counters.values()) {
|
||||||
if (c.getCounters(c1) != 0) {
|
if (c.getCounters(c1) != 0 && CardFactoryUtil.isNegativeCounter(c1)) {
|
||||||
c.addCounter(c1, 1);
|
c.addCounter(c1, 1);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user