mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
- Some preparations for triggered counter abilities with defined controlled by the AI.
This commit is contained in:
@@ -3,7 +3,7 @@ ManaCost:3 B
|
||||
Types:World Enchantment
|
||||
Text:no text
|
||||
T:Mode$ SpellCast | ValidCard$ Card | ValidActivatingPlayer$ Each | TriggerZones$ Battlefield | Execute$ TrigCounter | TriggerDescription$ Whenever a player casts a spell, counter it unless its controller pays 3.
|
||||
SVar:TrigCounter:AB$Counter | Cost$ 0 | UnlessCost$ 3 | Defined$ TriggeredSpellAbility | UnlessPayer$ TriggeredCardController
|
||||
SVar:TrigCounter:DB$Counter | Cost$ 0 | UnlessCost$ 3 | Defined$ TriggeredSpellAbility | UnlessPayer$ TriggeredCardController
|
||||
SVar:RemRandomDeck:True
|
||||
SVar:Rarity:Rare
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/nether_void.jpg
|
||||
|
||||
@@ -25,7 +25,6 @@ import forge.card.spellability.Target_Selection;
|
||||
// -Hand
|
||||
// -BottomOfLibrary
|
||||
// -ShuffleIntoLibrary
|
||||
//UnlessCost - counter target spell unless it's controller pays this cost
|
||||
//PowerSink - true if the drawback type part of Power Sink should be used
|
||||
//ExtraActions - this has been removed. All SubAbilitys should now use the standard SubAbility system
|
||||
|
||||
@@ -161,16 +160,20 @@ public class AbilityFactory_CounterMagic {
|
||||
}
|
||||
}
|
||||
|
||||
SpellAbility topSA = AllZone.Stack.peek();
|
||||
if (!CardFactoryUtil.isCounterable(topSA.getSourceCard()) || topSA.getActivatingPlayer().isComputer())
|
||||
return false;
|
||||
|
||||
Target tgt = sa.getTarget();
|
||||
tgt.resetTargets();
|
||||
if (Target_Selection.matchSpellAbility(sa, topSA, tgt))
|
||||
tgt.addTarget(topSA);
|
||||
else
|
||||
return false;
|
||||
if (tgt != null) {
|
||||
|
||||
SpellAbility topSA = AllZone.Stack.peek();
|
||||
if (!CardFactoryUtil.isCounterable(topSA.getSourceCard()) || topSA.getActivatingPlayer().isComputer())
|
||||
return false;
|
||||
|
||||
tgt.resetTargets();
|
||||
if (Target_Selection.matchSpellAbility(sa, topSA, tgt))
|
||||
tgt.addTarget(topSA);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (unlessCost != null){
|
||||
// Is this Usable Mana Sources? Or Total Available Mana?
|
||||
@@ -215,43 +218,44 @@ public class AbilityFactory_CounterMagic {
|
||||
if(AllZone.Stack.size() < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SpellAbility topSA = AllZone.Stack.peek();
|
||||
if (!CardFactoryUtil.isCounterable(topSA.getSourceCard()) || topSA.getActivatingPlayer().isComputer())
|
||||
return false;
|
||||
|
||||
|
||||
Target tgt = sa.getTarget();
|
||||
tgt.resetTargets();
|
||||
if (Target_Selection.matchSpellAbility(sa, topSA, tgt))
|
||||
tgt.addTarget(topSA);
|
||||
|
||||
else
|
||||
return false;
|
||||
|
||||
Card source = sa.getSourceCard();
|
||||
if (unlessCost != null){
|
||||
// Is this Usable Mana Sources? Or Total Available Mana?
|
||||
int usableManaSources = CardFactoryUtil.getUsableManaSources(AllZone.HumanPlayer);
|
||||
int toPay = 0;
|
||||
boolean setPayX = false;
|
||||
if (unlessCost.equals("X") && source.getSVar(unlessCost).equals("Count$xPaid")){
|
||||
setPayX = true;
|
||||
toPay = ComputerUtil.determineLeftoverMana(sa);
|
||||
}
|
||||
else
|
||||
toPay = AbilityFactory.calculateAmount(source, unlessCost, sa);
|
||||
|
||||
if (toPay == 0)
|
||||
if (tgt != null) {
|
||||
SpellAbility topSA = AllZone.Stack.peek();
|
||||
if (!CardFactoryUtil.isCounterable(topSA.getSourceCard()) || topSA.getActivatingPlayer().isComputer())
|
||||
return false;
|
||||
|
||||
if (toPay <= usableManaSources){
|
||||
// If this is a reusable Resource, feel free to play it most of the time
|
||||
if (!sa.getPayCosts().isReusuableResource() || MyRandom.random.nextFloat() < .4)
|
||||
|
||||
tgt.resetTargets();
|
||||
if (Target_Selection.matchSpellAbility(sa, topSA, tgt))
|
||||
tgt.addTarget(topSA);
|
||||
else
|
||||
return false;
|
||||
|
||||
Card source = sa.getSourceCard();
|
||||
if (unlessCost != null){
|
||||
// Is this Usable Mana Sources? Or Total Available Mana?
|
||||
int usableManaSources = CardFactoryUtil.getUsableManaSources(AllZone.HumanPlayer);
|
||||
int toPay = 0;
|
||||
boolean setPayX = false;
|
||||
if (unlessCost.equals("X") && source.getSVar(unlessCost).equals("Count$xPaid")){
|
||||
setPayX = true;
|
||||
toPay = ComputerUtil.determineLeftoverMana(sa);
|
||||
}
|
||||
else
|
||||
toPay = AbilityFactory.calculateAmount(source, unlessCost, sa);
|
||||
|
||||
if (toPay == 0)
|
||||
return false;
|
||||
|
||||
if (toPay <= usableManaSources){
|
||||
// If this is a reusable Resource, feel free to play it most of the time
|
||||
if (!sa.getPayCosts().isReusuableResource() || MyRandom.random.nextFloat() < .4)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (setPayX)
|
||||
source.setSVar("PayX", Integer.toString(toPay));
|
||||
}
|
||||
|
||||
if (setPayX)
|
||||
source.setSVar("PayX", Integer.toString(toPay));
|
||||
}
|
||||
|
||||
// TODO: Improve AI
|
||||
|
||||
@@ -2518,7 +2518,7 @@ public class CardFactoryUtil {
|
||||
|
||||
// Count$TopOfLibraryCMC
|
||||
if(sq[0].contains("TopOfLibraryCMC")) {
|
||||
CardList topcard = AllZoneUtil.getPlayerCardsInLibrary(AllZone.HumanPlayer, 1);
|
||||
CardList topcard = AllZoneUtil.getPlayerCardsInLibrary(cardController, 1);
|
||||
return doXMath(topcard.getTotalConvertedManaCost(), m, c);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user