added weapon handling for connect, please be sure to code these weapons as follows

target=*|mybattlefield
auto={0}:equip
auto=connect
notice i declare the equip before the connect, this is becuase connect will use the equip ability of the card to handle it. 
target= can be used for connecting them now as the first time equip. please remember to use teach( or autoskill= to avoid giving abilities forever to a target...this makes equipments hybrid auras.

also, moved parentchildrule init from original init to rules.txt...
in yourrules.txt
should look like this:

include mtg.txt
name=Classic
[INIT]
mode=mtg
auto=connectrule
[PLAYERS]
auto=shuffle
auto=draw:7

i did this becuase i want to reuse the parentchild associations for mtgabilities...and if parents will always kill thier children, i won't be able to use it :P

changed connect into an instant ability, i don't want this ability to be done by menu choice.
This commit is contained in:
omegablast2002@yahoo.com
2011-09-10 21:28:20 +00:00
parent c0e8dcb1c9
commit 6a8f7374cb
5 changed files with 53 additions and 19 deletions

View File

@@ -2330,6 +2330,15 @@ public:
};
//
/* create a parent child association between cards */
class AAConnect: public InstantAbility
{
public:
AAConnect(int id, MTGCardInstance * card, MTGCardInstance * _target, ManaCost * _cost = NULL);
int resolve();
AAConnect * clone() const;
};
//equipment
class AEquip: public TargetAbility
{
@@ -2347,12 +2356,19 @@ public:
if (source->target)
{
source->target->equipment -= 1;
source->parentCards.clear();
for(unsigned int w = 0;w < source->target->childrenCards.size();w++)
{
MTGCardInstance * child = source->target->childrenCards[w];
if(child == source)
source->target->childrenCards.erase(source->target->childrenCards.begin() + w);
}
}
source->target = NULL;
for (size_t i = 0; i < currentAbilities.size(); ++i)
{
MTGAbility * a = currentAbilities[i];
if (dynamic_cast<AEquip *> (a) || dynamic_cast<ATeach *> (a) || (a->aType == MTGAbility::STANDARD_TOKENCREATOR && a->oneShot))
if (dynamic_cast<AEquip *> (a) || dynamic_cast<ATeach *> (a) || dynamic_cast<AAConnect *> (a) || (a->aType == MTGAbility::STANDARD_TOKENCREATOR && a->oneShot))
{
SAFE_DELETE(a);
continue;
@@ -2367,6 +2383,8 @@ public:
{
source->target = equipped;
source->target->equipment += 1;
source->parentCards.push_back((MTGCardInstance*)target);
source->target->childrenCards.push_back((MTGCardInstance*)source);
AbilityFactory af;
af.getAbilities(&currentAbilities, NULL, source);
for (size_t i = 0; i < currentAbilities.size(); ++i)
@@ -2374,6 +2392,7 @@ public:
MTGAbility * a = currentAbilities[i];
if (dynamic_cast<AEquip *> (a)) continue;
if (dynamic_cast<ATeach *> (a)) continue;
if (dynamic_cast<AAConnect *> (a)) continue;
if (a->aType == MTGAbility::STANDARD_TOKENCREATOR && a->oneShot)
{
a->forceDestroy = 1;
@@ -3214,15 +3233,6 @@ public:
}
};
/* create a parent child association between cards */
class AAConnect: public ActivatedAbility
{
public:
AAConnect(int id, MTGCardInstance * card, MTGCardInstance * _target, ManaCost * _cost = NULL);
int resolve();
AAConnect * clone() const;
};
// Add life of gives damage if a given zone has more or less than [condition] cards at the beginning of [phase]
//Ex : the rack, ivory tower...
class ALifeZoneLink: public MTGAbility

View File

@@ -413,7 +413,6 @@ class ParentChildRule: public MTGAbility
{
public:
ParentChildRule(int _id);
map<MTGCardInstance*,vector<MTGCardInstance*> > victems;
int receiveEvent(WEvent * event);
virtual ostream& toString(ostream& out) const;
int testDestroy();

View File

@@ -3833,7 +3833,7 @@ ABlinkGeneric::~ABlinkGeneric()
// target becomes a parent of card(source)
AAConnect::AAConnect(int id, MTGCardInstance * card, MTGCardInstance * _target, ManaCost * _cost) :
ActivatedAbility(id, card, _cost, 0)
InstantAbility(id, card, target)
{
target = _target;
}
@@ -3847,12 +3847,29 @@ int AAConnect::resolve()
_target = _target->next;
_target->childrenCards.push_back(source);
source->parentCards.push_back(_target);
if(source->target)
source->target = NULL;
//clearing the source target allows us to use target= line
//without creating side effects on any other abilities a card has
//connect has to be the first ability in the cards lines unless you want it to do effects to the targeted card!!!
//weapon
if(source->hasSubtype(Subtypes::TYPE_EQUIPMENT))
{
GameObserver * g = GameObserver::GetInstance();
for (size_t i = 1; i < g->mLayers->actionLayer()->mObjects.size(); i++)
{
MTGAbility * a = ((MTGAbility *) g->mLayers->actionLayer()->mObjects[i]);
AEquip * eq = dynamic_cast<AEquip*> (a);
if (eq && eq->source == source)
{
((AEquip*)a)->unequip();
((AEquip*)a)->equip(_target);
}
}
}
else
{
if(source->target)
source->target = NULL;
//clearing the source target allows us to use target= line
//without creating side effects on any other abilities a card has
//connect has to be the first ability in the cards lines unless you want it to do effects to the targeted card!!!
}
}
return 1;
}

View File

@@ -44,7 +44,6 @@ void DuelLayers::init()
action->Add(NEW MTGDeathtouchRule(-1));
action->Add(NEW OtherAbilitiesEventReceiver(-1));
action->Add(NEW MTGMorphCostRule(-1));
action->Add(NEW ParentChildRule(-1));
//Other display elements
action->Add(NEW HUDDisplay(-1));

View File

@@ -11,6 +11,7 @@
#include "Translate.h"
#include "ThisDescriptor.h"
#include "ExtraCost.h"
#include "MTGRules.h"
//Used for Lord/This parsing
@@ -2397,6 +2398,14 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
return a;
}
//adds the rule to destroy children if parent dies
found = s.find("connectrule");
if(found != string::npos)
{
GameObserver * game = GameObserver::GetInstance();
game->addObserver(NEW ParentChildRule(-1));
return NULL;
}
//create an association between cards.
found = s.find("connect");
if (found != string::npos)