diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 9ac994786..fcf14d734 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -2704,7 +2704,7 @@ public: for (size_t i = 0; i < currentAbilities.size(); ++i) { MTGAbility * a = currentAbilities[i]; - if (dynamic_cast (a) || dynamic_cast (a)) + if (dynamic_cast (a) || dynamic_cast (a) || a->aType == MTGAbility::STANDARD_TOKENCREATOR && a->oneShot) { SAFE_DELETE(a); continue; @@ -2726,6 +2726,13 @@ public: MTGAbility * a = currentAbilities[i]; if (dynamic_cast (a)) continue; if (dynamic_cast (a)) continue; + if (a->aType == MTGAbility::STANDARD_TOKENCREATOR && a->oneShot) + { + a->forceDestroy = 1; + continue; + } + //we generally dont want to pass oneShot tokencreators to the cards + //we equip... a->addToGame(); } return 1; @@ -2962,7 +2969,7 @@ public: { AEquip* ae = dynamic_cast(a); ae->unequip(); - ae->equip(card); + ae->equip(card); } } } @@ -3951,6 +3958,21 @@ public: ~APreventDamageTypesUEOT(); }; +//Upkeep Cost +class AVanishing: public ActivatedAbility +{ +public: + int timeLeft; + int amount; + + AVanishing(int _id, MTGCardInstance * card, ManaCost * _cost, int _tap = 0, int restrictions = 0,int amount = 0); + void Update(float dt); + int resolve(); + const char * getMenuText(); + AVanishing * clone() const; + ~AVanishing(); +}; + //Upkeep Cost class AUpkeep: public ActivatedAbility, public NestedAbility { diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 5bebec30a..77d4c6a2d 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -2782,6 +2782,73 @@ APreventDamageTypesUEOT::~APreventDamageTypesUEOT() SAFE_DELETE(ability); } +//AVanishing creature +AVanishing::AVanishing(int _id, MTGCardInstance * card, ManaCost * _cost, int _tap, int restrictions, int amount) : +ActivatedAbility(_id, card, _cost, restrictions, _tap),amount(amount) +{ + for(int i = 0;i< amount;i++) + source->counters->addCounter("time",0,0); +} + +void AVanishing::Update(float dt) +{ + if (newPhase != currentPhase && source->controller() == game->currentPlayer) + { + if(newPhase == Constants::MTG_PHASE_UPKEEP) + { + source->counters->removeCounter("time",0,0); + Counter * targetCounter = NULL; + timeLeft = 0; + + if (source->counters && source->counters->hasCounter("time", 0, 0)) + { + targetCounter = source->counters->hasCounter("time", 0, 0); + timeLeft = targetCounter->nb; + } + else + { + timeLeft = 0; + WEvent * e = NEW WEventCardSacrifice(source); + GameObserver * game = GameObserver::GetInstance(); + game->receiveEvent(e); + source->controller()->game->putInGraveyard(source); + } + + } + else if (newPhase == Constants::MTG_PHASE_UPKEEP && timeLeft <= 0) + { + WEvent * e = NEW WEventCardSacrifice(source); + GameObserver * game = GameObserver::GetInstance(); + game->receiveEvent(e); + source->controller()->game->putInGraveyard(source); + } + + } + ActivatedAbility::Update(dt); +} + +int AVanishing::resolve() +{ + + return 1; +} + +const char * AVanishing::getMenuText() +{ + return "Vanishing"; +} + +AVanishing * AVanishing::clone() const +{ + AVanishing * a = NEW AVanishing(*this); + a->isClone = 1; + return a; +} + +AVanishing::~AVanishing() +{ +} + //AUpkeep AUpkeep::AUpkeep(int _id, MTGCardInstance * card, MTGAbility * a, ManaCost * _cost, int _tap, int restrictions, int _phase, int _once,bool Cumulative) : diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index f81382349..90a760015 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -1750,6 +1750,8 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG ATokenCreator * tok = NEW ATokenCreator(id, card,target, NULL, sname, stypes, power + value, toughness + value, sabilities, 0,starfound, multiplier, who,aLivingWeapon); tok->oneShot = 1; + if(aLivingWeapon) + tok->forceDestroy = 1; return tok; } @@ -2422,7 +2424,25 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG MTGAbility * a = NEW ABloodThirst(id, card, target, amount); return a; } - + //Vanishing + found = s.find("vanishing:"); + if (found != string::npos) + { + size_t start = s.find(":", found); + size_t end = s.find(" ", start); + int amount; + if (end != string::npos) + { + amount = atoi(s.substr(start + 1, end - start - 1).c_str()); + } + else + { + amount = atoi(s.substr(start + 1).c_str()); + } + MTGAbility * a = NEW AVanishing(id, card, NULL, doTap, restrictions,amount); + return a; + } + if (s.find("altercost(") != string::npos) return getManaReduxAbility(s.substr(s.find("altercost(") + 10), id, spell, card, target); diff --git a/projects/mtg/src/WEvent.cpp b/projects/mtg/src/WEvent.cpp index 08ba3863e..e3f1f4728 100644 --- a/projects/mtg/src/WEvent.cpp +++ b/projects/mtg/src/WEvent.cpp @@ -173,9 +173,9 @@ Targetable * WEventVampire::getTarget(int target) switch (target) { case TARGET_TO: - return victem->next; + return source->next; case TARGET_FROM: - return source; + return victem; } return NULL; }