Merge pull request #778 from zethfoxster/master

getting master
This commit is contained in:
zethfoxster
2016-07-21 20:47:28 -04:00
committed by GitHub
10 changed files with 271 additions and 18 deletions
+23
View File
@@ -4456,6 +4456,29 @@ public:
const string getMenuText(); const string getMenuText();
AAMorph * clone() const; AAMorph * clone() const;
}; };
class AAMeldFrom : public ActivatedAbility
{
public:
string _MeldedName;
AAMeldFrom(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target, string MeldedName = "");
int resolve();
const string getMenuText();
AAMeldFrom * clone() const;
};
/* meld*/
class AAMeld : public ActivatedAbility
{
public:
string _MeldedName;
AAMeld(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target,string MeldedName = "");
int resolve();
const string getMenuText();
AAMeld * clone() const;
};
/* flip*/ /* flip*/
class AAFlip: public InstantAbility class AAFlip: public InstantAbility
{ {
+2 -1
View File
@@ -299,7 +299,8 @@ public:
class Offering : public ExtraCost class Offering : public ExtraCost
{ {
public: public:
Offering(TargetChooser *_tc = NULL); bool emerge;
Offering(TargetChooser *_tc = NULL, bool emerge = false);
virtual int canPay(); virtual int canPay();
virtual int isPaymentSet(); virtual int isPaymentSet();
virtual int doPay(); virtual int doPay();
+1
View File
@@ -89,6 +89,7 @@ public:
bool turningOver; bool turningOver;
bool isMorphed; bool isMorphed;
bool isFlipped; bool isFlipped;
string MeldedFrom;
bool isPhased; bool isPhased;
bool isCascaded; bool isCascaded;
int phasedTurn; int phasedTurn;
+105 -2
View File
@@ -3069,6 +3069,68 @@ AAMorph * AAMorph::clone() const
a->forceDestroy = 1; a->forceDestroy = 1;
return a; return a;
} }
//Melded From Setter
AAMeldFrom::AAMeldFrom(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target, string MeldedName) :
ActivatedAbility(observer, id, card, 0), _MeldedName(MeldedName)
{
target = _target;
// aType = MTGAbility::Melder;
}
int AAMeldFrom::resolve()
{
source->MeldedFrom = _MeldedName;
return 1;
}
const string AAMeldFrom::getMenuText()
{
return "Melded From";
}
AAMeldFrom * AAMeldFrom::clone() const
{
return NEW AAMeldFrom(*this);
}
//Melding
AAMeld::AAMeld(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target, string MeldedName) :
ActivatedAbility(observer, id, card, 0), _MeldedName(MeldedName)
{
target = _target;
// aType = MTGAbility::Melder;
}
int AAMeld::resolve()
{
MTGCardInstance * _target = (MTGCardInstance *)target;
if (_target && _target->controller() == source->controller() && _target->owner == source->owner && !_target->isToken && !source->isToken)
{
source->controller()->game->putInExile(source);
_target->controller()->game->putInExile(_target);
source->next->controller()->game->putInZone(source->next, source->next->currentZone, source->next->controller()->game->temp);
_target->next->controller()->game->putInZone(_target->next, _target->next->currentZone, _target->next->controller()->game->temp);
MTGAbility *a = NEW AACastCard(game, game->mLayers->actionLayer()->getMaxId(), source, source, false, false, false, _MeldedName, _MeldedName, false, true);
a->oneShot = false;
a->canBeInterrupted = false;
a->addToGame();
return 1;
}
return 0;
}
const string AAMeld::getMenuText()
{
return "Meld";
}
AAMeld * AAMeld::clone() const
{
return NEW AAMeld(*this);
}
// flip a card // flip a card
AAFlip::AAFlip(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target,string flipStats) : AAFlip::AAFlip(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target,string flipStats) :
InstantAbility(observer, id, card, _target),flipStats(flipStats) InstantAbility(observer, id, card, _target),flipStats(flipStats)
@@ -6900,21 +6962,62 @@ void ABlink::resolveBlink()
// this->forceDestroy = 1; // this->forceDestroy = 1;
// return; // return;
//} //}
if (_target->MeldedFrom.size())
{
//cards with meld are handled very different from normal cards with this specific ability giving us about 3 of the
//core rules for the ability. below we split the card up, and we send them to garbage, move the original to temp where
//it is later moved to garbage by garbage collection.
//then we build 2 seperate blinks with the 2 parts as the targets.
vector<string> names = split(_target->MeldedFrom, '|');
MTGCard * cardone = MTGCollection()->getCardByName(names[0]);
MTGCardInstance * cardOne = NEW MTGCardInstance(cardone, _target->owner->game);
MTGCard * cardtwo = MTGCollection()->getCardByName(names[1]);
MTGCardInstance * cardTwo = NEW MTGCardInstance(cardtwo, _target->owner->game);
_target->controller()->game->putInZone(_target, _target->currentZone,
_target->owner->game->temp);
_target->controller()->game->garbage->addCard(cardOne);
_target->controller()->game->garbage->addCard(cardTwo);
MTGAbility * a = NEW ABlinkGeneric(game, game->mLayers->actionLayer()->getMaxId(), source, cardOne, blinkueot, blinkForSource, blinkhand, stored);
a->target = (Targetable*)cardOne;
a->oneShot = false;
a->canBeInterrupted = false;
a->resolve();
SAFE_DELETE(a);
MTGAbility * a2 = NEW ABlinkGeneric(game, game->mLayers->actionLayer()->getMaxId(), source, cardTwo, blinkueot, blinkForSource, blinkhand, stored);
a2->target = (Targetable*)cardTwo;
a2->oneShot = false;
a2->canBeInterrupted = false;
a2->resolve();
SAFE_DELETE(a2);
this->forceDestroy = 1;
this->removeFromGame();
return;
}
else
_target->controller()->game->putInZone(_target, _target->currentZone, _target->controller()->game->putInZone(_target, _target->currentZone,
_target->owner->game->exile); _target->owner->game->exile);
if (_target->MeldedFrom.size() || !_target)
{
return;
}
if(_target->isToken) if(_target->isToken)
{ {
//if our target is a token, we're done as soon as its sent to exile. //if our target is a token, we're done as soon as its sent to exile.
this->forceDestroy = 1; this->forceDestroy = 1;
return; return;
} }
_target = _target->next;
if (_target && _target->next)
_target = _target->next;
_target->blinked = true; _target->blinked = true;
Blinked = _target; Blinked = _target;
if(!blinkueot && !blinkForSource) if (!blinkueot && !blinkForSource)
{ {
returnCardIntoPlay(_target); returnCardIntoPlay(_target);
} }
} }
} }
+5
View File
@@ -154,6 +154,11 @@ void CardGui::Render()
quad = AlternateThumbQuad(card); quad = AlternateThumbQuad(card);
float cardScale = quad ? 40 / quad->mHeight : 1; float cardScale = quad ? 40 / quad->mHeight : 1;
//I want the below for melded cards but I dont know how to adjust everything else
//to look neat and clean. leaving this here incase someone else wants to pretty up the p/t box
//and line up the position.
/* if (card->MeldedFrom.size())
cardScale = cardScale + (10 / quad->mHeight);*/
float scale = actZ * cardScale; float scale = actZ * cardScale;
JQuadPtr shadow; JQuadPtr shadow;
+72 -15
View File
@@ -1128,8 +1128,8 @@ Offering * Offering::clone() const
return ec; return ec;
} }
Offering::Offering(TargetChooser *_tc) : Offering::Offering(TargetChooser *_tc,bool emerge) :
ExtraCost("Select creature to offer", _tc) ExtraCost("Select creature to offer", _tc), emerge(emerge)
{ {
} }
@@ -1137,28 +1137,77 @@ int Offering::canPay()
{ {
if (target && target->has(Constants::CANTBESACRIFIED)) if (target && target->has(Constants::CANTBESACRIFIED))
return 0; return 0;
if (emerge)
if (target && (!source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()))))
{ {
tc->removeTarget(target); if (target)
target = NULL; {
return 0; ManaCost * reduced = NEW ManaCost(source->getManaCost());
reduced->remove(Constants::MTG_COLOR_ARTIFACT, target->getManaCost()->getConvertedCost());
if (target && (!source->controller()->getManaPool()->canAfford(reduced)))
{
tc->removeTarget(target);
target = NULL;
SAFE_DELETE(reduced);
return 0;
}
if (target && source->controller()->getManaPool()->canAfford(reduced))
{
SAFE_DELETE(reduced);
return 1;
}
}
}
else
{
if (target && (!source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()))))
{
tc->removeTarget(target);
target = NULL;
return 0;
}
if (target && (source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()))))
return 1;
} }
if (target && (source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()))))
return 1;
return 0; return 0;
} }
int Offering::isPaymentSet() int Offering::isPaymentSet()
{ {
if (target && (!source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost())))) if (emerge)
{ {
tc->removeTarget(target); if (target)
target = NULL; {
return 0; ManaCost * reduced = NEW ManaCost(source->getManaCost());
reduced->remove(Constants::MTG_COLOR_ARTIFACT, target->getManaCost()->getConvertedCost());
if (target && (!source->controller()->getManaPool()->canAfford(reduced)))
{
tc->removeTarget(target);
target = NULL;
SAFE_DELETE(reduced);
return 0;
}
if (target && source->controller()->getManaPool()->canAfford(reduced))
{
SAFE_DELETE(reduced);
return 1;
}
}
}
else
{
if (target && (!source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()))))
{
tc->removeTarget(target);
target = NULL;
return 0;
}
if (target && (source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()))))
return 1;
} }
if (target && (source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()))))
return 1;
return 0; return 0;
} }
@@ -1166,6 +1215,14 @@ int Offering::doPay()
{ {
if (target) if (target)
{ {
if (emerge)
{
ManaCost * reduced = NEW ManaCost(source->getManaCost());
reduced->remove(Constants::MTG_COLOR_ARTIFACT, target->getManaCost()->getConvertedCost());
target->controller()->getManaPool()->pay(reduced);
SAFE_DELETE(reduced);
}
else
target->controller()->getManaPool()->pay(source->getManaCost()->Diff(target->getManaCost())); target->controller()->getManaPool()->pay(source->getManaCost()->Diff(target->getManaCost()));
MTGCardInstance * beforeCard = target; MTGCardInstance * beforeCard = target;
source->storedCard = target->createSnapShot(); source->storedCard = target->createSnapShot();
+27
View File
@@ -3296,6 +3296,33 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
return a; return a;
} }
//meld helper class
vector<string> splitMeldFrom = parseBetween(s, "meldfrom(", ")", true);
if (splitMeldFrom.size())
{
string splitMeldNames = "";
if (splitMeldFrom[1].size())
{
splitMeldNames = splitMeldFrom[1];
}
MTGAbility * a = NEW AAMeldFrom(observer, id, card, target, splitMeldNames);
a->oneShot = true;
return a;
}
//meld
vector<string> splitMeld = parseBetween(s, "meld(", ")", true);
if (splitMeld.size())
{
string splitMeldName = "";
if (splitMeld[1].size())
{
splitMeldName = splitMeld[1];
}
MTGAbility * a = NEW AAMeld(observer, id, card, target, splitMeldName);
a->oneShot = true;
return a;
}
//flip //flip
vector<string> splitFlipStat = parseBetween(s, "flip(", ")", true); vector<string> splitFlipStat = parseBetween(s, "flip(", ")", true);
if(splitFlipStat.size()) if(splitFlipStat.size())
+1
View File
@@ -195,6 +195,7 @@ void MTGCardInstance::initMTGCI()
morphed = false; morphed = false;
turningOver = false; turningOver = false;
isMorphed = false; isMorphed = false;
MeldedFrom = "";
isFlipped = false; isFlipped = false;
isPhased = false; isPhased = false;
isCascaded = false; isCascaded = false;
+28
View File
@@ -431,6 +431,34 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
return ret;//don't send event return ret;//don't send event
} }
} }
//before adding card to zone, if its Melded, we break it apart
if (from == g->players[0]->game->battlefield || from == g->players[1]->game->battlefield)
{
if(to != g->players[0]->game->battlefield || to != g->players[1]->game->battlefield)
if (copy->previous && copy->previous->MeldedFrom.size())
{
vector<string> names = split(copy->previous->MeldedFrom, '|');
MTGCard * cardone = MTGCollection()->getCardByName(names[0]);
MTGCardInstance * cardOne = NEW MTGCardInstance(cardone, copy->owner->game);
to->addCard(cardOne);
WEvent * e = NEW WEventZoneChange(cardOne, from, to);
g->receiveEvent(e);
MTGCard * cardtwo = MTGCollection()->getCardByName(names[1]);
MTGCardInstance * cardTwo = NEW MTGCardInstance(cardtwo, copy->owner->game);
to->addCard(cardTwo);
WEvent * e2 = NEW WEventZoneChange(cardTwo, from, to);
g->receiveEvent(e2);
if(from == g->players[0]->game->battlefield)
g->players[0]->game->temp->addCard(copy);
if (from == g->players[1]->game->battlefield)
g->players[1]->game->temp->addCard(copy);
WEvent * e3 = NEW WEventZoneChange(copy, from, to);
g->receiveEvent(e3);
return ret;
}
}
to->addCard(copy); to->addCard(copy);
//The "Temp" zone are purely for code purposes, and we don't want the abilities engine to //The "Temp" zone are purely for code purposes, and we don't want the abilities engine to
//Trigger when cards move in this zone //Trigger when cards move in this zone
+7
View File
@@ -153,6 +153,13 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan
} }
break; break;
case 'e': case 'e':
if (value == "emerge")
{
if (!tc)
tc = tcf.createTargetChooser("creature|mybattlefield", c);
manaCost->addExtraCost(NEW Offering(tc,true));
}
else
//Exile //Exile
manaCost->addExtraCost(NEW ExileTargetCost(tc)); manaCost->addExtraCost(NEW ExileTargetCost(tc));
break; break;