mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Clean up
This commit is contained in:
@@ -572,8 +572,7 @@ public class AiAttackController {
|
|||||||
if (numExtraBlocks > 0) {
|
if (numExtraBlocks > 0) {
|
||||||
// TODO should be limited to how much getBlockCost the opp can pay
|
// TODO should be limited to how much getBlockCost the opp can pay
|
||||||
while (numExtraBlocks-- > 0 && !remainingAttackers.isEmpty()) {
|
while (numExtraBlocks-- > 0 && !remainingAttackers.isEmpty()) {
|
||||||
blockedAttackers.add(remainingAttackers.get(0));
|
blockedAttackers.add(remainingAttackers.remove(0));
|
||||||
remainingAttackers.remove(0);
|
|
||||||
maxBlockersAfterCrew--;
|
maxBlockersAfterCrew--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -581,8 +580,7 @@ public class AiAttackController {
|
|||||||
if (remainingAttackers.isEmpty()) {
|
if (remainingAttackers.isEmpty()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
blockedAttackers.add(remainingAttackers.get(0));
|
blockedAttackers.add(remainingAttackers.remove(0));
|
||||||
remainingAttackers.remove(0);
|
|
||||||
maxBlockersAfterCrew--;
|
maxBlockersAfterCrew--;
|
||||||
}
|
}
|
||||||
unblockedAttackers.addAll(remainingAttackers);
|
unblockedAttackers.addAll(remainingAttackers);
|
||||||
@@ -605,8 +603,8 @@ public class AiAttackController {
|
|||||||
final CardCollection unblockableCantPayFor = new CardCollection();
|
final CardCollection unblockableCantPayFor = new CardCollection();
|
||||||
final CardCollection unblockableWithoutCost = new CardCollection();
|
final CardCollection unblockableWithoutCost = new CardCollection();
|
||||||
// TODO also check poison
|
// TODO also check poison
|
||||||
for (Card attacker : CardLists.getKeyword(unblockedAttackers, Keyword.TRAMPLE)) {
|
for (Card attacker : unblockedAttackers) {
|
||||||
Cost tax = CombatUtil.getAttackCost(attacker.getGame(), attacker, defendingOpponent);
|
Cost tax = CombatUtil.getAttackCost(ai.getGame(), attacker, defendingOpponent);
|
||||||
if (tax == null) {
|
if (tax == null) {
|
||||||
unblockableWithoutCost.add(attacker);
|
unblockableWithoutCost.add(attacker);
|
||||||
} else {
|
} else {
|
||||||
@@ -620,19 +618,17 @@ public class AiAttackController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
int dmgUnblockableAfterPaying = ComputerUtilCombat.sumDamageIfUnblocked(unblockableWithPaying, defendingOpponent);
|
int dmgUnblockableAfterPaying = ComputerUtilCombat.sumDamageIfUnblocked(unblockableWithPaying, defendingOpponent);
|
||||||
|
unblockedAttackers = unblockableWithoutCost;
|
||||||
if (dmgUnblockableAfterPaying > trampleDamage) {
|
if (dmgUnblockableAfterPaying > trampleDamage) {
|
||||||
unblockedAttackers.removeAll(unblockableCantPayFor);
|
myFreeMana -= unblockableAttackTax;
|
||||||
unblockedAttackers.removeAll(unblockableWithPaying);
|
|
||||||
totalCombatDamage = dmgUnblockableAfterPaying;
|
totalCombatDamage = dmgUnblockableAfterPaying;
|
||||||
// recalculate the trampler damage with the reduced mana available now
|
// recalculate the trampler damage with the reduced mana available now
|
||||||
myFreeMana -= unblockableAttackTax;
|
|
||||||
trampleDamage = getDamageFromBlockingTramplers(blockedAttackers, remainingBlockers, myFreeMana).getLeft();
|
trampleDamage = getDamageFromBlockingTramplers(blockedAttackers, remainingBlockers, myFreeMana).getLeft();
|
||||||
} else {
|
} else {
|
||||||
unblockedAttackers = unblockableWithoutCost;
|
|
||||||
myFreeMana -= tramplerTaxPaid;
|
myFreeMana -= tramplerTaxPaid;
|
||||||
// find out if we can still pay for some left
|
// find out if we can still pay for some left
|
||||||
for (Card attacker : unblockableWithPaying) {
|
for (Card attacker : unblockableWithPaying) {
|
||||||
Cost tax = CombatUtil.getAttackCost(attacker.getGame(), attacker, defendingOpponent);
|
Cost tax = CombatUtil.getAttackCost(ai.getGame(), attacker, defendingOpponent);
|
||||||
int taxCMC = tax.getCostMana().getMana().getCMC();
|
int taxCMC = tax.getCostMana().getMana().getCMC();
|
||||||
if (myFreeMana < unblockableAttackTax + taxCMC) {
|
if (myFreeMana < unblockableAttackTax + taxCMC) {
|
||||||
continue;
|
continue;
|
||||||
@@ -664,7 +660,7 @@ public class AiAttackController {
|
|||||||
CardCollection remainingBlockers = new CardCollection(blockers);
|
CardCollection remainingBlockers = new CardCollection(blockers);
|
||||||
for (Card attacker : CardLists.getKeyword(blockedAttackers, Keyword.TRAMPLE)) {
|
for (Card attacker : CardLists.getKeyword(blockedAttackers, Keyword.TRAMPLE)) {
|
||||||
// TODO might sort by quotient of dmg/cost for best combination
|
// TODO might sort by quotient of dmg/cost for best combination
|
||||||
Cost tax = CombatUtil.getAttackCost(attacker.getGame(), attacker, defendingOpponent);
|
Cost tax = CombatUtil.getAttackCost(ai.getGame(), attacker, defendingOpponent);
|
||||||
int taxCMC = tax != null ? tax.getCostMana().getMana().getCMC() : 0;
|
int taxCMC = tax != null ? tax.getCostMana().getMana().getCMC() : 0;
|
||||||
if (myFreeMana < currentAttackTax + taxCMC) {
|
if (myFreeMana < currentAttackTax + taxCMC) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -1268,21 +1268,17 @@ public class ComputerUtilCombat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Card> list = Lists.newArrayList();
|
List<Card> list = Lists.newArrayList();
|
||||||
if (!sa.hasParam("ValidCards")) {
|
|
||||||
list = AbilityUtils.getDefinedCards(source, sa.getParam("Defined"), null);
|
|
||||||
}
|
|
||||||
if (sa.hasParam("Defined") && sa.getParam("Defined").startsWith("TriggeredAttacker")) {
|
|
||||||
list.add(attacker);
|
|
||||||
}
|
|
||||||
if (sa.hasParam("ValidCards")) {
|
if (sa.hasParam("ValidCards")) {
|
||||||
if (attacker.isValid(sa.getParam("ValidCards").split(","), source.getController(), source, null)
|
if (attacker.isValid(sa.getParam("ValidCards").split(","), source.getController(), source, null)
|
||||||
|| attacker.isValid(sa.getParam("ValidCards").replace("attacking+", "").split(","),
|
|| attacker.isValid(sa.getParam("ValidCards").replace("attacking+", "").split(","),
|
||||||
source.getController(), source, null)) {
|
source.getController(), source, null)) {
|
||||||
list.add(attacker);
|
list.add(attacker);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
list = AbilityUtils.getDefinedCards(source, sa.getParam("Defined"), null);
|
||||||
}
|
}
|
||||||
if (list.isEmpty()) {
|
if (sa.hasParam("Defined") && sa.getParam("Defined").startsWith("TriggeredAttacker")) {
|
||||||
continue;
|
list.add(attacker);
|
||||||
}
|
}
|
||||||
if (!list.contains(attacker)) {
|
if (!list.contains(attacker)) {
|
||||||
continue;
|
continue;
|
||||||
@@ -1464,14 +1460,15 @@ public class ComputerUtilCombat {
|
|||||||
toughness -= predictDamageTo(attacker, damage, source, false);
|
toughness -= predictDamageTo(attacker, damage, source, false);
|
||||||
continue;
|
continue;
|
||||||
} else if (ApiType.Pump.equals(sa.getApi())) {
|
} else if (ApiType.Pump.equals(sa.getApi())) {
|
||||||
|
if (!sa.hasParam("NumDef")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (sa.hasParam("Cost")) {
|
if (sa.hasParam("Cost")) {
|
||||||
if (!CostPayment.canPayAdditionalCosts(sa.getPayCosts(), sa)) {
|
if (!CostPayment.canPayAdditionalCosts(sa.getPayCosts(), sa)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!sa.hasParam("NumDef")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
final String defined = sa.getParam("Defined");
|
final String defined = sa.getParam("Defined");
|
||||||
CardCollection list = AbilityUtils.getDefinedCards(source, defined, sa);
|
CardCollection list = AbilityUtils.getDefinedCards(source, defined, sa);
|
||||||
if (defined != null && defined.startsWith("TriggeredAttacker")) {
|
if (defined != null && defined.startsWith("TriggeredAttacker")) {
|
||||||
@@ -1497,6 +1494,9 @@ public class ComputerUtilCombat {
|
|||||||
toughness += AbilityUtils.calculateAmount(source, bonus, sa);
|
toughness += AbilityUtils.calculateAmount(source, bonus, sa);
|
||||||
}
|
}
|
||||||
} else if (ApiType.PumpAll.equals(sa.getApi())) {
|
} else if (ApiType.PumpAll.equals(sa.getApi())) {
|
||||||
|
if (!sa.hasParam("NumDef")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (sa.hasParam("Cost")) {
|
if (sa.hasParam("Cost")) {
|
||||||
if (!CostPayment.canPayAdditionalCosts(sa.getPayCosts(), sa)) {
|
if (!CostPayment.canPayAdditionalCosts(sa.getPayCosts(), sa)) {
|
||||||
continue;
|
continue;
|
||||||
@@ -1506,9 +1506,6 @@ public class ComputerUtilCombat {
|
|||||||
if (!sa.hasParam("ValidCards")) {
|
if (!sa.hasParam("ValidCards")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!sa.hasParam("NumDef")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!attacker.isValid(sa.getParam("ValidCards").replace("attacking+", "").split(","), source.getController(), source, sa)) {
|
if (!attacker.isValid(sa.getParam("ValidCards").replace("attacking+", "").split(","), source.getController(), source, sa)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -724,7 +724,7 @@ public class ComputerUtilCost {
|
|||||||
|
|
||||||
// ward or human misplay
|
// ward or human misplay
|
||||||
if (ApiType.Counter.equals(sa.getApi())) {
|
if (ApiType.Counter.equals(sa.getApi())) {
|
||||||
List<SpellAbility> spells = AbilityUtils.getDefinedSpellAbilities(source, sa.hasParam("Defined") ? sa.getParam("Defined") : "Targeted", sa);
|
List<SpellAbility> spells = AbilityUtils.getDefinedSpellAbilities(source, sa.getParamOrDefault("Defined", "Targeted"), sa);
|
||||||
for (SpellAbility toBeCountered : spells) {
|
for (SpellAbility toBeCountered : spells) {
|
||||||
if (!CardFactoryUtil.isCounterable(toBeCountered.getHostCard())) {
|
if (!CardFactoryUtil.isCounterable(toBeCountered.getHostCard())) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user