mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Merge remote-tracking branch 'upstream/master' into patch-carddb-performance
This commit is contained in:
@@ -238,6 +238,9 @@ public class ComputerUtilCost {
|
|||||||
}
|
}
|
||||||
for (final CostPart part : cost.getCostParts()) {
|
for (final CostPart part : cost.getCostParts()) {
|
||||||
if (part instanceof CostSacrifice) {
|
if (part instanceof CostSacrifice) {
|
||||||
|
if (!ai.isAI()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
CardCollection list = new CardCollection();
|
CardCollection list = new CardCollection();
|
||||||
final CardCollection exclude = new CardCollection();
|
final CardCollection exclude = new CardCollection();
|
||||||
if (AiCardMemory.getMemorySet(ai, MemorySet.PAYS_SAC_COST) != null) {
|
if (AiCardMemory.getMemorySet(ai, MemorySet.PAYS_SAC_COST) != null) {
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ public enum SpellApiToAi {
|
|||||||
.put(ApiType.ClassLevelUp, AlwaysPlayAi.class)
|
.put(ApiType.ClassLevelUp, AlwaysPlayAi.class)
|
||||||
.put(ApiType.Cleanup, AlwaysPlayAi.class)
|
.put(ApiType.Cleanup, AlwaysPlayAi.class)
|
||||||
.put(ApiType.Clone, CloneAi.class)
|
.put(ApiType.Clone, CloneAi.class)
|
||||||
|
.put(ApiType.CompanionChoose, ChooseCompanionAi.class)
|
||||||
.put(ApiType.CopyPermanent, CopyPermanentAi.class)
|
.put(ApiType.CopyPermanent, CopyPermanentAi.class)
|
||||||
.put(ApiType.CopySpellAbility, CopySpellAbilityAi.class)
|
.put(ApiType.CopySpellAbility, CopySpellAbilityAi.class)
|
||||||
.put(ApiType.ControlPlayer, CannotPlayAi.class)
|
.put(ApiType.ControlPlayer, CannotPlayAi.class)
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
package forge.ai.ability;
|
package forge.ai.ability;
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import forge.ai.SpellAbilityAi;
|
import forge.ai.SpellAbilityAi;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
@@ -36,10 +32,4 @@ public class CanPlayAsDrawbackAi extends SpellAbilityAi {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public SpellAbility chooseSingleSpellAbility(Player player, SpellAbility sa, List<SpellAbility> spells,
|
|
||||||
Map<String, Object> params) {
|
|
||||||
// This might be called from CopySpellAbilityEffect - to hide warning (for having no overload) use this simple overload
|
|
||||||
return spells.get(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ public class CountersProliferateAi extends SpellAbilityAi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean checkApiLogic(Player ai, SpellAbility sa) {
|
protected boolean checkApiLogic(Player ai, SpellAbility sa) {
|
||||||
|
|
||||||
final List<Card> cperms = Lists.newArrayList();
|
final List<Card> cperms = Lists.newArrayList();
|
||||||
final List<Player> allies = ai.getAllies();
|
final List<Player> allies = ai.getAllies();
|
||||||
allies.add(ai);
|
allies.add(ai);
|
||||||
@@ -87,7 +86,6 @@ public class CountersProliferateAi extends SpellAbilityAi {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return !cperms.isEmpty() || !hperms.isEmpty() || opponentPoison || allyExpOrEnergy;
|
return !cperms.isEmpty() || !hperms.isEmpty() || opponentPoison || allyExpOrEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ public class UnattachAllAi extends SpellAbilityAi {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||||
|
|
||||||
// prevent run-away activations - first time will always return true
|
// prevent run-away activations - first time will always return true
|
||||||
boolean chance = MyRandom.getRandom().nextFloat() <= .9;
|
boolean chance = MyRandom.getRandom().nextFloat() <= .9;
|
||||||
|
|
||||||
|
|||||||
@@ -154,8 +154,7 @@ public class CopySpellAbilityEffect extends SpellAbilityEffect {
|
|||||||
copies.add(copy);
|
copies.add(copy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
for (int i = 0; i < amount; i++) {
|
for (int i = 0; i < amount; i++) {
|
||||||
SpellAbility copy = CardFactory.copySpellAbilityAndPossiblyHost(sa, chosenSA, controller);
|
SpellAbility copy = CardFactory.copySpellAbilityAndPossiblyHost(sa, chosenSA, controller);
|
||||||
if (sa.hasParam("MayChooseTarget")) {
|
if (sa.hasParam("MayChooseTarget")) {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package forge.game.ability.effects;
|
package forge.game.ability.effects;
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public class FlipCoinEffect extends SpellAbilityEffect {
|
|||||||
int countHeads = 0;
|
int countHeads = 0;
|
||||||
int countTails = 0;
|
int countTails = 0;
|
||||||
|
|
||||||
for(int i = 0; i < amount; ++i) {
|
for (int i = 0; i < amount; ++i) {
|
||||||
final boolean resultIsHeads = flipCoinNoCall(sa, flipper, flipMultiplier, varName);
|
final boolean resultIsHeads = flipCoinNoCall(sa, flipper, flipMultiplier, varName);
|
||||||
|
|
||||||
if (resultIsHeads) {
|
if (resultIsHeads) {
|
||||||
@@ -118,7 +118,7 @@ public class FlipCoinEffect extends SpellAbilityEffect {
|
|||||||
int countWins = 0;
|
int countWins = 0;
|
||||||
int countLosses = 0;
|
int countLosses = 0;
|
||||||
|
|
||||||
for(int i = 0; i < amount; ++i) {
|
for (int i = 0; i < amount; ++i) {
|
||||||
final boolean win = flipCoinCall(caller.get(0), sa, flipMultiplier, varName);
|
final boolean win = flipCoinCall(caller.get(0), sa, flipMultiplier, varName);
|
||||||
|
|
||||||
if (win) {
|
if (win) {
|
||||||
|
|||||||
@@ -768,8 +768,7 @@ public class Combat {
|
|||||||
if (divideCombatDamageAsChoose) {
|
if (divideCombatDamageAsChoose) {
|
||||||
if (orderedBlockers == null || orderedBlockers.isEmpty()) {
|
if (orderedBlockers == null || orderedBlockers.isEmpty()) {
|
||||||
orderedBlockers = getDefendersCreatures();
|
orderedBlockers = getDefendersCreatures();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
for (Card c : getDefendersCreatures()) {
|
for (Card c : getDefendersCreatures()) {
|
||||||
if (!orderedBlockers.contains(c)) {
|
if (!orderedBlockers.contains(c)) {
|
||||||
orderedBlockers.add(c);
|
orderedBlockers.add(c);
|
||||||
@@ -798,8 +797,7 @@ public class Combat {
|
|||||||
} else if (trampler || !band.isBlocked()) { // this is called after declare blockers, no worries 'bout nulls in isBlocked
|
} else if (trampler || !band.isBlocked()) { // this is called after declare blockers, no worries 'bout nulls in isBlocked
|
||||||
damageMap.put(attacker, defender, damageDealt);
|
damageMap.put(attacker, defender, damageDealt);
|
||||||
} // No damage happens if blocked but no blockers left
|
} // No damage happens if blocked but no blockers left
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Player assigningPlayer = getAttackingPlayer();
|
Player assigningPlayer = getAttackingPlayer();
|
||||||
// Defensive Formation is very similar to Banding with Blockers
|
// Defensive Formation is very similar to Banding with Blockers
|
||||||
// It allows the defending player to assign damage instead of the attacking player
|
// It allows the defending player to assign damage instead of the attacking player
|
||||||
|
|||||||
@@ -3050,7 +3050,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
|
|
||||||
CardCollectionView view = CardCollection.getView(legalCompanions);
|
CardCollectionView view = CardCollection.getView(legalCompanions);
|
||||||
|
|
||||||
SpellAbility fakeSa = new SpellAbility.EmptySa(ApiType.CompanionChoose, legalCompanions.get(0), this);
|
SpellAbility fakeSa = new SpellAbility.EmptySa(ApiType.CompanionChoose, legalCompanions.get(0), this);
|
||||||
return player.chooseSingleEntityForEffect(view, fakeSa, Localizer.getInstance().getMessage("lblChooseACompanion"), true, null);
|
return player.chooseSingleEntityForEffect(view, fakeSa, Localizer.getInstance().getMessage("lblChooseACompanion"), true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user