From ca3c2d30abbd7467e253a7ddf820299c1f9e327b Mon Sep 17 00:00:00 2001 From: "wagic.the.homebrew@gmail.com" Date: Tue, 23 Jun 2009 14:22:00 +0000 Subject: [PATCH] Erwan - Magic 2010: Combat Damages don't go on the stack anymore - Comp rules: "goes to graveyard" effects don't go on the stack anymore - Regenerate "fixed" (untested) - Basic "ReplacementEffect" mechanism for damage prevention. Can be extended to other replacement effects with some limits. - TODO: Damages don't go on the stack, the abilities that create them do. --- projects/mtg/Makefile | 2 +- .../mtg/bin/Res/test/circle_of_protection.txt | 9 +-- projects/mtg/include/AllAbilities.h | 55 +++++++++----- projects/mtg/include/Damage.h | 2 +- projects/mtg/include/GameObserver.h | 3 +- projects/mtg/include/MTGCardInstance.h | 8 +- projects/mtg/include/Player.h | 2 +- projects/mtg/include/ReplacementEffects.h | 39 ++++++++++ projects/mtg/include/TargetChooser.h | 16 +++- projects/mtg/src/Damage.cpp | 15 ++-- projects/mtg/src/DamageResolverLayer.cpp | 2 + projects/mtg/src/GameObserver.cpp | 3 + projects/mtg/src/MTGAbility.cpp | 36 +++++---- projects/mtg/src/MTGCardInstance.cpp | 24 +++++- projects/mtg/src/ReplacementEffects.cpp | 76 +++++++++++++++++++ projects/mtg/src/TargetChooser.cpp | 22 +++++- projects/mtg/template.vcproj | 16 ++++ 17 files changed, 266 insertions(+), 64 deletions(-) create mode 100644 projects/mtg/include/ReplacementEffects.h create mode 100644 projects/mtg/src/ReplacementEffects.cpp diff --git a/projects/mtg/Makefile b/projects/mtg/Makefile index 6dc54461a..a9c4c282f 100644 --- a/projects/mtg/Makefile +++ b/projects/mtg/Makefile @@ -1,4 +1,4 @@ -OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/Blocker.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/CardEffect.o objs/ConstraintResolver.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DamageResolverLayer.o objs/DeckDataWrapper.o objs/DeckStats.o objs/DuelLayers.o objs/Effects.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameStateDuel.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GuiCardsController.o objs/GuiLayers.o objs/GuiPhaseBar.o objs/Logger.o objs/ManaCost.o objs/ManaCostHybrid.o objs/MenuItem.o objs/MTGAbility.o objs/MTGCardInstance.o objs/MTGCard.o objs/MTGDeck.o objs/MTGDefinitions.o objs/MTGGamePhase.o objs/MTGGameZones.o objs/MTGGuiHand.o objs/MTGGuiPlay.o objs/MTGRules.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/PriceList.o objs/ShopItem.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.o objs/TexturesCache.o objs/Token.o objs/Translate.o objs/utils.o objs/WEvent.o +OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/Blocker.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/CardEffect.o objs/ConstraintResolver.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DamageResolverLayer.o objs/DeckDataWrapper.o objs/DeckStats.o objs/DuelLayers.o objs/Effects.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameStateDuel.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GuiCardsController.o objs/GuiLayers.o objs/GuiPhaseBar.o objs/Logger.o objs/ManaCost.o objs/ManaCostHybrid.o objs/MenuItem.o objs/MTGAbility.o objs/MTGCardInstance.o objs/MTGCard.o objs/MTGDeck.o objs/MTGDefinitions.o objs/MTGGamePhase.o objs/MTGGameZones.o objs/MTGGuiHand.o objs/MTGGuiPlay.o objs/MTGRules.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/PriceList.o objs/ReplacementEffects.o objs/ShopItem.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.o objs/TexturesCache.o objs/Token.o objs/Translate.o objs/utils.o objs/WEvent.o DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS)) RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache) diff --git a/projects/mtg/bin/Res/test/circle_of_protection.txt b/projects/mtg/bin/Res/test/circle_of_protection.txt index e898103d9..6eb439ee2 100644 --- a/projects/mtg/bin/Res/test/circle_of_protection.txt +++ b/projects/mtg/bin/Res/test/circle_of_protection.txt @@ -9,16 +9,11 @@ inplay:1335,plains 1166 next #blockers -next -no -#damage phase -no -#interrupt the actual damage -yes plains 1335 1166 -endinterrupt +next +#damage next #combatend [ASSERT] diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 2930e5ded..6a1d1e396 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -434,12 +434,8 @@ class ADestroyer:public TargetAbility{ int resolve(){ MTGCardInstance * _target = tc->getNextCardTarget(); if(_target){ - if (bury){ - _target->controller()->game->putInGraveyard(_target); - }else{ - game->mLayers->stackLayer()->addPutInGraveyard(_target); - } - return 1; + if (bury) return _target->bury(); + else return _target->destroy(); } return 0; } @@ -976,17 +972,46 @@ class ASpellCounterEnchantment:public TargetAbility{ //Circle of Protections class ACircleOfProtection: public TargetAbility{ +protected: + map current; public: - ACircleOfProtection(int _id, MTGCardInstance * source, int _color):TargetAbility(_id,source,NEW DamageTargetChooser(source,_color),NEW ManaCost(),0,0){ + ACircleOfProtection(int _id, MTGCardInstance * source, int _color):TargetAbility(_id,source,NEW SpellOrPermanentTargetChooser(source,_color),NEW ManaCost(),0,0){ cost->add(Constants::MTG_COLOR_ARTIFACT,1); } int resolve(){ - Damage * damage = tc->getNextDamageTarget(); - if (!damage) return 0; - game->mLayers->stackLayer()->Fizzle(damage); + MTGCardInstance * _target = NULL; + if (! (_target = tc->getNextCardTarget())){ + Spell * starget = tc->getNextSpellTarget(); + _target = starget->source; + } + if (!_target) return 0; + REDamagePrevention * re = NEW REDamagePrevention ( + NEW CardTargetChooser(_target,NULL), + NEW PlayerTargetChooser(0,1,source->controller())); + current[re] = 1; + game->replacementEffects->add(re); return 1; } + + void clear(){ + for (map::iterator it = current.begin(); it!=current.end(); it++){ + ReplacementEffect* re = (*it).first; + game->replacementEffects->remove(re); + delete re; + } + current.clear(); + } + + void Update(float dt){ + if (newPhase != currentPhase && newPhase == Constants::MTG_PHASE_UNTAP) clear(); + TargetAbility::Update(dt); + } + + ~ACircleOfProtection(){ + clear(); + } + virtual ostream& toString(ostream& out) const { out << "ACircleOfProtection ::: ("; @@ -1005,16 +1030,6 @@ class AStandardRegenerate:public ActivatedAbility{ int resolve(){ MTGCardInstance * _target = (MTGCardInstance *)target; _target->regenerate(); - PutInGraveyard * action = ((PutInGraveyard *) game->mLayers->stackLayer()->getNext(NULL,ACTION_PUTINGRAVEYARD,NOT_RESOLVED)); - while(action){ -#if defined (WIN32) || defined (LINUX) - OutputDebugString("Fizzling due to regenerate! \n"); -#endif - if (action->card == _target){ - game->mLayers->stackLayer()->Fizzle(action); - } - action = ((PutInGraveyard *) game->mLayers->stackLayer()->getNext(action,ACTION_PUTINGRAVEYARD,NOT_RESOLVED)); - } return 1; } diff --git a/projects/mtg/include/Damage.h b/projects/mtg/include/Damage.h index c20b97ce1..24e4e49cc 100644 --- a/projects/mtg/include/Damage.h +++ b/projects/mtg/include/Damage.h @@ -13,7 +13,7 @@ class GameObserver; #define DAMAGEABLE_MTGCARDINSTANCE 0 #define DAMAGEABLE_PLAYER 1 -class Damageable { +class Damageable:public Targetable { protected: public: diff --git a/projects/mtg/include/GameObserver.h b/projects/mtg/include/GameObserver.h index 4d6d60890..55748c4a9 100644 --- a/projects/mtg/include/GameObserver.h +++ b/projects/mtg/include/GameObserver.h @@ -9,7 +9,7 @@ #include "DuelLayers.h" #include "TargetChooser.h" #include "PhaseRing.h" - +#include "ReplacementEffects.h" class MTGGamePhase; class MTGAbility; @@ -43,6 +43,7 @@ class GameObserver{ int oldGamePhase; TargetChooser * targetChooser; DuelLayers * mLayers; + ReplacementEffects *replacementEffects; Player * gameOver; Player * players[2]; //created outside MTGGamePhase * gamePhaseManager; //Created Outside ? diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index 5bb3aca6c..a1903f4e3 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -23,7 +23,7 @@ class Counters; -class MTGCardInstance: public MTGCard, public Damageable, public Targetable { +class MTGCardInstance: public MTGCard, public Damageable { protected: int untapping; int nb_damages; @@ -37,6 +37,7 @@ class MTGCardInstance: public MTGCard, public Damageable, public Targetable { MTGCardInstance * getNextPartner(); void initMTGCI(); public: + int regenerateTokens; bool isToken; int stillInUse(); Player * lastController; @@ -76,13 +77,16 @@ class MTGCardInstance: public MTGCard, public Damageable, public Targetable { MTGCardInstance(); MTGCardInstance(MTGCard * card, MTGPlayerCards * _belongs_to); Blockers * getBlockers(); - void regenerate(); + int regenerate(); + int triggerRegenerate(); Player * controller(); JQuad * getIcon(); int initAttackersDefensers(); MTGCardInstance * getNextOpponent(MTGCardInstance * previous=NULL); int nbOpponents(); ~MTGCardInstance(); + int bury(); + int destroy(); int addToToughness(int value); diff --git a/projects/mtg/include/Player.h b/projects/mtg/include/Player.h index a7cd8df31..f40700298 100644 --- a/projects/mtg/include/Player.h +++ b/projects/mtg/include/Player.h @@ -10,7 +10,7 @@ class MTGPlayerCards; class MTGInPlay; -class Player: public Damageable, public Targetable{ +class Player: public Damageable{ protected: ManaCost * manaPool; diff --git a/projects/mtg/include/ReplacementEffects.h b/projects/mtg/include/ReplacementEffects.h new file mode 100644 index 000000000..268094623 --- /dev/null +++ b/projects/mtg/include/ReplacementEffects.h @@ -0,0 +1,39 @@ +#ifndef _REPLACEMENT_EFFECTS_H_ +#define _REPLACEMENT_EFFECTS_H_ + +#include +using namespace std; +#include "WEvent.h" + +class TargetChooser; + +class ReplacementEffect { +public: + virtual WEvent * replace (WEvent * e) {return e;}; + virtual ~ReplacementEffect(){}; +}; + +class REDamagePrevention: public ReplacementEffect { +protected: + TargetChooser * tcSource; + TargetChooser * tcTarget; + int damage; + bool oneShot; +public: + REDamagePrevention(TargetChooser *_tcSource = NULL,TargetChooser *_tcTarget = NULL, int _damage = -1, bool _oneShot = true); + WEvent * replace (WEvent *e); + ~REDamagePrevention(); +}; + +class ReplacementEffects { +protected: + listmodifiers; +public: + ReplacementEffects(); + WEvent * replace(WEvent *e); + int add(ReplacementEffect * re); + int remove (ReplacementEffect * re); + ~ReplacementEffects(); +}; + +#endif \ No newline at end of file diff --git a/projects/mtg/include/TargetChooser.h b/projects/mtg/include/TargetChooser.h index eaa989b9c..bf3376655 100644 --- a/projects/mtg/include/TargetChooser.h +++ b/projects/mtg/include/TargetChooser.h @@ -52,9 +52,19 @@ class TargetChooserFactory{ }; +class CardTargetChooser:public TargetChooser { + +protected: + MTGCardInstance * validTarget; +public: + CardTargetChooser(MTGCardInstance * _card, MTGCardInstance * source); + virtual int canTarget(Targetable * target ); +}; + + class TargetZoneChooser:public TargetChooser{ public: - MTGGameZone * zones[6]; + MTGGameZone * zones[10]; int nbzones; int init(MTGGameZone ** _zones, int _nbzones); int targetsZone(MTGGameZone * z); @@ -83,8 +93,10 @@ class DamageableTargetChooser:public CreatureTargetChooser{ class PlayerTargetChooser:public TargetChooser{ +protected: + Player * p; //In Case we can only target a specific player public: - PlayerTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1):TargetChooser(card, _maxtargets){}; + PlayerTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, Player *_p = NULL); virtual int canTarget(Targetable * target); }; diff --git a/projects/mtg/src/Damage.cpp b/projects/mtg/src/Damage.cpp index 20a3a23b7..dbebbc3aa 100644 --- a/projects/mtg/src/Damage.cpp +++ b/projects/mtg/src/Damage.cpp @@ -45,12 +45,17 @@ int Damage::resolve(){ _target->doDamageTest = 1; } - int a = target->dealDamage(damage); + GameObserver * g = GameObserver::GetInstance(); + WEvent * e = NEW WEventDamage(this); + e = g->replacementEffects->replace(e); - //Send Damage event to listeners - WEventDamage * e = NEW WEventDamage(this); - GameObserver::GetInstance()->receiveEvent(e); - delete e; + int a = 0; + if (damage) a = target->dealDamage(damage); + + //Send (Damage/Replaced effect) event to listeners + + g->receiveEvent(e); + SAFE_DELETE(e); return a; } diff --git a/projects/mtg/src/DamageResolverLayer.cpp b/projects/mtg/src/DamageResolverLayer.cpp index da0719724..4318ac35b 100644 --- a/projects/mtg/src/DamageResolverLayer.cpp +++ b/projects/mtg/src/DamageResolverLayer.cpp @@ -169,6 +169,7 @@ int DamageResolverLayer::initResolve(){ if (empty()){ if (!damageStack->empty()){ game->mLayers->stackLayer()->addAction(damageStack); + game->mLayers->stackLayer()->resolve(); //Wagic 2010 }else{ SAFE_DELETE(damageStack); } @@ -246,6 +247,7 @@ int DamageResolverLayer::resolveDamages(){ } } game->mLayers->stackLayer()->addAction(damageStack); + game->mLayers->stackLayer()->resolve(); //Wagic 2010 remainingDamageSteps--; resetObjects(); damageStack = NULL; diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index 0c7777767..347a64230 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -51,6 +51,7 @@ GameObserver::GameObserver(Player * _players[], int _nb_players){ reaction = 0; gameOver = NULL; phaseRing = NEW PhaseRing(_players,_nb_players); + replacementEffects = NEW ReplacementEffects(); } void GameObserver::setGamePhaseManager(MTGGamePhase * _phases){ @@ -229,6 +230,7 @@ GameObserver::~GameObserver(){ SAFE_DELETE(targetChooser); SAFE_DELETE(mLayers); SAFE_DELETE(phaseRing); + SAFE_DELETE(replacementEffects); LOG("==GameObserver Destroyed=="); } @@ -442,6 +444,7 @@ void GameObserver::untapPhase(){ } int GameObserver::receiveEvent(WEvent * e){ + if (!e) return 0; return mLayers->receiveEvent(e); } diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index ae666e82b..4bd28543d 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -37,14 +37,12 @@ int AbilityFactory::destroyAllInPlay(TargetChooser * tc, int bury){ tc->source = NULL; // This is to prevent protection from... as objects that destroy all do not actually target GameObserver * game = GameObserver::GetInstance(); for (int i = 0; i < 2 ; i++){ - for (int j = game->players[i]->game->inPlay->nb_cards-1; j >=0 ; j--){ - MTGCardInstance * current = game->players[i]->game->inPlay->cards[j]; + Player * p = game->players[i]; + for (int j = p->game->inPlay->nb_cards-1; j >=0 ; j--){ + MTGCardInstance * current = p->game->inPlay->cards[j]; if (tc->canTarget(current)){ - if (bury){ - game->players[i]->game->putInGraveyard(current); - }else{ - game->mLayers->stackLayer()->addPutInGraveyard(current); - } + if (bury) current->bury(); + else current->destroy(); } } } @@ -546,7 +544,7 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){ if (tc){ game->addObserver(NEW ABurier(id, card,tc)); }else{ - target->controller()->game->putInGraveyard(target); + target->bury(); } } } @@ -584,7 +582,7 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){ if (tc){ game->addObserver(NEW ADestroyer(id, card,tc,0,cost)); }else{ - game->mLayers->stackLayer()->addPutInGraveyard(target); + target->destroy(); } } result++; @@ -1605,19 +1603,19 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){ int _x = x; MTGCardInstance * target = spell->getNextCardTarget(); while(target && _x){ - game->mLayers->stackLayer()->addPutInGraveyard(target); - _x--; - target = spell->getNextCardTarget(target); + target->destroy(); + _x--; + target = spell->getNextCardTarget(target); } x-=_x; for (int i = 0; i < 2 ; i++){ - game->mLayers->stackLayer()->addDamage(card, game->players[i], x); - for (int j = 0; j < game->players[i]->game->inPlay->nb_cards; j++){ - MTGCardInstance * current = game->players[i]->game->inPlay->cards[j]; - if (current->isACreature()){ - game->mLayers->stackLayer()->addDamage(card, current, x); - } - } + game->mLayers->stackLayer()->addDamage(card, game->players[i], x); + for (int j = 0; j < game->players[i]->game->inPlay->nb_cards; j++){ + MTGCardInstance * current = game->players[i]->game->inPlay->cards[j]; + if (current->isACreature()){ + game->mLayers->stackLayer()->addDamage(card, current, x); + } + } } break; } diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index cffd711cd..bf1b469b4 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -101,6 +101,7 @@ void MTGCardInstance::initMTGCI(){ previous = NULL; next = NULL; lastController = NULL; + regenerateTokens = 0; } @@ -128,13 +129,20 @@ int MTGCardInstance::afterDamage(){ doDamageTest = 0; if (!isACreature()) return 0; if (life <=0 && isInPlay()){ - GameObserver * game = GameObserver::GetInstance(); - game->mLayers->stackLayer()->addPutInGraveyard(this); - return 1; + return destroy(); } return 0; } +int MTGCardInstance::bury(){ + Player * p = controller(); + p->game->putInZone(this,p->game->inPlay,owner->game->graveyard); + return 1; +} +int MTGCardInstance::destroy(){ + if (!triggerRegenerate()) return bury(); + return 0; +} MTGGameZone * MTGCardInstance::getCurrentZone(){ GameObserver * game = GameObserver::GetInstance(); @@ -194,10 +202,17 @@ void MTGCardInstance::resetAllDamage(){ nb_damages = 0; } -void MTGCardInstance::regenerate(){ +int MTGCardInstance::regenerate(){ + return ++regenerateTokens; +} + +int MTGCardInstance::triggerRegenerate(){ + if (! regenerateTokens) return 0; + regenerateTokens--; tapped = 1; life = toughness; initAttackersDefensers(); + return 1; } @@ -217,6 +232,7 @@ int MTGCardInstance::cleanup(){ if (previous && !previous->stillInUse()){ SAFE_DELETE(previous); } + regenerateTokens = 0; return 1; } diff --git a/projects/mtg/src/ReplacementEffects.cpp b/projects/mtg/src/ReplacementEffects.cpp new file mode 100644 index 000000000..9347bb7cd --- /dev/null +++ b/projects/mtg/src/ReplacementEffects.cpp @@ -0,0 +1,76 @@ +#include "../include/config.h" +#include "../include/ReplacementEffects.h" +#include "../include/MTGCardInstance.h" +#include "../include/TargetChooser.h" +#include "../include/Damage.h" + + +REDamagePrevention::REDamagePrevention(TargetChooser *_tcSource, TargetChooser *_tcTarget,int _damage, bool _oneShot):damage(_damage), tcSource(_tcSource), tcTarget(_tcTarget), oneShot(_oneShot){ +} + +WEvent * REDamagePrevention::replace (WEvent *event){ + if (!event) return event; + if (!damage) return event; + WEventDamage * e = dynamic_cast(event); + if (!e) return event; + Damage *d = e->damage; + if ((!tcSource || tcSource->canTarget(d->source)) && + (!tcTarget || tcTarget->canTarget(d->target)) + ){ + if (damage == -1){ + d->damage = 0; + delete event; + if (oneShot) damage = 0; + return NULL; + } + if (damage >= d->damage){ + damage-= d->damage; + d->damage = 0; + delete event; + return NULL; + } + d->damage -= damage; + damage = 0; + delete event; + WEventDamage* newEvent = NEW WEventDamage(d); + return newEvent; + } + return event; +} +REDamagePrevention::~REDamagePrevention(){ + SAFE_DELETE(tcSource); + SAFE_DELETE(tcTarget); +} + +ReplacementEffects::ReplacementEffects(){} + +WEvent * ReplacementEffects::replace(WEvent *e){ + list::iterator it; + + for ( it=modifiers.begin() ; it != modifiers.end(); it++ ){ + ReplacementEffect *re = *it; + WEvent * newEvent = re->replace(e); + if (!newEvent) return NULL; + if (newEvent != e) return replace(newEvent); + } + return e; +} + +int ReplacementEffects::add(ReplacementEffect * re){ + modifiers.push_back(re); + return 1; +} + +int ReplacementEffects::remove (ReplacementEffect *re){ + modifiers.remove(re); + return 1; +} + +ReplacementEffects::~ReplacementEffects(){ + list::iterator it; + for ( it=modifiers.begin() ; it != modifiers.end(); it++ ){ + ReplacementEffect *re = *it; + delete(re); + } + modifiers.clear(); +} \ No newline at end of file diff --git a/projects/mtg/src/TargetChooser.cpp b/projects/mtg/src/TargetChooser.cpp index 0087a54f3..a2b8a60b0 100644 --- a/projects/mtg/src/TargetChooser.cpp +++ b/projects/mtg/src/TargetChooser.cpp @@ -330,7 +330,21 @@ int TargetChooser::targetListSet(){ return 0; } +/** + a specific Card +**/ +CardTargetChooser::CardTargetChooser(MTGCardInstance * _card, MTGCardInstance * source):TargetChooser(source){ + validTarget = _card; +} +int CardTargetChooser::canTarget(Targetable * target ){ + if (!TargetChooser::canTarget(target)) return 0; + if (target->typeAsTarget() == TARGET_CARD){ + MTGCardInstance * card = (MTGCardInstance *) target; + if (card == validTarget) return 1; + } + return 0; +} /** Choose anything that has a given list of types @@ -522,9 +536,15 @@ int TargetZoneChooser::targetsZone(MTGGameZone * z){ } /* Player Target */ + +PlayerTargetChooser::PlayerTargetChooser(MTGCardInstance * card, int _maxtargets, Player *_p):TargetChooser(card, _maxtargets){ + p = _p; +} + int PlayerTargetChooser::canTarget(Targetable * target){ if (target->typeAsTarget() == TARGET_PLAYER){ - return 1; + Player * _target = (Player *) target; + if (!p || p == _target) return 1; } return 0; } diff --git a/projects/mtg/template.vcproj b/projects/mtg/template.vcproj index e88a3403a..0ade39d38 100644 --- a/projects/mtg/template.vcproj +++ b/projects/mtg/template.vcproj @@ -372,6 +372,10 @@ RelativePath=".\src\GuiLayers.cpp" > + + @@ -456,6 +460,10 @@ RelativePath=".\src\PriceList.cpp" > + + @@ -673,6 +681,10 @@ RelativePath=".\include\GuiLayers.h" > + + @@ -761,6 +773,10 @@ RelativePath=".\include\PriceList.h" > + +