Fixed several primitives, added a new Commander Deck for AI, Fixed an issue on "blink" return ability (e.g. "Otherworldly Journey"), improved "exerted" trigger adding "turnlimited" option, added a new keyword "losesatype" to remove a specific type from a card (e.g. "Conversion"), improved "vanishing", "fading" and "bloodthirst" keywords in order to allow the usage of variables (e.g. "Tidewalker"), added new triggers "poisonedof" and "poisonedfoeof" to handle the event when a player gets a poison counter, added new keywords "countershroud" to avoid a card can get any kind of counter, added new keywords "expshroud" and "energyshroud" to avoid a player can get one of those counters, added new option "uent" for "transforms" keyword ability to allow transformation effects end at the end of your next turn, fixed an issue on "swap" keyword when a non-creature card is firstly transformed into a creature (e.g. "Wandering Fumarole").

This commit is contained in:
Vittorio Alfieri
2021-12-18 13:45:58 +01:00
parent 8551f55636
commit 7fa03e620d
15 changed files with 655 additions and 332 deletions
+50 -26
View File
@@ -1037,8 +1037,16 @@ int AAAlterPoison::resolve()
if (_target)
{
Player * pTarget = (Player*)_target;
if(!pTarget->inPlay()->hasAbility(Constants::POISONSHROUD) || poison < 0)
if(!pTarget->inPlay()->hasAbility(Constants::POISONSHROUD) || poison < 0){
_target->poisonCount += poison;
if(pTarget->poisonCount < 0)
pTarget->poisonCount = 0;
if(poison > 0)
{
WEvent * e = NEW WEventplayerPoisoned(pTarget, poison); // Added an event when player receives any poison counter.
game->receiveEvent(e);
}//todo loses poison event
}
}
return 0;
}
@@ -1377,14 +1385,16 @@ int AAAlterEnergy::resolve()
Player * pTarget = (Player*)_target;
if(pTarget)
{
pTarget->energyCount += energy;
if(pTarget->energyCount < 0)
pTarget->energyCount = 0;
if(energy > 0)
{
WEvent * e = NEW WEventplayerEnergized(pTarget, energy);
game->receiveEvent(e);
}//todo loses enegy event
if(!pTarget->inPlay()->hasAbility(Constants::ENERGYSHROUD) || energy < 0){
pTarget->energyCount += energy;
if(pTarget->energyCount < 0)
pTarget->energyCount = 0;
if(energy > 0)
{
WEvent * e = NEW WEventplayerEnergized(pTarget, energy);
game->receiveEvent(e);
}//todo loses enegy event
}
}
}
return 0;
@@ -1420,14 +1430,16 @@ int AAAlterExperience::resolve()
Player * pTarget = (Player*)_target;
if(pTarget)
{
pTarget->experienceCount += experience;
if(pTarget->experienceCount < 0)
pTarget->experienceCount = 0;
if(experience > 0)
{
WEvent * e = NEW WEventplayerExperienced(pTarget, experience);
game->receiveEvent(e);
}//todo loses experience event
if(!pTarget->inPlay()->hasAbility(Constants::EXPSHROUD) || experience < 0){
pTarget->experienceCount += experience;
if(pTarget->experienceCount < 0)
pTarget->experienceCount = 0;
if(experience > 0)
{
WEvent * e = NEW WEventplayerExperienced(pTarget, experience);
game->receiveEvent(e);
}//todo loses experience event
}
}
}
return 0;
@@ -2551,6 +2563,9 @@ AACounter::AACounter(GameObserver* observer, int id, MTGCardInstance * source, M
}
if (nb > 0)
{
if(_target->has(Constants::COUNTERSHROUD)) // Added to avoid the counter increasement (e.g. "Solemnity").
return 0;
for (int i = 0; i < nb; i++)
{
while (_target->next)
@@ -7533,8 +7548,8 @@ AAlterCost::~AAlterCost()
}
// ATransformer
ATransformer::ATransformer(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound,vector<string> newAbilitiesList,bool newAbilityFound,bool aForever, bool aUntilNext,string _menu) :
MTGAbility(observer, id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound),newAbilitiesList(newAbilitiesList),newAbilityFound(newAbilityFound),aForever(aForever),UYNT(aUntilNext),menutext(_menu)
ATransformer::ATransformer(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound,vector<string> newAbilitiesList,bool newAbilityFound,bool aForever,bool aUntilNext,bool aUntilEndNext,string _menu) :
MTGAbility(observer, id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound),newAbilitiesList(newAbilitiesList),newAbilityFound(newAbilityFound),aForever(aForever),UYNT(aUntilNext),UENT(aUntilEndNext),menutext(_menu)
{
if (target != source) {
@@ -7576,7 +7591,7 @@ ATransformer::ATransformer(GameObserver* observer, int id, MTGCardInstance * sou
int ATransformer::addToGame()
{
if(UYNT)
if(UYNT || UENT)
myCurrentTurn = game->turn;
MTGCardInstance * _target = NULL;
Interruptible * action = (Interruptible *) target;
@@ -7784,6 +7799,12 @@ int ATransformer::addToGame()
if(myCurrentTurn != 1000 && game->turn > myCurrentTurn && source->controller()->getId() == game->currentPlayer->getId())
return 1;
return 0; // Fixed an issue when the transformation with uynt is triggered by instant/sorcery or by card that left the battlefield before the ability ending turn.
}
else if(UENT)
{
if(myCurrentTurn != 1000 && game->turn > (myCurrentTurn + 1) && source->controller()->getId() != game->currentPlayer->getId())
return 1;
return 0; // Fixed an issue when the transformation with uent is triggered by instant/sorcery or by card that left the battlefield before the ability ending turn.
}
return MTGAbility::testDestroy();
}
@@ -7896,10 +7917,10 @@ ATransformer::~ATransformer()
}
//ATransformerInstant
ATransformerInstant::ATransformerInstant(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound,vector<string>newAbilitiesList,bool newAbilityFound,bool aForever,bool aUntilNext,string _menu) :
InstantAbility(observer, id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound),newAbilitiesList(newAbilitiesList),newAbilityFound(newAbilityFound),aForever(aForever),UYNT(aUntilNext),menu(_menu)
ATransformerInstant::ATransformerInstant(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound,vector<string>newAbilitiesList,bool newAbilityFound,bool aForever,bool aUntilNext,bool aUntilEndNext,string _menu) :
InstantAbility(observer, id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound),newAbilitiesList(newAbilitiesList),newAbilityFound(newAbilityFound),aForever(aForever),UYNT(aUntilNext),UENT(aUntilEndNext),menu(_menu)
{
ability = NEW ATransformer(game, id, source, target, types, abilities,newpower,newpowerfound,newtoughness,newtoughnessfound,newAbilitiesList,newAbilityFound,aForever,aUntilNext,_menu);
ability = NEW ATransformer(game, id, source, target, types, abilities,newpower,newpowerfound,newtoughness,newtoughnessfound,newAbilitiesList,newAbilityFound,aForever,aUntilNext,aUntilEndNext,_menu);
aType = MTGAbility::STANDARD_BECOMES;
}
@@ -8163,8 +8184,8 @@ ALoseAbilities * ALoseAbilities::clone() const
}
//ALoseSubtypes
ALoseSubtypes::ALoseSubtypes(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * _target, int parentType) :
MTGAbility(observer, id, source), parentType(parentType)
ALoseSubtypes::ALoseSubtypes(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * _target, int parentType, bool specificType) :
MTGAbility(observer, id, source), parentType(parentType), specificType(specificType)
{
target = _target;
}
@@ -8181,7 +8202,7 @@ int ALoseSubtypes::addToGame()
for (int i = ((int)_target->types.size())-1; i >= 0; --i)
{
int subtype = _target->types[i];
if (MTGAllCards::isSubtypeOfType(subtype, parentType))
if ((!specificType && MTGAllCards::isSubtypeOfType(subtype, parentType)) || (specificType && subtype == parentType)) // added to remove a specific type (e.g. "Conversion").
{
storedSubtypes.push_back(subtype);
_target->removeType(subtype);
@@ -9328,7 +9349,10 @@ void ABlink::returnCardIntoPlay(MTGCardInstance* _target) {
spell->source->toughness = spell->source->origtoughness;
spell->source->X = 0;
if (!spell->source->hasSubtype(Subtypes::TYPE_AURA)) {
MTGGameZone* prev = spell->source->previousZone; // Save the previous zone of card before spell resolution.
spell->resolve();
if(prev && spell->source->currentZone == spell->source->previousZone)
spell->source->previousZone = prev; // Fixed issue on previous zone (e.g. "Otherworldly Journey").
if (stored)
{
MTGAbility * clonedStored = stored->clone();
+14 -5
View File
@@ -189,8 +189,14 @@ int Damage::resolve()
{
// Poison on player
Player * _target = (Player *) target;
if(!_target->inPlay()->hasAbility(Constants::POISONSHROUD))
if(!_target->inPlay()->hasAbility(Constants::POISONSHROUD)){
_target->poisonCount += damage;//this will be changed to poison counters.
if(damage > 0)
{
WEvent * e = NEW WEventplayerPoisoned(_target, damage); // Added an event when player receives any poison counter.
_target->getObserver()->receiveEvent(e);
}
}
_target->damageCount += damage;
if(typeOfDamage == 2)
_target->nonCombatDamage += damage;
@@ -225,20 +231,23 @@ int Damage::resolve()
}
if(!_target->inPlay()->hasAbility(Constants::POISONSHROUD))
{
int poison = 0;
if (source->has(Constants::POISONTOXIC))
{
_target->poisonCount += 1;
poison = 1;
}
else if (source->has(Constants::POISONTWOTOXIC))
{
_target->poisonCount += 2;
poison = 2;
}
else
{
_target->poisonCount += 3;
poison = 3;
}
_target->poisonCount += poison;
WEvent * e = NEW WEventplayerPoisoned(_target, damage); // Added an event when player receives any poison counter.
_target->getObserver()->receiveEvent(e);
}
}
else
{
+37 -11
View File
@@ -1188,7 +1188,7 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string, int id, Spell
//Card Exerted
if (TargetChooser *tc = parseSimpleTC(s,"exerted", card))
return NEW TrCardExerted(observer, id, card, tc, once);
return NEW TrCardExerted(observer, id, card, tc, once, limitOnceATurn);
//CombatTrigger
//Card card attacked and is blocked
@@ -1228,6 +1228,14 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string, int id, Spell
attackingTrigger, attackedAloneTrigger, notBlockedTrigger, attackBlockedTrigger, blockingTrigger);
}
//poisoned player - controller of card
if (TargetChooser * tc = parseSimpleTC(s, "poisonedof", card))
return NEW TrplayerPoisoned(observer, id, card, tc, once, true, false);
//poisoned player - opponent of card controller
if (TargetChooser * tc = parseSimpleTC(s, "poisonedfoeof", card))
return NEW TrplayerPoisoned(observer, id, card, tc, once, false, true);
//energized player - controller of card
if (TargetChooser * tc = parseSimpleTC(s, "energizedof", card))
return NEW TrplayerEnergized(observer, id, card, tc, once, true, false);
@@ -3723,6 +3731,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
bool oneShot = false;
bool forceForever = false;
bool untilYourNextTurn = false;
bool untilYourNextEndTurn = false;
found = s.find("ueot");
if (found != string::npos)
forceUEOT = true;
@@ -3735,6 +3744,9 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
found = s.find("uynt");
if (found != string::npos)
untilYourNextTurn = true;
found = s.find("uent");
if (found != string::npos)
untilYourNextEndTurn = true;
//Prevent Damage
const string preventDamageKeywords[] = { "preventallcombatdamage", "preventallnoncombatdamage", "preventalldamage", "fog" };
const int preventDamageTypes[] = {0, 2, 1, 0}; //TODO enum ?
@@ -4147,7 +4159,15 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
if (splitLoseTypes.size())
{
int parentType = MTGAllCards::findType(splitLoseTypes[1]);
return NEW ALoseSubtypes(observer, id, card, target, parentType);
return NEW ALoseSubtypes(observer, id, card, target, parentType, false);
}
//Lose a specific type (e.g. "Conversion").
vector<string> splitLoseSpecType = parseBetween(s, "losesatype(", ")");
if (splitLoseSpecType.size())
{
int typeToLose = MTGAllCards::findType(splitLoseSpecType[1]);
return NEW ALoseSubtypes(observer, id, card, target, typeToLose, true);
}
//Cast/Play Restrictions
@@ -4448,9 +4468,9 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
}
}
if (oneShot || forceUEOT || forceForever)
return NEW ATransformerInstant(observer, id, card, target, stypes, sabilities,newPower,ptFound,newToughness,ptFound,vector<string>(),false,forceForever,untilYourNextTurn);
return NEW ATransformerInstant(observer, id, card, target, stypes, sabilities,newPower,ptFound,newToughness,ptFound,vector<string>(),false,forceForever,untilYourNextTurn,untilYourNextEndTurn);
return NEW ATransformer(observer, id, card, target, stypes, sabilities,newPower,ptFound,newToughness,ptFound,vector<string>(),false,forceForever,untilYourNextTurn);
return NEW ATransformer(observer, id, card, target, stypes, sabilities,newPower,ptFound,newToughness,ptFound,vector<string>(),false,forceForever,untilYourNextTurn,untilYourNextEndTurn);
}
//Remake... (animate artifact...: Remake(Creature: manacost/manacost) - alternative
@@ -4484,30 +4504,36 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
}
}
if (oneShot || forceUEOT || forceForever)
return NEW ATransformerInstant(observer, id, card, target, stypes, sabilities,newPower,ptFound,newToughness,ptFound,vector<string>(),false,forceForever,untilYourNextTurn);
return NEW ATransformerInstant(observer, id, card, target, stypes, sabilities,newPower,ptFound,newToughness,ptFound,vector<string>(),false,forceForever,untilYourNextTurn,untilYourNextEndTurn);
return NEW ATransformer(observer, id, card, target, stypes, sabilities,newPower,ptFound,newToughness,ptFound,vector<string>(),false,forceForever,untilYourNextTurn);
return NEW ATransformer(observer, id, card, target, stypes, sabilities,newPower,ptFound,newToughness,ptFound,vector<string>(),false,forceForever,untilYourNextTurn,untilYourNextEndTurn);
}
//bloodthirst
vector<string> splitBloodthirst = parseBetween(s, "bloodthirst:", " ", false);
if (splitBloodthirst.size())
{
return NEW ABloodThirst(observer, id, card, target, atoi(splitBloodthirst[1].c_str()));
WParsedInt* parser = NEW WParsedInt(splitBloodthirst[1], card);
int nb = parser->intValue;
return NEW ABloodThirst(observer, id, card, target, nb);
}
//Vanishing
vector<string> splitVanishing = parseBetween(s, "vanishing:", " ", false);
if (splitVanishing.size())
{
return NEW AVanishing(observer, id, card, NULL, restrictions, atoi(splitVanishing[1].c_str()), "time");
WParsedInt* parser = NEW WParsedInt(splitVanishing[1], card);
int nb = parser->intValue;
return NEW AVanishing(observer, id, card, NULL, restrictions, nb, "time");
}
//Fading
vector<string> splitFading = parseBetween(s, "fading:", " ", false);
if (splitFading.size())
{
return NEW AVanishing(observer, id, card, NULL, restrictions, atoi(splitFading[1].c_str()), "fade");
WParsedInt* parser = NEW WParsedInt(splitFading[1], card);
int nb = parser->intValue;
return NEW AVanishing(observer, id, card, NULL, restrictions, nb, "fade");
}
//Alter cost
@@ -4581,9 +4607,9 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
sabilities.replace(pos, 14, "transforms((" + storedString + "))");
if (oneShot || forceUEOT || forceForever)
return NEW ATransformerInstant(observer, id, card, target, stypes, sabilities,newpower,newpowerfound,newtoughness,newtoughnessfound,newAbilitiesList,newAbilityFound,forceForever,untilYourNextTurn,newName);
return NEW ATransformerInstant(observer, id, card, target, stypes, sabilities,newpower,newpowerfound,newtoughness,newtoughnessfound,newAbilitiesList,newAbilityFound,forceForever,untilYourNextTurn,untilYourNextEndTurn,newName);
return NEW ATransformer(observer, id, card, target, stypes, sabilities,newpower,newpowerfound,newtoughness,newtoughnessfound,newAbilitiesList,newAbilityFound,forceForever,untilYourNextTurn,newName);
return NEW ATransformer(observer, id, card, target, stypes, sabilities,newpower,newpowerfound,newtoughness,newtoughnessfound,newAbilitiesList,newAbilityFound,forceForever,untilYourNextTurn,untilYourNextEndTurn,newName);
}
+4
View File
@@ -926,6 +926,10 @@ void MTGCardInstance::switchPT(bool apply)
stripPTbonus();
swapP = power;
swapT = toughness;
if(!origpower && !origtoughness){ // Fix when a non-creature card is firstly transformed into a creature (e.g. "Wandering Fumarole").
origpower = power;
origtoughness = toughness;
}
power += origpower;
power -= swapP;
addToToughness(origtoughness);
+4 -1
View File
@@ -239,7 +239,10 @@ const char* Constants::MTGBasicAbilities[] = {
"hasaftermath", //Flashback cost is an aftemath cost (e.g. "Claim // Fame")
"noentertrg", //Creatures entering the battlefield don't cause abilities to trigger (e.g. "Hushbringer").
"nodietrg", //Creatures dying don't cause abilities to trigger (e.g. "Hushbringer").
"training" //Has training ability (e.g. "Gryff Rider")
"training", //Has training ability (e.g. "Gryff Rider")
"energyshroud", //Player can't get energy counters (e.g. "Solemnity").
"expshroud", //Player can't get experience counters (e.g. "Solemnity").
"countershroud" //Card can't get any kind of counter (e.g. "Solemnity").
};
map<string,int> Constants::MTGBasicAbilitiesMap;
+11
View File
@@ -287,6 +287,11 @@ WEventCombatStepChange::WEventCombatStepChange(CombatStep step) :
{
}
WEventplayerPoisoned::WEventplayerPoisoned(Player * player, int nb_count) :
player(player), nb_count(nb_count)
{
}
WEventplayerEnergized::WEventplayerEnergized(Player * player, int nb_count) :
player(player), nb_count(nb_count)
{
@@ -634,6 +639,12 @@ Targetable * WEventTokenCreated::getTarget(int target)
return NULL;
}
Targetable * WEventplayerPoisoned::getTarget(Player * player)
{
if (player) return player;
return NULL;
}
Targetable * WEventplayerEnergized::getTarget(Player * player)
{
if (player) return player;
+2 -2
View File
@@ -965,7 +965,7 @@ void WParsedInt::init(string s, Spell * spell, MTGCardInstance * card)
intValue += card->controller()->game->graveyard->cards[j]->myconvertedcost;
}
}
else if (s == "powertotalinplay")//Count Total Power of Creatures you control... Formidable
else if (s == "powertotalinplay" || s == "pwrtotalinplay")//Count Total Power of Creatures you control... Formidable
{
intValue = 0;
for (int j = card->controller()->game->inPlay->nb_cards - 1; j >= 0; --j)
@@ -974,7 +974,7 @@ void WParsedInt::init(string s, Spell * spell, MTGCardInstance * card)
intValue += card->controller()->game->inPlay->cards[j]->getCurrentPower();
}
}
else if (s == "toughnesstotalinplay")//Count Total toughness of Creatures you control...
else if (s == "toughnesstotalinplay" || s == "thstotalinplay")//Count Total toughness of Creatures you control...
{
intValue = 0;
for (int j = card->controller()->game->inPlay->nb_cards - 1; j >= 0; --j)