Updated an AI commander deck, improved damage and life and manaproduce ability to send the correct source card on triggers when they are used inside the "ability$!!$" keyword, fixed issue #1090 about filtering cards with add{c} instead of add{1} ability.

This commit is contained in:
Vittorio Alfieri
2023-05-30 00:08:25 +02:00
parent c17abc3dca
commit 4f4addb8e9
5 changed files with 32 additions and 9 deletions

View File

@@ -1,6 +1,8 @@
#NAME:Draconic Rage
#DESC:The First D&D Deck
#NAME:Vrondiss Commander 2023
#DESC:Forgotten Realms Commander Deck
#DESC:Draconic Rage
#HINT:castpriority(commander,*)
#HINT:alwaysattackwith(creature[Dragon Spirit])
Bogardan Hellkite (*) *1
Demanding Dragon (*) *1
Dragonmaster Outcast (*) *1

View File

@@ -24,7 +24,10 @@ void Damage::init(MTGCardInstance * _source, Damageable * _target, int _damage,
{
typeOfDamage = _typeOfDamage;
target = _target;
source = _source;
if(_source && _source->name.empty() && _source->storedSourceCard) // Fix for damage dealt inside ability$!!$ keyword.
source = _source->storedSourceCard;
else
source = _source;
if (_damage < 0)
_damage = 0; //Negative damages cannot happen

View File

@@ -8064,10 +8064,19 @@ int AManaProducer::resolve()
player->getManaPool()->add(output, source);
if(DoesntEmpty)
player->doesntEmpty->add(output);
source->getProducedMana()->copy(output);
WEventCardManaProduced * ev = NEW WEventCardManaProduced(source);
if(ev)
source->getObserver()->receiveEvent(ev);
if(source->name.empty() && source->storedSourceCard){ // Fix for mana produced inside ability$!!$ keyword.
source->storedSourceCard->getProducedMana()->copy(output);
WEventCardManaProduced * ev = NEW WEventCardManaProduced(source->storedSourceCard);
if(ev)
source->storedSourceCard->getObserver()->receiveEvent(ev);
} else {
source->getProducedMana()->copy(output);
WEventCardManaProduced * ev = NEW WEventCardManaProduced(source);
if(ev)
source->getObserver()->receiveEvent(ev);
}
if(andAbility)
{
MTGAbility * andAbilityClone = andAbility->clone();

View File

@@ -190,7 +190,11 @@ int Player::gainOrLoseLife(int value, MTGCardInstance* source)
}
//Send life event to listeners
WEvent * lifed = NEW WEventLife(this, value, source);
WEvent * lifed = NULL;
if(source && source->name.empty() && source->storedSourceCard) // Fix for life gained inside ability$!!$ keyword.
lifed = NEW WEventLife(this, value, source->storedSourceCard);
else
lifed = NEW WEventLife(this, value, source);
observer->receiveEvent(lifed);
return value;

View File

@@ -340,8 +340,13 @@ bool WCFilterProducesColor::isMatch(MTGCard * c)
while (t != string::npos)
{
s = s.substr(t + 3);
size_t start_pos = 0;
while((start_pos = s.find("{c}", start_pos)) != std::string::npos) {
s.replace(start_pos, 3, "{1}"); // Fix while filtering cards for colorless mana {c} instead of {1} (http://code.google.com/p/wagic/issues/detail?id=1090).
start_pos += 3;
}
ManaCost * mc = ManaCost::parseManaCost(s);
if (mc->hasColor(color) > 0)
if (mc && mc->hasColor(color) > 0)
{
bMatch = true;
SAFE_DELETE(mc);