Improve payment test on hybrid shards (#2562)

* Improve payment test on hybrid shards

* Clean up

---------

Co-authored-by: tool4EvEr <tool4EvEr@192.168.0.59>
This commit is contained in:
tool4ever
2023-02-25 13:53:05 +01:00
committed by GitHub
parent eab63b52bd
commit 6c168b1a4a
4 changed files with 11 additions and 12 deletions

View File

@@ -688,10 +688,6 @@ public class ComputerUtilMana {
ListMultimap<ManaCostShard, SpellAbility> sourcesForShards = getSourcesForShards(cost, sa, ai, test,
checkPlayable, manaSpentToPay, hasConverge, ignoreColor, ignoreType);
if (sourcesForShards == null && !purePhyrexian) {
return false; // no mana abilities to use for paying
}
int testEnergyPool = ai.getCounters(CounterEnumType.ENERGY);
final ManaPool manapool = ai.getManaPool();
ManaCostShard toPay = null;
@@ -712,7 +708,7 @@ public class ComputerUtilMana {
manapool.applyCardMatrix(pay);
for (byte color : ManaAtom.MANATYPES) {
if (manapool.tryPayCostWithColor(color, sa, cost)) {
if (manapool.tryPayCostWithColor(color, sa, cost, manaSpentToPay)) {
found = true;
break;
}
@@ -724,6 +720,11 @@ public class ComputerUtilMana {
if (cost.isPaid()) {
break;
}
if (sourcesForShards == null && !purePhyrexian) {
return false; // no mana abilities to use for paying
}
toPay = getNextShardToPay(cost);
boolean lifeInsteadOfBlack = toPay.isBlack() && ai.hasKeyword("PayLifeInsteadOf:B");

View File

@@ -212,7 +212,7 @@ public class ManaPool extends ManaConversionMatrix implements Iterable<Mana> {
}
}
public boolean tryPayCostWithColor(byte colorCode, SpellAbility saPaidFor, ManaCostBeingPaid manaCost) {
public boolean tryPayCostWithColor(byte colorCode, SpellAbility saPaidFor, ManaCostBeingPaid manaCost, List<Mana> manaSpentToPay) {
Mana manaFound = null;
String restriction = manaCost.getSourceRestriction();
Collection<Mana> cm = floatingMana.get(colorCode);
@@ -231,7 +231,7 @@ public class ManaPool extends ManaConversionMatrix implements Iterable<Mana> {
}
if (manaFound != null && tryPayCostWithMana(saPaidFor, manaCost, manaFound, false)) {
saPaidFor.getPayingMana().add(0, manaFound);
manaSpentToPay.add(0, manaFound);
return true;
}
return false;

View File

@@ -5,10 +5,8 @@ PT:3/4
K:Vigilance
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigExile | TriggerDescription$ When CARDNAME enters the battlefield or attacks, exile a card from a graveyard.
T:Mode$ Attacks | ValidCard$ Card.Self | Execute$ TrigExile | Secondary$ True | TriggerDescription$ Whenever CARDNAME enters the battlefield or attacks, exile a card from a graveyard.
SVar:TrigExile:DB$ ChangeZone | Origin$ Graveyard | Destination$ Exile | ChangeType$ Card | ChangeNum$ 1 | SelectPrompt$ Select a card from a graveyard | Mandatory$ True | Hidden$ True | Imprint$ True | AILogic$ ExilePreference:MostProminentNonLandNonExiledOwnType
SVar:TrigExile:DB$ ChangeZone | Origin$ Graveyard | Destination$ Exile | ChangeType$ Card | ChangeNum$ 1 | SelectPrompt$ Select a card from a graveyard | Mandatory$ True | Hidden$ True | AILogic$ ExilePreference:MostProminentNonLandNonExiledOwnType
S:Mode$ ReduceCost | ValidCard$ Card | Type$ Spell | Amount$ AffectedX | Activator$ You | Description$ Spells you cast cost {1} less to cast for each card type they share with cards exiled with CARDNAME.
SVar:AffectedX:Count$TypesSharedWith Imprinted.ExiledWithSource
T:Mode$ ChangesZone | Origin$ Battlefield | ValidCard$ Card.Self | Destination$ Any | Execute$ DBCleanup | Static$ True
SVar:DBCleanup:DB$ Cleanup | ClearImprinted$ True
SVar:AffectedX:Count$TypesSharedWith Card.ExiledWithSource
DeckHints:Ability$Graveyard|Discard
Oracle:Vigilance\nWhenever Cemetery Prowler enters the battlefield or attacks, exile a card from a graveyard.\nSpells you cast cost {1} less to cast for each card type they share with cards exiled with Cemetery Prowler.

View File

@@ -201,7 +201,7 @@ public abstract class InputPayMana extends InputSyncronizedBase {
public void useManaFromPool(byte colorCode) {
// find the matching mana in pool.
if (player.getManaPool().tryPayCostWithColor(colorCode, saPaidFor, manaCost)) {
if (player.getManaPool().tryPayCostWithColor(colorCode, saPaidFor, manaCost, saPaidFor.getPayingMana())) {
onManaAbilityPaid();
showMessage();
}