Fixed primitives, fixed multiple snow mana cost payments, added keywords to count snow mana pool (total and single colors).

This commit is contained in:
Vittorio Alfieri
2021-01-20 18:11:56 +01:00
parent f982124209
commit 0b5f375df6
3 changed files with 72 additions and 104 deletions
+39 -3
View File
@@ -6240,9 +6240,21 @@ int ActivatedAbility::reactToClick(MTGCardInstance * card)
game->mExtraPayment = cost->extraCosts;
return 0;
}
if(cost->extraCosts){ // Added to check if the snow mana amount is enough to pay all the snow cost.
int countSnow = 0;
for(unsigned int i = 0; i < cost->extraCosts->costs.size(); i++){
if(dynamic_cast<SnowCost*> (cost->extraCosts->costs[i]))
countSnow++;
}
if((source->controller()->snowManaG + source->controller()->snowManaU + source->controller()->snowManaR +
source->controller()->snowManaB + source->controller()->snowManaW + source->controller()->snowManaC) < countSnow){
game->mExtraPayment = cost->extraCosts;
return 0;
}
}
ManaCost * previousManaPool = NEW ManaCost(player->getManaPool());
cost->doPayExtra(); // Bring here brefore the normal payment to solve Snow Mana payment bug.
game->currentlyActing()->getManaPool()->pay(cost);
cost->doPayExtra();
SAFE_DELETE(abilityCost);
abilityCost = previousManaPool->Diff(player->getManaPool());
delete previousManaPool;
@@ -6265,9 +6277,21 @@ int ActivatedAbility::reactToTargetClick(Targetable * object)
game->mExtraPayment = cost->extraCosts;
return 0;
}
if(cost->extraCosts){ // Added to check if the snow mana amount is enough to pay all the snow cost.
int countSnow = 0;
for(unsigned int i = 0; i < cost->extraCosts->costs.size(); i++){
if(dynamic_cast<SnowCost*> (cost->extraCosts->costs[i]))
countSnow++;
}
if((source->controller()->snowManaG + source->controller()->snowManaU + source->controller()->snowManaR +
source->controller()->snowManaB + source->controller()->snowManaW + source->controller()->snowManaC) < countSnow){
game->mExtraPayment = cost->extraCosts;
return 0;
}
}
ManaCost * previousManaPool = NEW ManaCost(player->getManaPool());
cost->doPayExtra(); // Bring here brefore the normal payment to solve Snow Mana payment bug.
game->currentlyActing()->getManaPool()->pay(cost);
cost->doPayExtra();
SAFE_DELETE(abilityCost);
abilityCost = previousManaPool->Diff(player->getManaPool());
delete previousManaPool;
@@ -7182,8 +7206,20 @@ int AManaProducer::reactToClick(MTGCardInstance * _card)
game->mExtraPayment = cost->extraCosts;
return 0;
}
if(cost->extraCosts){ // Added to check if the snow mana amount is enough to pay all the snow cost.
int countSnow = 0;
for(unsigned int i = 0; i < cost->extraCosts->costs.size(); i++){
if(dynamic_cast<SnowCost*> (cost->extraCosts->costs[i]))
countSnow++;
}
if((source->controller()->snowManaG + source->controller()->snowManaU + source->controller()->snowManaR +
source->controller()->snowManaB + source->controller()->snowManaW + source->controller()->snowManaC) < countSnow){
game->mExtraPayment = cost->extraCosts;
return 0;
}
}
cost->doPayExtra(); // Bring here brefore the normal payment to solve Snow Mana payment bug.
game->currentlyActing()->getManaPool()->pay(cost);
cost->doPayExtra();
}
if (options[Options::SFXVOLUME].number > 0)
+30 -2
View File
@@ -567,9 +567,37 @@ void WParsedInt::init(string s, Spell * spell, MTGCardInstance * card)
{
intValue = (target->foretellTurn < 0)?0:(target->getObserver()->turn-target->foretellTurn); // Check if you can use the foretell cost from exile (CurrentTurn > ForetellTurn).
}
else if (s == "isflipped" || s == "snowcount") // Return 1 if card has been flipped -- // Snowcount is just to count the number of snow mana produced ... just for debugging purposes...
else if (s == "isflipped") // Return 1 if card has been flipped
{
intValue = (s == "isflipped")?card->isFlipped:target->controller()->snowManaG + target->controller()->snowManaU +target->controller()->snowManaR + target->controller()->snowManaB + target->controller()->snowManaW + target->controller()->snowManaC;
intValue = card->isFlipped;
}
else if (s == "mysnowpoolcount" || s == "opponentsnowpoolcount") // snowpoolcount is just to count the number of snow mana produced ...
{
intValue = (s == "mysnowpoolcount")?(target->controller()->snowManaG + target->controller()->snowManaU + target->controller()->snowManaR + target->controller()->snowManaB + target->controller()->snowManaW + target->controller()->snowManaC):(target->controller()->opponent()->snowManaG + target->controller()->opponent()->snowManaU + target->controller()->opponent()->snowManaR + target->controller()->opponent()->snowManaB + target->controller()->opponent()->snowManaW + target->controller()->opponent()->snowManaC);
}
else if (s == "mysnowgreenpoolcount" || s == "opponentsnowgreenpoolcount")
{
intValue = (s == "mysnowgreenpoolcount")?target->controller()->snowManaG:target->controller()->opponent()->snowManaG;
}
else if (s == "mysnowredpoolcount" || s == "opponentsnowredpoolcount")
{
intValue = (s == "mysnowredpoolcount")?target->controller()->snowManaR:target->controller()->opponent()->snowManaR;
}
else if (s == "mysnowbluepoolcount" || s == "opponentsnowbluepoolcount")
{
intValue = (s == "mysnowbluepoolcount")?target->controller()->snowManaU:target->controller()->opponent()->snowManaU;
}
else if (s == "mysnowwhitepoolcount" || s == "opponentsnowwhitepoolcount")
{
intValue = (s == "mysnowwhitepoolcount")?target->controller()->snowManaW:target->controller()->opponent()->snowManaW;
}
else if (s == "mysnowblackpoolcount" || s == "opponentsnowblackpoolcount")
{
intValue = (s == "mysnowblackpoolcount")?target->controller()->snowManaB:target->controller()->opponent()->snowManaB;
}
else if (s == "mysnowcolorlesspoolcount" || s == "opponentsnowcolorlesspoolcount")
{
intValue = (s == "mysnowcolorlesspoolcount")?target->controller()->snowManaC:target->controller()->opponent()->snowManaC;
}
else if (s == "mypoolcount" || s == "opponentpoolcount") // total manapool
{