diff --git a/projects/mtg/bin/Res/sets/10E/_cards.dat b/projects/mtg/bin/Res/sets/10E/_cards.dat index a57f7b250..d6e5d8712 100644 --- a/projects/mtg/bin/Res/sets/10E/_cards.dat +++ b/projects/mtg/bin/Res/sets/10E/_cards.dat @@ -295,6 +295,19 @@ subtype=Spider toughness=3 [/card] [card] +text=As Clone comes into play, you may choose a creature in play. If you do, Clone comes into play as a copy of that creature. +auto=may copy target(creature) +id=129501 +name=Clone +rarity=R +color=Blue +type=Creature +mana={3}{U} +power=0 +subtype=Shapeshifter +toughness=0 +[/card] +[card] text=Flying (This creature can't be blocked except by creatures with flying or reach.) Cloud Elemental can block only creatures with flying. abilities=cloud,flying id=129804 diff --git a/projects/mtg/bin/Res/sets/10E/todo.dat b/projects/mtg/bin/Res/sets/10E/todo.dat index 05ffb13c8..c3fe7ae58 100644 --- a/projects/mtg/bin/Res/sets/10E/todo.dat +++ b/projects/mtg/bin/Res/sets/10E/todo.dat @@ -283,18 +283,7 @@ power=2 subtype=Elf Warrior Druid toughness=2 [/card] -[card] -text=As Clone comes into play, you may choose a creature in play. If you do, Clone comes into play as a copy of that creature. -id=129501 -name=Clone -rarity=R -color=Blue -type=Creature -mana={3}{U} -power=0 -subtype=Shapeshifter -toughness=0 -[/card] + [card] text=Each creature gets +1/+1 for each other creature in play that shares a creature type with it. (For example, if a Goblin Warrior, a Goblin Scout, and a Zombie Goblin are in play, each gets +2/+2.) id=129502 diff --git a/projects/mtg/bin/Res/sets/RV/_cards.dat b/projects/mtg/bin/Res/sets/RV/_cards.dat index 422ca4ffd..1a4b20a2b 100644 --- a/projects/mtg/bin/Res/sets/RV/_cards.dat +++ b/projects/mtg/bin/Res/sets/RV/_cards.dat @@ -357,6 +357,19 @@ power=0 toughness=4 [/card] [card] +text=As Clone comes into play, you may choose a creature in play. If you do, Clone comes into play as a copy of that creature. +auto=may copy target(creature) +id=1193 +name=Clone +rarity=U +color=Blue +type=Creature +mana={3}{U} +power=0 +subtype=Shapeshifter +toughness=0 +[/card] +[card] text=Flying Whenever Cockatrice blocks or becomes blocked by a non-Wall creature, destroy that creature at end of combat. abilities=Flying id=1238 diff --git a/projects/mtg/bin/Res/sets/RV/todo.dat b/projects/mtg/bin/Res/sets/RV/todo.dat index 934fa02da..46d1f6cb3 100644 --- a/projects/mtg/bin/Res/sets/RV/todo.dat +++ b/projects/mtg/bin/Res/sets/RV/todo.dat @@ -17,18 +17,6 @@ type=Artifact mana={4} [/card] [card] -text=As Clone comes into play, you may choose a creature in play. If you do, Clone comes into play as a copy of that creature. -id=1193 -name=Clone -rarity=U -color=Blue -type=Creature -mana={3}{U} -power=0 -subtype=Shapeshifter -toughness=0 -[/card] -[card] text=Remove Contract from Below from your deck before playing if you're not playing for ante. Discard your hand, add the top card of your library to the ante, then draw seven cards. id=1147 name=Contract from Below diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index 4b9eae185..b0e9976f8 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -31,6 +31,8 @@ brass_man.txt castle.txt celestial_purge.txt circle_of_protection.txt +clone.txt +clone2.txt composite_golem.txt control_magic.txt control_magic2.txt diff --git a/projects/mtg/bin/Res/test/clone.txt b/projects/mtg/bin/Res/test/clone.txt new file mode 100644 index 000000000..d4fa7e0fa --- /dev/null +++ b/projects/mtg/bin/Res/test/clone.txt @@ -0,0 +1,41 @@ +# As Clone comes into play, you may choose a creature in play. If you do, Clone comes into play as a copy of that creature. +[INIT] +FIRSTMAIN +[PLAYER1] +hand:129501 +manapool:{3}{U} +inplay:135185 +[PLAYER2] +[DO] +129501 +choice 0 +135185 +eot +eot +#untap +next +#upkeep +next +#draw +next +#main1 +next +#combat begin +next +#attackers +129501 +135185 +next +#blockers +next +#damage +next +#combat end +[ASSERT] +COMBATEND +[PLAYER1] +inplay:129501,135185 +manapool:{0} +[PLAYER2] +life:18 +[END] \ No newline at end of file diff --git a/projects/mtg/bin/Res/test/clone2.txt b/projects/mtg/bin/Res/test/clone2.txt new file mode 100644 index 000000000..501ecbf38 --- /dev/null +++ b/projects/mtg/bin/Res/test/clone2.txt @@ -0,0 +1,42 @@ +# As Clone comes into play, you may choose a creature in play. If you do, Clone comes into play as a copy of that creature. +[INIT] +FIRSTMAIN +[PLAYER1] +hand:129501 +manapool:{3}{U} +[PLAYER2] +inplay:1221 +[DO] +129501 +choice 0 +1221 +eot +eot +#untap +next +#upkeep +next +#draw +next +#main1 +next +#combat begin +next +#attackers +129501 +next +#blockers +next +#damage +next +#combat end +[ASSERT] +COMBATEND +[PLAYER1] +inplay:129501 +manapool:{0} +life:19 +[PLAYER2] +inplay:1221 +life:16 +[END] \ No newline at end of file diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 86a2119c9..9130eac6e 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -31,6 +31,7 @@ public: int deleteAbility; MayAbility(int _id, MTGAbility * _ability, MTGCardInstance * _source):MTGAbility(_id,_source),ability(_ability){ triggered = 0; + ability->forceDestroy = 1; deleteAbility = 1; } @@ -269,6 +270,28 @@ public: } }; +//Copier. TargetAbility +class ACopier:public TargetAbility{ + public: + ACopier(int _id, MTGCardInstance * _source, TargetChooser * _tc = NULL, ManaCost * _cost=NULL):TargetAbility(_id,_source, _tc,_cost,0,0){ + if (!tc) tc = NEW CreatureTargetChooser(); + } + + int resolve(){ + MTGCardInstance * _target = tc->getNextCardTarget(); + if(_target){ + source->copy(_target); + return 1; + } + return 0; + } + + const char * getMenuText(){ + return "Copy"; + } + +}; + //Destroyer. TargetAbility class ADestroyer:public TargetAbility{ public: diff --git a/projects/mtg/include/MTGAbility.h b/projects/mtg/include/MTGAbility.h index bbd2664b1..6e1987218 100644 --- a/projects/mtg/include/MTGAbility.h +++ b/projects/mtg/include/MTGAbility.h @@ -41,6 +41,7 @@ class MTGAbility: public ActionElement{ GameObserver * game; public: + int forceDestroy; ManaCost * cost; Damageable * target; int aType; diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index cc6782503..cb6f37fd5 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -93,7 +93,7 @@ class MTGCardInstance: public MTGCard, public Damageable, public Targetable { int addProtection(CardDescriptor * cd); int removeProtection(CardDescriptor *cd, int erase = 0); int protectedAgainst(MTGCardInstance * card); - + void copy(MTGCardInstance * card); // in game int isTapped(); void untap(); diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index fa7a73bc9..f04ba6b99 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -333,6 +333,25 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){ continue; } + //Copy a target + found = s.find("copy "); + if (found != string::npos){ + if (dryMode) return BAKA_EFFECT_GOOD; //TODO : + if (tc){ + ACopier * a = NEW ACopier(id,card,tc,cost); + if (may){ + game->addObserver(NEW MayAbility(id,a,card)); + OutputDebugString("may!\n"); + }else{ + game->addObserver(a); + } + }else{ + //TODO + } + result++; + continue; + } + //Bury found = s.find("bury"); if (found != string::npos){ @@ -1553,6 +1572,7 @@ MTGAbility::MTGAbility(int id, MTGCardInstance * card):ActionElement(id){ target = card; aType = MTGAbility::UNKNOWN; cost = NULL; + forceDestroy = 0; } MTGAbility::MTGAbility(int id, MTGCardInstance * _source,Damageable * _target ):ActionElement(id){ @@ -1561,6 +1581,7 @@ MTGAbility::MTGAbility(int id, MTGCardInstance * _source,Damageable * _target ): target = _target; aType = MTGAbility::UNKNOWN; cost = NULL; + forceDestroy = 0; } MTGAbility::~MTGAbility(){ @@ -1570,6 +1591,8 @@ MTGAbility::~MTGAbility(){ //returns 1 if this ability needs to be removed from the list of active abilities int MTGAbility::testDestroy(){ if (game->mLayers->stackLayer()->has(this)) return 0; + if (waitingForAnswer) return 0; + if (forceDestroy) return 1; if (!game->isInPlay(source) ){ OutputDebugString("Destroying Ability !!!\n"); return 1; diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index 40c80ee27..81c0c00d4 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -31,6 +31,47 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * _belongs_to): } +void MTGCardInstance::copy(MTGCardInstance * card){ + MTGCard * source = card->model; + for (int i = 0; i< Constants::NB_BASIC_ABILITIES; i++){ + basicAbilities[i] = source->basicAbilities[i]; + } + for (int i = 0; i< MAX_TYPES_PER_CARD; i++){ + types[i] = source->types[i]; + } + nb_types = source->nb_types; + for (int i = 0; i< Constants::MTG_NB_COLORS; i++){ + colors[i] = source->colors[i]; + } + manaCost.copy(source->getManaCost()); + + text = source->text; + name = source->name; + //strcpy(image_name, source->image_name); + + //rarity = source->rarity; + power = source->power; + toughness = source->toughness; + life = toughness; + lifeOrig = life; + //mtgid = source->mtgid; + //setId = source->setId; + formattedTextInit = 0; + magicText = source->magicText; + spellTargetType = source->spellTargetType; + alias = source->alias; + + //Now this is dirty... + int backupid = mtgid; + mtgid = source->getId(); + Spell * spell = NEW Spell(this); + AbilityFactory af; + GameObserver * g = GameObserver::GetInstance(); + af.addAbilities(g->mLayers->actionLayer()->getMaxId(), spell); + delete spell; + mtgid = backupid; +} + MTGCardInstance::~MTGCardInstance(){ LOG("==Deleting MTGCardInstance=="); SAFE_DELETE(blockers);