From c0e8dcb1c9805c9a9e9dda412b3f3e414ac8a4db Mon Sep 17 00:00:00 2001 From: "omegablast2002@yahoo.com" Date: Sat, 10 Sep 2011 19:37:44 +0000 Subject: [PATCH] this is the first basic rules of kais mod. added parentchildrule which currently only handles the removel of children if a parent dies, but will be extended to handle other actions based on event receiving that deal with child and parent association. add keyword targetable ability "connect" connect means "the source adds the target to it's parent vector, the target adds the source to it's children vector" this can be multitargeted, so it is possible that "Big Bad Dragon" can live it 2 different domains. not sure if this was even asked for, but i thought it would be cool to be able to say "to play big bad creature you need to give it 2 homes" or "big bad creature can live in upto 4 homes" this adds a level of stratigy, becuase now big bad creature can have "all creatures which share a domain with big bad creature gain +2/+2"...or "all domains that city planner live in gain 1 capacity" but also add the possibility of faster removel from a card like "destroy all creatures on target domain". i thought it would be a nice add to kai rules. connect clears a target= on a card after connecting...this is to avoid abilities transfering to the target, unless you want it to effect the target like "tap target domain as this becomes a inhabatant" target=domain auto=tap auto=connect auto=<==this line on will not be targeting the domain --- projects/mtg/include/AllAbilities.h | 9 ++++ projects/mtg/include/MTGCardInstance.h | 3 ++ projects/mtg/include/MTGRules.h | 11 +++++ projects/mtg/src/AllAbilities.cpp | 30 +++++++++++++ projects/mtg/src/DuelLayers.cpp | 1 + projects/mtg/src/MTGAbility.cpp | 9 ++++ projects/mtg/src/MTGRules.cpp | 58 ++++++++++++++++++++++++++ 7 files changed, 121 insertions(+) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index cd1ecd793..d51d1fddd 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -3214,6 +3214,15 @@ 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 diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index 5a7cbf979..58f13d174 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -43,6 +43,9 @@ protected: int removeBlocker(MTGCardInstance * c); int init(); public: + vectorparentCards; + vectorchildrenCards; + int setAttacker(int value); int setDefenser(MTGCardInstance * c); MTGGameZone * currentZone; diff --git a/projects/mtg/include/MTGRules.h b/projects/mtg/include/MTGRules.h index 9b46d6503..7eeecc7f4 100644 --- a/projects/mtg/include/MTGRules.h +++ b/projects/mtg/include/MTGRules.h @@ -408,6 +408,17 @@ public: virtual MTGDeathtouchRule * clone() const; }; +/* handling parentchild */ +class ParentChildRule: public MTGAbility +{ +public: + ParentChildRule(int _id); + map > victems; + int receiveEvent(WEvent * event); + virtual ostream& toString(ostream& out) const; + int testDestroy(); + virtual ParentChildRule * clone() const; +}; /* HUD Display */ class HUDString diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 260341037..103ab9082 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -3831,6 +3831,36 @@ ABlinkGeneric::~ABlinkGeneric() SAFE_DELETE(ability); } +// target becomes a parent of card(source) +AAConnect::AAConnect(int id, MTGCardInstance * card, MTGCardInstance * _target, ManaCost * _cost) : +ActivatedAbility(id, card, _cost, 0) +{ + target = _target; +} + +int AAConnect::resolve() +{ + MTGCardInstance * _target = (MTGCardInstance *) target; + if (_target) + { + while (_target->next) + _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!!! + + } + return 1; +} + +AAConnect * AAConnect::clone() const +{ + return NEW AAConnect(*this); +} //Tutorial Messaging diff --git a/projects/mtg/src/DuelLayers.cpp b/projects/mtg/src/DuelLayers.cpp index 92bb67239..ccca246bf 100644 --- a/projects/mtg/src/DuelLayers.cpp +++ b/projects/mtg/src/DuelLayers.cpp @@ -44,6 +44,7 @@ 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)); diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index ad075fd9e..b66a4106f 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -2397,6 +2397,15 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG return a; } + //create an association between cards. + found = s.find("connect"); + if (found != string::npos) + { + MTGAbility * a = NEW AAConnect(id, card, target); + a->oneShot = 1; + return a; + } + DebugTrace(" no matching ability found. " << s); return NULL; } diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 0d337e55e..f374bfc9d 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -2319,3 +2319,61 @@ MTGDeathtouchRule * MTGDeathtouchRule::clone() const { return NEW MTGDeathtouchRule(*this); } +// +//kai mod +ParentChildRule::ParentChildRule(int _id) : +MTGAbility(_id, NULL) +{ +} +; + +int ParentChildRule::receiveEvent(WEvent * event) +{ + WEventZoneChange * z = dynamic_cast (event); + if (z) + { + MTGCardInstance * card = z->card->previous; + if(!card) + { + return 0; + } + if(!card->childrenCards.size()) + return 0; + Player * p = card->controller(); + if (z->from == p->game->inPlay) + { + for(unsigned int w = 0;w < card->childrenCards.size();w++) + { + MTGCardInstance * child = card->childrenCards[w]; + if(child == NULL) + continue; + if(child->parentCards.size() < 2) + child->controller()->game->putInGraveyard(child); + else//allows a card to declare 2 homes, as long as it has a home it can stay inplay. + { + for(unsigned int myParent = 0;myParent < child->parentCards.size();myParent++) + { + if(child->parentCards[myParent] == card) + child->parentCards.erase(child->parentCards.begin() + myParent); + } + } + } + } + return 1; + } + return 0; +} + +ostream& ParentChildRule::toString(ostream& out) const +{ + out << "ParentChildRule ::: ("; + return MTGAbility::toString(out) << ")"; +} +int ParentChildRule::testDestroy() +{ + return 0; +} +ParentChildRule * ParentChildRule::clone() const +{ + return NEW ParentChildRule(*this); +} \ No newline at end of file