Added/fixed primitives, improved "@draw" trigger, added a "@scryed" trigger for scry ability, added a new keyword "placefromthetop" to put a card in a specifc position of owners library from the top.
This commit is contained in:
@@ -892,6 +892,8 @@ int GenericScryAbility::resolve()
|
||||
{
|
||||
MTGAbility * ability = NEW MTGScryCards(game, this->GetId(), source, howMany);
|
||||
ability->addToGame();
|
||||
WEvent * e = NEW WEventCardScryed(source);
|
||||
game->receiveEvent(e);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1718,6 +1720,77 @@ AAModTurn * AAModTurn::clone() const
|
||||
return NEW AAModTurn(*this);
|
||||
}
|
||||
|
||||
//move target to specifc position of owners library from the top
|
||||
AALibraryPosition::AALibraryPosition(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost, unsigned int _position) :
|
||||
ActivatedAbility(observer, _id, _source, _cost, 0)
|
||||
{
|
||||
target = _target;
|
||||
andAbility = NULL;
|
||||
position = _position;
|
||||
}
|
||||
|
||||
int AALibraryPosition::resolve()
|
||||
{
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
_target = _target->owner->game->putInLibrary(_target);
|
||||
if (_target)
|
||||
{
|
||||
MTGLibrary * library = _target->owner->game->library;
|
||||
vector<MTGCardInstance *>oldOrder = library->cards;
|
||||
vector<MTGCardInstance *>newOrder;
|
||||
if(position > oldOrder.size())
|
||||
position = oldOrder.size(); //Avoid to exceed the library dimension.
|
||||
for(unsigned int k = 0; k < oldOrder.size() - position; ++k)
|
||||
{
|
||||
MTGCardInstance * rearranged = oldOrder[k];
|
||||
if(rearranged != _target)
|
||||
newOrder.push_back(rearranged);
|
||||
}
|
||||
newOrder.push_back(_target);
|
||||
for(unsigned int k = oldOrder.size() - position ; k < oldOrder.size(); ++k)
|
||||
{
|
||||
MTGCardInstance * rearranged = oldOrder[k];
|
||||
if(rearranged != _target)
|
||||
newOrder.push_back(rearranged);
|
||||
}
|
||||
library->cards = newOrder;
|
||||
if(andAbility)
|
||||
{
|
||||
MTGAbility * andAbilityClone = andAbility->clone();
|
||||
andAbilityClone->target = _target;
|
||||
if(andAbility->oneShot)
|
||||
{
|
||||
andAbilityClone->resolve();
|
||||
SAFE_DELETE(andAbilityClone);
|
||||
}
|
||||
else
|
||||
{
|
||||
andAbilityClone->addToGame();
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const string AALibraryPosition::getMenuText()
|
||||
{
|
||||
return "Put in Library in a specific position from the top";
|
||||
}
|
||||
|
||||
AALibraryPosition * AALibraryPosition::clone() const
|
||||
{
|
||||
AALibraryPosition * a = NEW AALibraryPosition(*this);
|
||||
if(andAbility)
|
||||
a->andAbility = andAbility->clone();
|
||||
return a;
|
||||
}
|
||||
|
||||
AALibraryPosition::~AALibraryPosition()
|
||||
{
|
||||
SAFE_DELETE(andAbility);
|
||||
}
|
||||
|
||||
//move target to bottom of owners library
|
||||
AALibraryBottom::AALibraryBottom(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost) :
|
||||
ActivatedAbility(observer, _id, _source, _cost, 0)
|
||||
|
||||
@@ -1210,11 +1210,11 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string, int id, Spell
|
||||
|
||||
//drawn player - controller of card - dynamic version drawof(player) -> returns current controller even with exchange of card controller
|
||||
if (TargetChooser * tc = parseSimpleTC(s, "drawof", card))
|
||||
return NEW TrcardDrawn(observer, id, card, tc,once,true,false);
|
||||
return NEW TrcardDrawn(observer, id, card, tc,once,true,false,limitOnceATurn);
|
||||
|
||||
//drawn player - opponent of card controller - dynamic version drawfoeof(player) -> returns current opponent even with exchange of card controller
|
||||
if (TargetChooser * tc = parseSimpleTC(s, "drawfoeof", card))
|
||||
return NEW TrcardDrawn(observer, id, card, tc,once,false,true);
|
||||
return NEW TrcardDrawn(observer, id, card, tc,once,false,true,limitOnceATurn);
|
||||
|
||||
//Card card is drawn - static version - drawn(player) - any player; drawn(controller) - owner forever; drawn(opponent) - opponent forever
|
||||
if (TargetChooser * tc = parseSimpleTC(s, "drawn", card))
|
||||
@@ -1224,11 +1224,15 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string, int id, Spell
|
||||
if (TargetChooser * tc = parseSimpleTC(s, "mutated", card))
|
||||
return NEW TrCardMutated(observer, id, card, tc, once, limitOnceATurn);
|
||||
|
||||
//Surveil has been performed from controller
|
||||
//Surveil has been performed from a card
|
||||
if (TargetChooser * tc = parseSimpleTC(s, "surveiled", card))
|
||||
return NEW TrCardSurveiled(observer, id, card, tc, once, limitOnceATurn);
|
||||
|
||||
//Esplores has been performed from controller
|
||||
//Scry has been performed from a card
|
||||
if (TargetChooser * tc = parseSimpleTC(s, "scryed", card))
|
||||
return NEW TrCardScryed(observer, id, card, tc, once, limitOnceATurn);
|
||||
|
||||
//Esplores has been performed from a cardr
|
||||
if (TargetChooser * tc = parseSimpleTC(s, "explored", card))
|
||||
return NEW TrCardExplored(observer, id, card, tc, once, limitOnceATurn);
|
||||
|
||||
@@ -3097,6 +3101,24 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
return a;
|
||||
}
|
||||
|
||||
//put a card in a specifc position of owners library from the top
|
||||
vector<string> splitPlaceFromTop = parseBetween(s, "placefromthetop(", ")");
|
||||
if (splitPlaceFromTop.size())
|
||||
{
|
||||
WParsedInt* parser = NEW WParsedInt(splitPlaceFromTop[1], card);
|
||||
int position = parser->intValue;
|
||||
MTGAbility * a = NEW AALibraryPosition(observer, id, card, target, NULL, position);
|
||||
a->oneShot = 1;
|
||||
//andability
|
||||
if(storedAndAbility.size())
|
||||
{
|
||||
string stored = storedAndAbility;
|
||||
storedAndAbility.clear();
|
||||
((AALibraryBottom*)a)->andAbility = parseMagicLine(stored, id, spell, card);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
//put a card on bottom of library
|
||||
found = s.find("bottomoflibrary");
|
||||
if (found != string::npos)
|
||||
|
||||
@@ -297,6 +297,11 @@ WEventCardSurveiled::WEventCardSurveiled(MTGCardInstance * card) :
|
||||
{
|
||||
}
|
||||
|
||||
WEventCardScryed::WEventCardScryed(MTGCardInstance * card) :
|
||||
WEventCardUpdate(card)
|
||||
{
|
||||
}
|
||||
|
||||
WEventCardExplored::WEventCardExplored(MTGCardInstance * card) :
|
||||
WEventCardUpdate(card)
|
||||
{
|
||||
@@ -531,6 +536,12 @@ Targetable * WEventCardSurveiled::getTarget(int target)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Targetable * WEventCardScryed::getTarget(int target)
|
||||
{
|
||||
if (target) return card;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Targetable * WEventCardExplored::getTarget(int target)
|
||||
{
|
||||
if (target) return card;
|
||||
|
||||
Reference in New Issue
Block a user